Update Dockerfile
This commit is contained in:
parent
5e0cb48906
commit
3821a48f6f
39
Dockerfile
39
Dockerfile
|
@ -1,37 +1,24 @@
|
|||
# Build an intermediate image for the Python requirements
|
||||
FROM python:3.9-slim-buster as intermediate
|
||||
FROM python:3.11-alpine AS base
|
||||
|
||||
# Install Git and Python requirements
|
||||
RUN apt update && apt install -y build-essential
|
||||
FROM base AS build
|
||||
COPY requirements.txt .
|
||||
RUN python -m pip install --user -r requirements.txt
|
||||
|
||||
# Start from a fresh image
|
||||
FROM python:3.9-slim-buster
|
||||
|
||||
# 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
|
||||
FROM base AS app
|
||||
ENV PATH=$PATH:/app/.local/bin
|
||||
RUN adduser -u 4000 -h /app -D appuser
|
||||
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
|
||||
|
||||
# Set the main execution command
|
||||
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 --chown=appuser --from=build /root/.local /app/.local
|
||||
COPY slinky slinky/
|
||||
COPY templates templates/
|
||||
COPY config.yaml .
|
||||
COPY main.py .
|
||||
|
||||
FROM app
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV PYTHONPATH=/app
|
||||
ENTRYPOINT ["waitress-serve", "main:app"]
|
||||
EXPOSE 8080/tcp
|
||||
|
|
Loading…
Reference in a new issue