services: server: build: context: . # Enable BuildKit for better caching cache_from: - python:3.9 ports: # Bind to loopback only by default: this service has no authentication (see README → # "Deployment & network"). Change to "7860:7860" (all interfaces) or attach it to an # internal Docker network only after you have placed it behind your own trust boundary. - 127.0.0.1:7860:7860 environment: # Local inference service: models are pre-cached in the python-cache volume, so load from # cache and never revalidate against huggingface.co at runtime (avoids cold-start hangs when # the network to HF is slow/unavailable). Remove/set to 0 only when adding a new model. HF_HUB_OFFLINE: "1" TRANSFORMERS_OFFLINE: "1" # Namespaces whose models may run their own Python at load time (trust_remote_code). # Everything else still loads — just with remote code disabled, which covers every # architecture transformers supports natively. Add an org only when its models genuinely # need custom code; each entry is a standing grant to everyone that org ever adds. # On the Hugging Face Space this is set as a Space Variable instead of here. TRUSTED_CODE_ORGS: "nomic-ai,pimcore" # How many loaded models stay resident (least-recently-used evicted first). Counts models, # not bytes — lower it when serving large vision models. Also a Space Variable on HF. MAX_CACHED_MODELS: "3" develop: watch: # Only rebuild on requirements.txt changes, sync code changes otherwise - action: rebuild path: ./requirements.txt - action: sync path: ./src target: /home/user/app/src - action: sync path: ./README.md target: /home/user/app/README.md volumes: - python-cache:/home/user/.cache # Cache pip packages - pip-cache:/home/user/.cache/pip volumes: python-cache: pip-cache: