# Synapse-Base Inference - Optimized for HF Spaces CPU (2 vCPU, 16GB RAM) FROM python:3.10-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ curl \ && rm -rf /var/lib/apt/lists/* # Copy requirements first (for Docker cache) COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY app.py . COPY engine.py . COPY model_loader.py . # Download model from HuggingFace (happens at build time) RUN python -c "from huggingface_hub import hf_hub_download; \ hf_hub_download(repo_id='GambitFlow/Synapse-Base', \ filename='synapse_base.onnx', \ local_dir='/app/models')" # Expose port EXPOSE 7860 # Set environment variables ENV PYTHONUNBUFFERED=1 ENV OMP_NUM_THREADS=2 ENV MKL_NUM_THREADS=2 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 # Run the application CMD ["python", "app.py"]