afterimage / Dockerfile
KryptosK's picture
Afterimage live backend (FastAPI + FastEmbed + embedded Qdrant)
850c319 verified
Raw
History Blame Contribute Delete
1.38 kB
# 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"]