# SuperKart Sales Forecasting API - Docker Configuration # ===================================================== # Use Python 3.11 slim image for optimal size and compatibility FROM python:3.11-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV FLASK_APP=app.py ENV FLASK_ENV=production # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends \ gcc \ g++ \ curl \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better Docker layer caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application files COPY . . # Create non-root user for security RUN adduser --disabled-password --gecos '' appuser && chown -R appuser:appuser /app USER appuser # Expose port EXPOSE 8080 # Health check HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8080/health || exit 1 # Production command using Gunicorn CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--workers", "2", "--timeout", "120", "--keep-alive", "2", "--max-requests", "1000", "--max-requests-jitter", "100", "app:app"] # Development command (commented out) # CMD ["python", "app.py"] # Container metadata LABEL maintainer="SuperKart ML Team" LABEL version="1.0" LABEL description="SuperKart Sales Forecasting API"