# Use official Python base image (faster & smaller than Ubuntu + manual Python) FROM python:3.10-slim # Set working directory WORKDIR /app # Prevent Python from buffering stdout/stderr ENV PYTHONUNBUFFERED=1 # Copy requirements first for better caching COPY requirements.txt . # Use PyPI mirror + increased timeout to avoid network errors RUN pip install --no-cache-dir -r requirements.txt \ -i https://pypi.org/simple \ --timeout=100 # Copy application code COPY . . # Environment variables ENV FLASK_ENV=production ENV FLASK_APP=run.py ENV FLASK_RUN_HOST=0.0.0.0 ENV FLASK_RUN_PORT=5000 # Expose the Flask port EXPOSE 5000 # Use Gunicorn for production CMD ["gunicorn", "--bind", "0.0.0.0:5000", "run:app"]