FROM python:3.9-slim

WORKDIR /app

# Copy requirements first for better Docker layer caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application files
COPY . .

# Run migration on startup then start app
EXPOSE 8310
CMD ["sh", "-c", "python migrate_db.py && python main.py"]
