FROM python:3.11-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    gcc \
    postgresql-client \
    && rm -rf /var/lib/apt/lists/*

# Copy API requirements only
COPY api/requirements.txt ./

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy only API code and game data
COPY api/ ./api/
COPY data/ ./data/
COPY gamedata/ ./gamedata/

# Copy migration scripts
COPY migrate_*.py ./

# Copy startup script
COPY api/start.sh ./
RUN chmod +x start.sh

# Expose port
EXPOSE 8000

# Run with auto-scaling workers
CMD ["./start.sh"]
