Natnael B. Haile
Cursor
feat: complete IR Studio with Git LFS tracking for all binary assets and NFCorpus index
fbad523 Download Dockerfile from NathyB/ir-studio: direct link, hf CLI and curl.
- Browser
- Download file 2.2 kB
-
https://huggingface.co/spaces/NathyB/ir-studio/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/NathyB/ir-studio/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/NathyB/ir-studio/resolve/main/Dockerfile
2.2 kB
| # ============================================================================== | |
| # IR Studio Multi-Stage Production Dockerfile (Hugging Face Spaces & Standalone) | |
| # Serves both the compiled React frontend and the live FastAPI backend | |
| # ============================================================================== | |
| # --- Stage 1: Build Frontend SPA --- | |
| FROM node:22-bookworm-slim AS frontend-builder | |
| WORKDIR /build | |
| # Copy dependency definitions & install | |
| COPY package.json package-lock.json ./ | |
| RUN npm ci | |
| # Copy source code and build Vite static bundle | |
| COPY index.html vite.config.ts tsconfig.json tsconfig.app.json tsconfig.node.json ./ | |
| COPY public/ ./public/ | |
| COPY src/ ./src/ | |
| ENV VITE_BASE_PATH=/ | |
| ENV VITE_API_URL= | |
| RUN npm run build | |
| # --- Stage 2: Production Python API Runner --- | |
| FROM python:3.11-slim-bookworm AS runner | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install Python requirements | |
| COPY api/requirements.txt /app/api/requirements.txt | |
| RUN pip install --no-cache-dir -r /app/api/requirements.txt | |
| # Copy backend code | |
| COPY api/ /app/api/ | |
| # Copy precomputed NFCorpus indices (Faiss 768-D & Lucene, ~18MB total) | |
| COPY indexes/ /app/indexes/ | |
| # Copy built frontend assets from builder stage | |
| COPY --from=frontend-builder /build/dist /app/dist | |
| # Ensure writable cache directory for Hugging Face downloads when running as non-root (HF Spaces UID 1000) | |
| RUN mkdir -p /app/.cache/huggingface /tmp/huggingface && chmod -R 777 /app/.cache /tmp/huggingface | |
| # Environment settings (Default to HF Spaces standard port 7860) | |
| ENV HOST=0.0.0.0 | |
| ENV PORT=7860 | |
| ENV PYTHONPATH=/app | |
| ENV STATIC_DIR=/app/dist | |
| ENV HF_HOME=/tmp/huggingface | |
| ENV FAISS_INDEX_DIR=/app/indexes/nfcorpus.bge-base-en-v1.5 | |
| ENV ONNX_NUM_THREADS=4 | |
| ENV MAX_CACHE_ENTRIES=2000 | |
| EXPOSE 7860 | |
| # Container healthcheck | |
| HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ | |
| CMD curl -f http://localhost:${PORT:-7860}/api/health || exit 1 | |
| # Start ASGI application (reads $PORT dynamically for HF Spaces or custom port) | |
| CMD ["sh", "-c", "python -m uvicorn api.app:app --host 0.0.0.0 --port ${PORT:-7860}"] | |