lampdra-api / Dockerfile
Paul1k's picture
Update Dockerfile
873b44f verified
Raw
History Blame Contribute Delete
1.76 kB
FROM python:3.10-slim
WORKDIR /app
# ── System Dependencies ────────────────────────────────────────────
RUN apt-get update && apt-get install -y \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
g++ \
&& rm -rf /var/lib/apt/lists/*
# ── Python Dependencies ────────────────────────────────────────────
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ── App Code ───────────────────────────────────────────────────────
COPY app.py .
COPY download_model.py .
# ── Bake Model Into Image at Build Time ───────────────────────────
# Runs download_model.py once during build β€” not on every cold start
# Model files become permanently part of the image
RUN python download_model.py
EXPOSE 7860
# ── Start the API ──────────────────────────────────────────────────
# 2 workers β€” each runs its own copy of app.py with its own pool of 4
# Total simultaneous capacity: 2 workers Γ— 4 pool = 8 images at once
# RAM estimate: 2 Γ— (4 Γ— 1.2GB model + 0.3GB app) = ~10.6GB (safe on HF free tier)
# uvicorn[standard] adds uvloop + httptools for faster HTTP handling
# If Worker 1 crashes β€” Uvicorn auto-restarts it while Worker 2 keeps serving
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]