# Use Python 3.11 slim image FROM python:3.11-slim # Set environment variables ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 ENV FLASK_ENV=production ENV FLASK_SECRET=production-secret-change-me # Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ default-libmysqlclient-dev \ pkg-config \ curl \ && rm -rf /var/lib/apt/lists/* # Create app directory WORKDIR /app # 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 . . # Create necessary directories RUN mkdir -p cache logs # Expose port EXPOSE 8000 # Health check HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8000/ || exit 1 # Copy entrypoint script COPY docker-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-entrypoint.sh # Set entrypoint ENTRYPOINT ["docker-entrypoint.sh"] # Run gunicorn CMD ["gunicorn", "--config", "gunicorn.conf.py", "web.app:app"]