Files
devops/Dockerfile
gitea ea335c96d0
Some checks failed
Build and Deploy Demo App / test (push) Successful in 12s
Build and Deploy Demo App / build (push) Successful in 16s
Build and Deploy Demo App / scan (push) Successful in 19s
Build and Deploy Demo App / deploy (push) Failing after 2m13s
Refactored Dockerfile
2025-11-26 13:50:06 +03:30

22 lines
813 B
Docker

# Build stage
FROM python:3.12-slim AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Runtime stage
FROM python:3.12-slim
WORKDIR /app
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
# NEW: Copy binaries like gunicorn
COPY --from=builder /usr/local/bin /usr/local/bin
COPY app.py models.py .
COPY templates ./templates
# NEW: Install wget for healthcheck (run as root, before switching user)
RUN apt-get update && apt-get install -y --no-install-recommends wget && rm -rf /var/lib/apt/lists/*
RUN useradd -m appuser
USER appuser
EXPOSE 5000
HEALTHCHECK --interval=30s --timeout=3s CMD wget --no-verbose --tries=1 --spider http://localhost:5000/ || exit 1
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]