FROM python:3.12-slim AS base # System deps for FAISS, sentencepiece, and torch RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install Python deps first (layer cache) COPY requirements.docker.txt ./requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Copy application code. Static chat UI lives at bee/static/ (since # 770a763) and is served by bee/server.py via FastAPI's StaticFiles # mount at URL /static — the mount resolves relative to __file__, so # the on-disk path under the container is /app/bee/static/. COPY bee/ ./bee/ COPY scripts/ ./scripts/ COPY .env.example ./.env.example # Copy ML artifacts under data/ (mirrors host layout — paths in bee/ point at ./data/*) COPY data/datasets/ ./data/datasets/ COPY data/rag_index/ ./data/rag_index/ COPY data/lora_checkpoints/ ./data/lora_checkpoints/ # Create dirs for runtime data RUN mkdir -p /app/data/datasets /app/data/rag_index /app/data/lora_checkpoints # Healthcheck reads whatever port the app actually bound to. # HF Spaces docker runtime sets PORT=7860 (verified against run logs of # commit 5a22d328 — uvicorn bound 7860, our cardData said app_port: 8000, # proxy probed :8000 forever, Space died at HF's 30-min watchdog). # Fix is two-pronged: cardData now says app_port: 7860 (matches reality), # and bee.server.main() reads PORT as a fallback to BEE_PORT. HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD python3 -c "import os, urllib.request; \ p = os.environ.get('BEE_PORT') or os.environ.get('PORT') or '7860'; \ urllib.request.urlopen(f'http://localhost:{p}/health')" || exit 1 # Both ports declared so the image runs cleanly under HF Spaces (7860, # the default the runtime forces) AND under generic docker run (8000, # our local default). bee.server picks via BEE_PORT > PORT > 7860. EXPOSE 7860 8000 ENV BEE_HOST=0.0.0.0 \ BEE_DEVICE=cpu \ PYTHONUNBUFFERED=1 CMD ["python3", "-m", "bee.server"]