From 28a403a0dd139ccd46083ed2473b5ec5672591f7 Mon Sep 17 00:00:00 2001 From: Dome Date: Tue, 5 May 2026 20:20:43 +0200 Subject: [PATCH] Update dockerfile --- dockerfile | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/dockerfile b/dockerfile index efb29bd..d49b937 100644 --- a/dockerfile +++ b/dockerfile @@ -1,32 +1,55 @@ -# -------- Stage 1: base -------- +# -------------------------------------------------- +# Base Image +# -------------------------------------------------- FROM python:3.11-slim -# -------- Env -------- +# -------------------------------------------------- +# Environment +# -------------------------------------------------- ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 -# -------- System deps (minimal) -------- +# -------------------------------------------------- +# System Dependencies (minimal) +# -------------------------------------------------- RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ && rm -rf /var/lib/apt/lists/* -# -------- Workdir -------- +# -------------------------------------------------- +# Workdir +# -------------------------------------------------- WORKDIR /app -# -------- Dependencies -------- +# -------------------------------------------------- +# Python Dependencies +# -------------------------------------------------- COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -# -------- App -------- -COPY app.py . +# -------------------------------------------------- +# App +# -------------------------------------------------- +COPY . . -# -------- Non-root user -------- +# -------------------------------------------------- +# Create cache directory (important!) +# -------------------------------------------------- +RUN mkdir -p /app/cache + +# -------------------------------------------------- +# Security: Non-root user +# -------------------------------------------------- RUN useradd -m appuser USER appuser -# -------- Healthcheck -------- +# -------------------------------------------------- +# Healthcheck +# -------------------------------------------------- HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ CMD curl -f http://localhost:5000/healthz || exit 1 -# -------- Run -------- -CMD ["python", "app.py"] +# -------------------------------------------------- +# Start (Production) +# -------------------------------------------------- +CMD ["gunicorn", "-w", "2", "-k", "gthread", "-t", "60", "-b", "0.0.0.0:5000", "app:app"]