FROM python:3.9-slim

ENV PIP_DEFAULT_TIMEOUT=120

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir --retries 5 -r requirements.txt

# Copy application files
COPY app ./app

# Set environment variables
ENV PYTHONUNBUFFERED=1

# Expose port
EXPOSE 3000

# Run the API server with gunicorn (Flask dev server is for the dev override).
CMD ["gunicorn", "--workers", "2", "--timeout", "30", "--bind", "0.0.0.0:3000", "app.cm_api:create_app()"]
