FROM python:3.12-slim-bookworm RUN apt-get update && apt-get install -y --no-install-recommends libstdc++6 libgomp1 tini build-essential python3-dev \ && rm -rf /var/lib/apt/lists/* RUN useradd --create-home --uid 1000 appuser WORKDIR /app COPY requirements.txt /app/requirements.txt RUN pip install --no-cache-dir -r /app/requirements.txt COPY --chown=1000:1000 . /app RUN chown -R 1000:1000 /app USER 1000 ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 \ GRADIO_ANALYTICS_ENABLED=False GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860 \ OMP_NUM_THREADS=2 OPENBLAS_NUM_THREADS=2 # Downloads are checksum-verified; bundled data is reused if present. # Build the graph once in the image, so sleeping/restarting needs no network. RUN python deploy.py --prepare RUN CC_STATE_DIR=/app/seed python deploy.py --build EXPOSE 7860 HEALTHCHECK --interval=30s --timeout=5s --start-period=120s \ CMD python -c "from urllib.request import urlopen; urlopen('http://127.0.0.1:7860/config', timeout=4)" ENTRYPOINT ["/usr/bin/tini", "--"] CMD ["python", "deploy.py"]