github-actions[bot]
Automated Deploy: f4f01388c7b26e818cffbd64414eac11381a7891
35e80ff
Raw History Blame Contribute Delete
1.03 kB
# syntax=docker/dockerfile:1
FROM python:3.11-slim AS build
WORKDIR /src
COPY pyproject.toml README.md ./
COPY src ./src
RUN pip install --no-cache-dir --prefix=/install ".[api]"
FROM python:3.11-slim
ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 \
COACH_CACHE_PATH=/data/responses.sqlite3 \
COACH_LOG_DIR=/data/logs \
COACH_ENV=prod
COPY --from=build /install /usr/local
RUN useradd --system --uid 10001 --home-dir /nonexistent coach && mkdir /data && chown coach /data
USER coach
VOLUME /data
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
CMD python -c "import urllib.request as u; u.urlopen('http://127.0.0.1:8000/healthz', timeout=2)"
# One worker on purpose: the response cache's single-flight and the in-memory budget guard live in the process.
# Scale by running more containers behind a load balancer, each with its own /data (or a shared budget store later).
CMD ["uvicorn", "ai_coach.api:create_app", "--factory", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]