FROM python:3.12-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 WORKDIR /app # HF Docker Spaces execute as uid 1000. Match that identity so copied code # and writable runtime mounts are usable after the build container is gone. RUN groupadd --gid 1000 libbee \ && useradd --uid 1000 --gid 1000 --create-home libbee \ && chown libbee:libbee /app COPY --chown=libbee:libbee requirements.txt ./ RUN pip install --no-cache-dir --requirement requirements.txt COPY --chown=libbee:libbee . . USER libbee EXPOSE 7860 HEALTHCHECK --interval=30s --timeout=8s --start-period=90s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:7860/health/live', timeout=5)" # Keep one process: the local session/metrics stores are not a shared database. # HF supplies the public address through its trusted reverse proxy. CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--proxy-headers", "--forwarded-allow-ips", "*"]