# Use an official Python runtime as a parent image FROM python:3.11-slim # Set environment variables for performance ENV PYTHONUNBUFFERED=1 \ PYTHONOPTIMIZE=1 \ HOST=0.0.0.0 \ PORT=7860 \ DATABASE_URL=sqlite:///./vortex.db # Set the working directory in the container WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ fonts-dejavu-core \ && rm -rf /var/lib/apt/lists/* # Copy only requirements first to leverage Docker layer caching COPY requirements.txt . # Install dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY . . # Hugging Face Spaces runs as user with UID 1000 RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app USER appuser # Expose port 7860 as required by Hugging Face Spaces EXPOSE 7860 # Command to run the application CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--proxy-headers", "--forwarded-allow-ips='*'"]