Spaces:
Running on Zero
Running on Zero
File size: 1,271 Bytes
24f7855 | 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 35 36 37 38 39 40 41 42 43 44 | # Production Dockerfile for Enterprise Corrective RAG (CRAG) on Hugging Face Spaces
FROM python:3.12-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PORT=7860 \
HOME=/home/user
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Set up standard non-root user (UID 1000 required by Hugging Face Spaces)
RUN useradd -m -u 1000 user
WORKDIR $HOME/app
# Install Python dependencies as root
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Pre-download NLTK sentence tokenization models
RUN python -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab')"
# Copy application files and set permissions for non-root user
COPY --chown=user:user . $HOME/app
# Switch to non-root user
USER user
ENV PATH=$HOME/.local/bin:$PATH
# Expose standard Hugging Face Spaces port
EXPOSE 7860
# Container health probe
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Launch ASGI FastAPI application on port 7860
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"]
|