FROM python:3.9-slim # Set working directory WORKDIR /app # Set environment variables first ENV TRANSFORMERS_CACHE=/tmp/transformers ENV HF_HOME=/tmp/huggingface ENV TORCH_HOME=/tmp/torch ENV HUGGINGFACE_HUB_CACHE=/tmp/huggingface/hub ENV PYTHONPATH=/app ENV FLASK_APP=app.py ENV FLASK_ENV=production # Install system dependencies RUN apt-get update && apt-get install -y \ git curl wget build-essential \ libgl1-mesa-dev libglib2.0-0 \ libsm6 libxext6 libxrender-dev \ libgomp1 libgcc-s1 ffmpeg \ && rm -rf /var/lib/apt/lists/* # Create cache directories with proper permissions RUN mkdir -p /tmp/transformers /tmp/huggingface /tmp/torch && \ chmod -R 777 /tmp/ # Copy application files COPY . . # Install minimal dependencies only RUN pip install --no-cache-dir --upgrade pip && \ pip install Flask==2.3.3 pillow>=10.0.0 && \ pip install requests>=2.31.0 loguru # Expose port EXPOSE 7860 # Simple health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 # Run with simple python command CMD ["python", "app.py"]