FROM python:3.12-slim
WORKDIR /app
COPY server/requirements.txt ./server/
RUN pip install --no-cache-dir -r server/requirements.txt
COPY server/ ./server/
EXPOSE 8000
# Apply any pending DB migrations, THEN start the app. `alembic upgrade head` is
# safe on both fresh and existing databases (the baseline migration adopts an
# existing schema, so no manual stamp is needed). `exec` hands PID 1 to gunicorn
# for correct signal handling; --preload imports the app once before forking.
CMD ["sh", "-c", "alembic -c server/alembic.ini upgrade head && exec gunicorn -k uvicorn.workers.UvicornWorker --preload -b 0.0.0.0:8000 --workers 2 server.app:app"]