26 lines
860 B
Docker
26 lines
860 B
Docker
FROM python:3.12.7-slim@sha256:60d9996b6a8a3689d36db740b49f4327be3be09a21122bd02fb8895abb38b50d
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
APP_HOST=0.0.0.0 \
|
|
APP_PORT=8080
|
|
|
|
WORKDIR /app
|
|
|
|
RUN groupadd --system app && \
|
|
useradd --system --gid app --create-home app
|
|
|
|
COPY requirements.txt /app/requirements.txt
|
|
RUN pip install --no-cache-dir --timeout 60 -r requirements.txt
|
|
|
|
COPY --chown=app:app src/ /app/src/
|
|
COPY --chown=app:app migrations/ /app/migrations/
|
|
|
|
USER app
|
|
|
|
EXPOSE 8080
|
|
|
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=3 \
|
|
CMD python -c "import os, urllib.request; urllib.request.urlopen('http://127.0.0.1:' + os.environ['APP_PORT'] + '/health/ready', timeout=2)" || exit 1
|
|
|
|
CMD ["sh", "-c", "exec uvicorn src.main:app --host \"${APP_HOST}\" --port \"${APP_PORT}\" --timeout-graceful-shutdown 8"] |