FROM python:3.12-slim

WORKDIR /app

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

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

# Copy application code
COPY . .

# Expose port 5000
EXPOSE 5000

# Start Gunicorn
# Using the config file we created earlier
CMD ["gunicorn", "-c", "deploy/gunicorn_config.py", "run:app"]
