FROM python:3.11-slim-bookworm ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ HF_HOME=/home/user/.cache/huggingface \ HF_HUB_DISABLE_TELEMETRY=1 \ QWEN_DEVICE=cpu COPY pyproject.toml /tmp/pyproject.toml RUN python -c 'import subprocess, sys, tomllib; deps = tomllib.load(open("/tmp/pyproject.toml", "rb"))["project"]["dependencies"]; torch = next(dep for dep in deps if dep.startswith("torch==")); subprocess.check_call([sys.executable, "-m", "pip", "install", "--no-cache-dir", "--index-url", "https://download.pytorch.org/whl/cpu", torch]); subprocess.check_call([sys.executable, "-m", "pip", "install", "--no-cache-dir", *deps])' RUN useradd --create-home --uid 1000 user WORKDIR /app COPY --chown=user:user runtime.py server.py preload_models.py ./ COPY --chown=user:user static ./static USER user # Cache only the pinned inference files, excluding training checkpoints. RUN python preload_models.py ENV HF_HUB_OFFLINE=1 EXPOSE 7860 CMD ["python", "server.py", "--host", "0.0.0.0", "--port", "7860"]