| FROM mcr.microsoft.com/playwright/python:v1.59.0-jammy | |
| # The Playwright base image already includes Chromium and required system libraries. | |
| WORKDIR /app | |
| # Copy requirements and install Python dependencies | |
| COPY app/requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Playwright browsers are already included in the base image. | |
| # Copy application code | |
| COPY app/ . | |
| # Create exports directory | |
| RUN mkdir -p exports logs | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PORT=7860 | |
| # Expose port | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ | |
| CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/').read()" || exit 1 | |
| # Start the application | |
| CMD ["gunicorn", "web_app:app", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120"] | |