Spaces:
Build error
Build error
| # EuropaLex β Docker / Hugging Face Spaces Deployment | |
| # Single-stage build: CPU-only deps + Gradio launch. | |
| # Models (~26 GB) are downloaded at runtime via app.py (_auto_download_models). | |
| # | |
| # Build (local, with token for gated models): | |
| # docker build --secret id=hf_token,env=HUGGING_FACE_HUB_TOKEN -t europalex . | |
| # | |
| # Run (local test): | |
| # docker run -p 7860:7860 europalex | |
| FROM python:3.12-slim | |
| # βββ System dependencies βββββββββββββββββββββββββββββββββββββββββββββββ | |
| # git for huggingface-cli, build-essential for llama-cpp-python compilation | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| git \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # βββ Build secret: Hugging Face token ββββββββββββββββββββββββββββββββββ | |
| # Mounted at /run/secrets/hf_token during docker build. | |
| # Used to authenticate huggingface-cli download of gated models. | |
| RUN --mount=type=secret,id=hf_token \ | |
| if [ -f /run/secrets/hf_token ]; then \ | |
| echo "Authenticated as $(huggingface-cli whoami --token $(cat /run/secrets/hf_token) 2>/dev/null || echo 'unknown')"; \ | |
| else \ | |
| echo "WARNING: No HUGGING_FACE_HUB_TOKEN secret provided. Model download will fail for gated models."; \ | |
| fi | |
| # βββ CPU-only PyTorch ββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Install from the official CPU wheel index to avoid ~2 GB of CUDA deps. | |
| RUN pip install --no-cache-dir \ | |
| --extra-index-url https://download.pytorch.org/whl/cpu \ | |
| torch>=2.1.0 | |
| # βββ llama-cpp-python (CPU-only build) βββββββββββββββββββββββββββββββββ | |
| # LLAMA_CUDA=0 forces CPU-only compile, skipping GPU backend entirely. | |
| # Without this, llama-cpp-python compiles from source for 15-30+ min with | |
| # no output, appearing frozen on HF Spaces. | |
| RUN LLAMA_CUDA=0 pip install --no-cache-dir \ | |
| llama-cpp-python>=0.3.28 | |
| # βββ Other Python dependencies βββββββββββββββββββββββββββββββββββββββββ | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # βββ Copy project source βββββββββββββββββββββββββββββββββββββββββββββββ | |
| COPY . /app | |
| WORKDIR /app | |
| # βββ Models downloaded at runtime by app.py (_auto_download_models) ββββ | |
| # Downloading ~26 GB of model weights at build time exceeds HF Spaces' timeout. | |
| # The auto-download runs on first app start, keeping the build fast. | |
| # βββ Launch ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| EXPOSE 7860 | |
| CMD ["python", "app.py"] | |