Spaces:
Sleeping
Sleeping
File size: 1,378 Bytes
850c319 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # Afterimage live backend — FastAPI + FastEmbed CLIP + embedded Qdrant.
# Built for a Hugging Face Docker Space (runs as UID 1000, serves on :7860).
FROM python:3.11-slim
RUN useradd -m -u 1000 user && mkdir -p /app && chown user:user /app
USER user
WORKDIR /app
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONUNBUFFERED=1 \
AFTERIMAGE_ASSET_ROOT=/app/data/assets \
AFTERIMAGE_MANIFEST=/app/data/manifest.json \
QDRANT_URL=path:/app/.qdrant-local \
AFTERIMAGE_ALLOW_FAKE_EMBEDDINGS=0 \
AFTERIMAGE_CORS_ORIGINS=* \
HF_HOME=/home/user/.cache/huggingface \
FASTEMBED_CACHE_DIR=/home/user/.cache/fastembed
COPY --chown=user backend/requirements.txt ./backend/requirements.txt
RUN pip install --no-cache-dir --user -r backend/requirements.txt
COPY --chown=user backend/ ./backend/
COPY --chown=user data/ ./data/
# Bake the model cache + seeded embedded Qdrant into the image so boots are fast.
# (Downloads CLIP ViT-B/32, embeds the 36 region/baseline/incident points.)
RUN cd backend && python scripts/seed.py \
&& python -c "from app.config import get_settings; from app.embedder import ImageEmbedder; ImageEmbedder(get_settings()).embed_text('warm up the clip text tower')" || echo "text-tower preload skipped"
EXPOSE 7860
WORKDIR /app/backend
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|