Spaces:
Runtime error
Runtime error
File size: 1,002 Bytes
56b04cf | 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 | FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Hugging Face Spaces requires a non-root user
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Copy requirements first for better Docker caching
COPY --chown=user server/requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy all environment code
COPY --chown=user . $HOME/app/
# Set PYTHONPATH correctly
ENV PYTHONPATH="$HOME/app:$PYTHONPATH"
# Health check (Updated to 7860)
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')" || exit 1
# Expose HF Space port
EXPOSE 7860
# Run the FastAPI server (Updated to 7860)
CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "7860"] |