Download Dockerfile from Cuong2004/LocalMate: direct link, hf CLI and curl.
- Browser
- Download file 2.12 kB
-
https://huggingface.co/spaces/Cuong2004/LocalMate/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/Cuong2004/LocalMate/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/Cuong2004/LocalMate/resolve/main/Dockerfile
2.12 kB
| # ============================================================================= | |
| # LocalMate Backend - Hugging Face Spaces Docker Deployment | |
| # ============================================================================= | |
| # Multi-stage build with SigLIP model pre-cached for optimal cold start | |
| # Stage 1: Build dependencies | |
| FROM python:3.11-slim as builder | |
| WORKDIR /app | |
| # Install build dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy dependency files (README.md required by pyproject.toml) | |
| COPY pyproject.toml README.md ./ | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir . | |
| # ============================================================================= | |
| # Stage 2: Production image | |
| # ============================================================================= | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Install runtime dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libgomp1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy installed packages from builder | |
| COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages | |
| COPY --from=builder /usr/local/bin /usr/local/bin | |
| # Copy application code | |
| COPY app ./app | |
| # Pre-download SigLIP model during build (cache in image) | |
| # This avoids downloading on every cold start | |
| RUN python -c "from open_clip import create_model_and_transforms; \ | |
| model, _, preprocess = create_model_and_transforms('ViT-B-16-SigLIP', pretrained='webli'); \ | |
| print('✅ SigLIP model cached')" | |
| # Create cache directory for HF models | |
| RUN mkdir -p /root/.cache/huggingface | |
| # Environment variables | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| # HF Spaces expects port 7860 | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ | |
| CMD python -c "import httpx; httpx.get('http://localhost:7860/health')" || exit 1 | |
| # Run with uvicorn | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] | |