| # Use official Python runtime as base image | |
| FROM python:3.11-slim | |
| # Set working directory in container | |
| WORKDIR /app | |
| # Copy requirements file | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY app.py . | |
| # Expose port 7860 | |
| EXPOSE 7860 | |
| # Set environment variables (can be overridden at runtime) | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV FLASK_APP=app.py | |
| # Run the application with gunicorn for production | |
| CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "4", "app:app"] |