20 lines
706 B
Docker
20 lines
706 B
Docker
FROM python:3.12-slim-bookworm AS base
|
|
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 PIP_NO_CACHE_DIR=1
|
|
WORKDIR /app
|
|
RUN addgroup --system --gid 1001 app && adduser --system --uid 1001 --ingroup app app
|
|
COPY pyproject.toml README.md ./
|
|
COPY src ./src
|
|
|
|
FROM base AS test
|
|
RUN pip install . pytest ruff
|
|
COPY tests ./tests
|
|
RUN ruff check src tests && pytest -q
|
|
|
|
FROM base AS runtime
|
|
RUN pip install .
|
|
USER app
|
|
EXPOSE 8000
|
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=15s --retries=6 CMD ["python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)"]
|
|
CMD ["uvicorn", "pk_lab_server.main:app", "--host", "0.0.0.0", "--port", "8000", "--proxy-headers"]
|
|
|