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"]