FROM python:3.12-slim AS builder WORKDIR /app COPY requirements.txt . RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt COPY . . RUN python -m compileall -b . FROM python:3.12-slim WORKDIR /app COPY --from=builder /app/wheels /wheels COPY --from=builder /app/requirements.txt . RUN pip install --no-cache /wheels/* COPY --from=builder /app /app RUN find . -type d -name "__pycache__" | while read -r dir; do \ module_dir=$(dirname "$dir"); \ mv "$dir"/*.pyc "$module_dir/"; \ rmdir "$dir"; \ done RUN find . -name "*.py" -delete EXPOSE 8000 # CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] CMD ["gunicorn", "--config", "gunicorn.conf.pyc", "main:app"]