FROM python:3.13-slim

WORKDIR /app
ENV PYTHONPATH=/app

# Install dependencies first (layer caching)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY . .

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

EXPOSE 8000

CMD ["sh", "-c", "alembic upgrade head && python repair_class_memberships.py && uvicorn app.main:app --host 0.0.0.0 --port 8000"]
