# ============================================================ # Image Compressor Pro — Python Backend (HuggingFace Spaces) # ============================================================ FROM python:3.11-slim # System dependencies for Pillow and pillow-heif RUN apt-get update && apt-get install -y --no-install-recommends \ libheif-dev \ libavif-dev \ libjpeg-turbo-progs \ libjpeg62-turbo-dev \ libwebp-dev \ libtiff-dev \ libffi-dev \ gcc \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install Python dependencies first (Docker layer caching) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY app.py . # HuggingFace Spaces expects port 7860 EXPOSE 7860 # Production: use multiple workers for concurrency CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4", "--log-level", "info"]