-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (32 loc) · 1.12 KB
/
Dockerfile
File metadata and controls
46 lines (32 loc) · 1.12 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
# ----------- Stage 1: Builder -----------
FROM python:3.14-slim AS builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /app
COPY requirements.txt .
RUN python -m venv /venv && \
/venv/bin/pip install --upgrade pip==23.3 && \
/venv/bin/pip install --no-cache-dir -r requirements.txt
# ----------- Stage 2: Runtime -----------
FROM python:3.14-slim
# Build-time argument
ARG PORT=8080
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
FLASK_APP=app/app.py \
FLASK_ENV=production \
PATH="/venv/bin:$PATH" \
APP_PORT=${PORT} \
GUNICORN_TIMEOUT=120 \
GUNICORN_WORKERS=2 \
GUNICORN_THREADS=4
WORKDIR /app
RUN useradd --create-home --shell /bin/bash appuser
COPY --from=builder /venv /venv
COPY --chown=appuser:appuser . .
USER appuser
EXPOSE ${APP_PORT}
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${APP_PORT}/health || exit 1
ENTRYPOINT ["sh", "-c"]
CMD ["gunicorn --bind 0.0.0.0:${APP_PORT} --timeout ${GUNICORN_TIMEOUT} --workers ${GUNICORN_WORKERS} --threads ${GUNICORN_THREADS} --log-level info app.app:app"]