Download Dockerfile from sumandas/ostra: direct link, hf CLI and curl.
- Browser
- Download file 2.73 kB
-
https://huggingface.co/spaces/sumandas/ostra/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/sumandas/ostra/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/sumandas/ostra/resolve/main/Dockerfile
2.73 kB
| # Stage 1: Build React + Vite frontend bundle | |
| FROM node:22-slim AS frontend-builder | |
| WORKDIR /build/frontend | |
| RUN npm install -g pnpm@11 | |
| COPY frontend/package.json frontend/pnpm-lock.yaml frontend/pnpm-workspace.yaml ./ | |
| RUN pnpm install --frozen-lockfile | |
| COPY frontend/ ./ | |
| RUN pnpm build | |
| # Stage 2: Python 3.12 CPU runtime serving FastAPI + static frontend on port 7860 | |
| FROM python:3.12-slim AS runtime | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libgomp1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | |
| # Hugging Face Spaces runs containers as non-root UID 1000 | |
| RUN useradd -m -u 1000 user | |
| ENV HOME=/home/user \ | |
| PATH="/app/backend/.venv/bin:/home/user/.local/bin:${PATH}" \ | |
| OSTRA_DATA_DIR=/app/data \ | |
| OSTRA_HF_SPACE=1 \ | |
| HF_HOME=/home/user/.cache/huggingface \ | |
| HF_HUB_DISABLE_TELEMETRY=1 \ | |
| NUMBA_CACHE_DIR=/home/user/.cache/numba \ | |
| MPLCONFIGDIR=/tmp/matplotlib \ | |
| TOKENIZERS_PARALLELISM=false \ | |
| OMP_NUM_THREADS=2 \ | |
| OPENBLAS_NUM_THREADS=2 \ | |
| MKL_NUM_THREADS=2 \ | |
| NUMBA_NUM_THREADS=2 \ | |
| PYTHONUNBUFFERED=1 \ | |
| UV_LINK_MODE=copy | |
| WORKDIR /app | |
| # Install backend dependencies using CPU-only PyTorch wheels (saves ~2.5 GB on CPU Basic) | |
| COPY backend/pyproject.toml /app/backend/pyproject.toml | |
| RUN uv venv /app/backend/.venv \ | |
| && uv pip install --python /app/backend/.venv/bin/python \ | |
| --no-cache \ | |
| --torch-backend=cpu \ | |
| -r /app/backend/pyproject.toml | |
| # Copy backend source, built frontend bundle, and pre-loaded demo corpus | |
| COPY --chown=user:user backend/app /app/backend/app | |
| COPY --from=frontend-builder --chown=user:user /build/frontend/dist /app/frontend/dist | |
| COPY --chown=user:user demo_data /app/data | |
| RUN mkdir -p /home/user/.cache/huggingface /home/user/.cache/numba /tmp/matplotlib \ | |
| && chown -R user:user /app /home/user | |
| USER user | |
| # Pre-warm default embedding model, lightweight reranker (~85 MB), and Numba UMAP JIT cache | |
| # so AG News search, Reranker Lab, and first user HF dataset index run immediately without cold stalls. | |
| RUN python -c "import numpy as np, umap; from sentence_transformers import SentenceTransformer, CrossEncoder; SentenceTransformer('BAAI/bge-small-en-v1.5', device='cpu'); CrossEncoder('cross-encoder/ms-marco-MiniLM-L-6-v2', max_length=512, device='cpu'); umap.UMAP(n_neighbors=10, min_dist=0.1, metric='cosine', random_state=42, low_memory=True, n_jobs=1).fit_transform(np.random.default_rng(42).standard_normal((40, 16)).astype(np.float32))" | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app.main:app", "--app-dir", "/app/backend", "--host", "0.0.0.0", "--port", "7860", "--proxy-headers", "--forwarded-allow-ips=*", "--timeout-keep-alive", "75"] | |