File size: 1,029 Bytes
27a578e e56edcc | 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 | 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", "*"]
|