Update Dockerfile

This commit is contained in:
Scott Wallace 2025-02-12 10:14:35 +00:00
parent 5e0cb48906
commit 3821a48f6f
Signed by: scott
SSH key fingerprint: SHA256:+LJug6Dj01Jdg86CILGng9r0lJseUrpI0xfRqdW9Uws

View file

@ -1,37 +1,24 @@
# Build an intermediate image for the Python requirements FROM python:3.11-alpine AS base
FROM python:3.9-slim-buster as intermediate
# Install Git and Python requirements FROM base AS build
RUN apt update && apt install -y build-essential
COPY requirements.txt . COPY requirements.txt .
RUN python -m pip install --user -r requirements.txt RUN python -m pip install --user -r requirements.txt
# Start from a fresh image FROM base AS app
FROM python:3.9-slim-buster ENV PATH=$PATH:/app/.local/bin
RUN adduser -u 4000 -h /app -D appuser
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
RUN useradd -u 4000 -d /app appuser
WORKDIR /app WORKDIR /app
# Copy over the Python requirements from the intermediate container
COPY --from=intermediate /root/.local /app/.local
RUN chown -R appuser: /app
USER appuser USER appuser
# Set the main execution command COPY --chown=appuser --from=build /root/.local /app/.local
ENTRYPOINT [".local/bin/waitress-serve", "main:app"]
# HEALTHCHECK --interval=5s --timeout=30s --start-period=5s --retries=3 CMD [ "/app/healthcheck.sh" ]
EXPOSE 8080/tcp
# Copy in the code
COPY slinky slinky/ COPY slinky slinky/
COPY templates templates/ COPY templates templates/
COPY config.yaml . COPY config.yaml .
COPY main.py . COPY main.py .
FROM app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
ENTRYPOINT ["waitress-serve", "main:app"]
EXPOSE 8080/tcp