FROM python:3.11-slim RUN apt-get update && apt-get install -y --no-install-recommends \ libpq-dev gcc libgl1 libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # Hugging Face Spaces runs Docker containers as UID 1000 — create a matching # user so the app can write the SQLite db and media/ uploads at runtime. RUN useradd -m -u 1000 user WORKDIR /app RUN chown user:user /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY --chown=user app ./app USER user EXPOSE 7860 # Railway/other PaaS inject $PORT; Hugging Face Spaces doesn't, so this falls # back to 7860 to match the app_port declared in README.md's Space metadata. CMD uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860}