Refactored Dockerfile
This commit is contained in:
@@ -8,12 +8,14 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||||||
FROM python:3.12-slim
|
FROM python:3.12-slim
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
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 app.py models.py .
|
||||||
COPY templates ./templates
|
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
|
RUN useradd -m appuser
|
||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
HEALTHCHECK --interval=30s --timeout=3s CMD wget --no-verbose --tries=1 --spider http://localhost:5000/ || exit 1
|
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"]
|
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
|
||||||
|
|||||||
Reference in New Issue
Block a user