-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (35 loc) · 1.66 KB
/
Dockerfile
File metadata and controls
47 lines (35 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# ── Build stage ─────────────────────────────────────────────────────────────
FROM python:3.12-slim AS builder
WORKDIR /app
# Install OS-level dependencies required by PyMuPDF
RUN apt-get update && apt-get install -y --no-install-recommends \
libmupdf-dev \
mupdf-tools \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies into a prefix so they can be copied cleanly
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# ── Runtime stage ────────────────────────────────────────────────────────────
FROM python:3.12-slim AS runtime
WORKDIR /app
# Minimal runtime OS libs needed by PyMuPDF at runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
libmupdf-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy installed packages from builder
COPY --from=builder /install /usr/local
# Copy application source
COPY app.py spool_optimizer.py ./
COPY templates/ templates/
COPY assets/ assets/
# Non-root user for security
RUN useradd --no-create-home --shell /bin/false appuser \
&& chown -R appuser:appuser /app
USER appuser
# Flask / Gunicorn config via env (overridable at runtime)
ENV FLASK_ENV=production \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
EXPOSE 5000
# Use gunicorn for production; single worker is fine for a CPU-bound task
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "2", "--timeout", "120", "app:app"]