social-mi-bi/deploy/Dockerfile.prod

30 lines
926 B
Text

FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY backend/pyproject.toml /app/pyproject.toml
RUN pip install --upgrade pip && pip install -e .
COPY backend /app
# Ops scripts (reset_password, run_e2e_cif, seed_benchmarks…). They expect
# PYTHONPATH=/app which is the default WORKDIR, so `python scripts/foo.py`
# resolves cleanly.
COPY scripts /app/scripts
# Baked-in git SHA (set via --build-arg GIT_SHA=... by the deploy script).
ARG GIT_SHA=unknown
ENV GIT_SHA=${GIT_SHA}
# On boot: apply migrations then launch the API.
CMD ["sh", "-c", "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000 --proxy-headers --forwarded-allow-ips='*'"]