FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && \ apt-get install -y --no-install-recommends \ curl \ libheif-dev \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Create directories for runtime data RUN mkdir -p /tmp/flask_session /app/data && \ chmod 777 /tmp/flask_session # Create non-root user for security RUN useradd -m -u 1000 nextsnap && \ chown -R nextsnap:nextsnap /app /tmp/flask_session USER nextsnap # Expose port EXPOSE 8000 # Health check HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ CMD curl -f http://localhost:8000/api/health || exit 1 # Use gunicorn for production with app factory CMD ["gunicorn", \ "--workers", "4", \ "--bind", "0.0.0.0:8000", \ "--timeout", "120", \ "--access-logfile", "-", \ "--error-logfile", "-", \ "--log-level", "info", \ "app:create_app()"]