gng / Dockerfile
plexdx's picture
Upload 21 files
f589dab verified
# Multi-stage Dockerfile optimized for Hugging Face Spaces
# HF Spaces requirements: port 7860, runs as non-root user
FROM python:3.12-slim AS base
# Install system deps
RUN apt-get update && apt-get install -y --no-install-recommends \
curl git build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install uv (Rust-native Python package manager)
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.cargo/bin:/root/.local/bin:$PATH"
WORKDIR /app
# Copy dependency files first for layer caching
COPY pyproject.toml ./
# Install dependencies with uv (10-100x faster than pip)
RUN uv pip install --system --no-cache \
fastapi uvicorn[standard] websockets pydantic pydantic-settings \
litellm groq qdrant-client fastembed \
redis[hiredis] aiokafka structlog httpx \
python-multipart xxhash neo4j python-dotenv orjson \
anyio tenacity prefect
# Copy source
COPY . .
# Create cache directory for FastEmbed model weights
RUN mkdir -p /tmp/fastembed_cache
# HF Spaces runs as user 1000
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app /tmp/fastembed_cache
USER appuser
# Expose HF Spaces standard port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
CMD ["python", "hf_main.py"]