FROM python:3.13-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Install the complete application as an immutable production package.
COPY . .
RUN pip install --no-cache-dir .

# Expose port
EXPOSE 8000

# Migrations must run against the configured runtime database, not against a
# throwaway SQLite file while the image is being built.
CMD ["sh", "-c", "alembic upgrade head && exec uvicorn app.main:app --host 0.0.0.0 --port 8000"]
