FROM python:3.11-slim

WORKDIR /app

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

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

# Copy application code
COPY . .

# Make entrypoints executable
RUN chmod +x /app/entrypoint.sh /app/entrypoint.prod.sh

# Expose port
EXPOSE 8000

# Default command (migrations + seed + uvicorn)
CMD ["sh", "/app/entrypoint.sh"]
