1- FROM python:3.12-slim
1+ # ββ Stage 1: build dependencies ββββββββββββββββββββββββββββββββββββββββββββββ
2+ FROM python:3.13-alpine AS builder
3+
4+ # Build deps needed to compile cryptography (Rust/C) and other native packages
5+ RUN apk add --no-cache gcc musl-dev libffi-dev openssl-dev cargo
6+
7+ WORKDIR /build
8+
9+ COPY requirements.txt .
10+ RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
11+
12+
13+ # ββ Stage 2: runtime image ββββββββββββββββββββββββββββββββββββββββββββββββββββ
14+ FROM python:3.13-alpine
215
316# ββ OCI image annotations βββββββββββββββββββββββββββββββββββββββββββββββββββββ
417LABEL org.opencontainers.image.title="Ghostbit" \
@@ -9,29 +22,22 @@ LABEL org.opencontainers.image.title="Ghostbit" \
922 org.opencontainers.image.vendor="StackOps HQ" \
1023 org.opencontainers.image.licenses="MIT"
1124
12- WORKDIR /app
25+ # Runtime deps only (no compiler, no Rust, no build tools)
26+ RUN apk add --no-cache libffi openssl
1327
14- COPY requirements.txt .
15- RUN pip install --no-cache-dir -r requirements.txt
28+ # Copy installed packages from builder
29+ COPY --from=builder /install /usr/local
1630
31+ WORKDIR /app
1732COPY . .
1833
1934RUN mkdir -p /data
2035
2136# ββ Runtime configuration βββββββββββββββββββββββββββββββββββββββββββββββββββββ
22- # Storage backend: "sqlite" or "redis"
2337ENV STORAGE_BACKEND=sqlite
24-
25- # SQLite database path (only used when STORAGE_BACKEND=sqlite)
2638ENV SQLITE_PATH=/data/ghostbit.db
27-
28- # Redis connection URL (only used when STORAGE_BACKEND=redis)
2939ENV REDIS_URL=redis://localhost:6379
30-
31- # Maximum paste size in bytes (default: 512 KB)
3240ENV MAX_PASTE_SIZE=524288
33-
34- # Server port
3541ENV PORT=8000
3642
3743EXPOSE ${PORT}
0 commit comments