FROM python:3.11-slim-bullseye # Install system dependencies RUN apt-get update && \ apt-get install -y build-essential curl && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /rideaware_landing # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Set environment variables ENV FLASK_APP=server.py ENV PYTHONUNBUFFERED=1 ENV PYTHONPATH=/rideaware_landing # Create non-root user for security RUN useradd --create-home --shell /bin/bash app && \ chown -R app:app /rideaware_landing USER app # Expose port EXPOSE 5000 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:5000/health || exit 1 # Run with optimized Gunicorn settings CMD ["gunicorn", \ "--bind", "0.0.0.0:5000", \ "--workers", "4", \ "--worker-class", "sync", \ "--worker-connections", "1000", \ "--max-requests", "1000", \ "--max-requests-jitter", "50", \ "--preload", \ "--timeout", "30", \ "--keep-alive", "2", \ "--access-logfile", "-", \ "--error-logfile", "-", \ "--log-level", "info", \ "server:app"]