# Use a slim Python image
FROM python:3.11-slim

# Environment: no .pyc files, real-time logs
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Create working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
 && rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip && pip install -r requirements.txt

# Copy app code
COPY . .

# Expose Flask port
EXPOSE 5000

# Launch Gunicorn with 8 workers (adjust for your CPU cores)
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app", "--workers", "8"]