FROM python:3.12-slim

WORKDIR /app

# Install dependencies first (cache layer)
COPY pyproject.toml README.md ./
COPY src/ src/
RUN pip install --no-cache-dir . && \
    pip install --no-cache-dir gunicorn

# Create data directory for SQLite
RUN mkdir -p /app/data

ENV CODETRUST_DB_PATH=/app/data/codetrust.db
ENV CODETRUST_HOST=0.0.0.0
ENV CODETRUST_PORT=8080

EXPOSE 8080

CMD ["gunicorn", "aicodetrustcore.api:app", \
     "-k", "uvicorn.workers.UvicornWorker", \
     "-b", "0.0.0.0:8080", \
     "--workers", "2", \
     "--timeout", "120"]
