54 lines
1.1 KiB
Docker
54 lines
1.1 KiB
Docker
# REF https://github.com/scratchmex/poetry-docker-template/blob/main/dockerfile.jinja
|
|
|
|
FROM python:3.11-slim-bookworm as base-python
|
|
|
|
####################
|
|
# - Build Variables
|
|
####################
|
|
ARG PIP_DISABLE_PIP_VERSION_CHECK 1
|
|
ARG PIP_NO_CACHE_DIR 1
|
|
## Disable Non-Reproducible pip
|
|
|
|
####################
|
|
# - Environment Variables
|
|
####################
|
|
ENV PYTHONOPTIMIZE 1
|
|
## Strip __debug__
|
|
|
|
ENV PYTHONUNBUFFERED 1
|
|
## Disable stdout/stderr Buffering
|
|
|
|
|
|
|
|
####################
|
|
# - Stage: Builder
|
|
####################
|
|
FROM base-python AS base-builder
|
|
WORKDIR /app-src
|
|
|
|
RUN pip install -r requirements.txt
|
|
|
|
|
|
|
|
####################
|
|
# - Stage: Production
|
|
####################
|
|
FROM base-python as production
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install --no-install-recommends -y \
|
|
curl
|
|
|
|
RUN groupadd -g 1500 pyrunner && \
|
|
useradd -m -u 1500 -g pyrunner pyrunner
|
|
|
|
COPY --chown=pyrunner:pyrunner ./app /app
|
|
COPY --from=builder-base --chown=poetry:poetry /app-src/.venv /app/.venv
|
|
|
|
USER poetry
|
|
WORKDIR /app
|
|
|
|
HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1
|
|
|
|
CMD poetry run uvicorn --proxy-headers --host=0.0.0.0 --port=3000 app.main:app
|