# Use Python 3.11 slim image as base FROM python:3.11-slim # Set working directory WORKDIR /app # Set environment variables ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 # Install system dependencies for OpenCV, QR code processing, and other requirements RUN apt-get update && apt-get install -y \ libzbar0 \ libzbar-dev \ libopencv-dev \ python3-opencv \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ libgomp1 \ libgtk-3-0 \ libgdk-pixbuf2.0-0 \ libpango-1.0-0 \ libcairo2 \ libfontconfig1 \ libfreetype6 \ libx11-6 \ wget \ curl \ build-essential \ && rm -rf /var/lib/apt/lists/* # Copy requirements file COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy application files COPY app.py . # Create directory for QR temporal data (fallback storage) RUN mkdir -p qr_temporal_data # Expose the port that Gradio runs on EXPOSE 7860 # Add health check HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860 || exit 1 # Set default environment variables (can be overridden) ENV MONGODB_DATABASE=qrcodetcp ENV MONGODB_COLLECTION=content_snapshots ENV MAX_CONTENT_LENGTH=2000 # Run the application CMD ["python", "app.py"]