FROM python:3.12-slim WORKDIR /app # Install only psycopg2 build deps (needed for alembic sync driver) RUN apt-get update && \ apt-get install -y --no-install-recommends libpq-dev gcc && \ rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt psycopg2-binary COPY alembic.ini . COPY alembic/ alembic/ COPY app/ app/ EXPOSE 8001 CMD ["sh", "-c", "alembic upgrade head && gunicorn app.main:app -k uvicorn.workers.UvicornWorker -w 2 -b 0.0.0.0:8001 --timeout 30"]