feat: add containerized FastAPI health check

This commit is contained in:
bot
2026-08-11 14:44:59 +03:00
parent fea8ca89f8
commit f7e668d692
10 changed files with 167 additions and 2 deletions
+35
View File
@@ -0,0 +1,35 @@
FROM python:3.12-slim-bookworm AS base
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
WORKDIR /app
RUN groupadd --gid 10001 app \
&& useradd --uid 10001 --gid app --no-create-home --shell /usr/sbin/nologin app
COPY requirements.txt ./
RUN pip install --no-cache-dir --requirement requirements.txt
FROM base AS test
COPY requirements-dev.txt pyproject.toml ./
RUN pip install --no-cache-dir --requirement requirements-dev.txt
COPY --chown=app:app app ./app
COPY --chown=app:app tests ./tests
USER app
CMD ["pytest"]
FROM base AS runtime
COPY --chown=app:app app ./app
USER app
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--no-access-log"]