Skip to content

Commit a3ac62e

Browse files
OriNachumclaude
andcommitted
Address Qodo review: harden compose (trust-remote-code, env_file, HOME)
- Security: drop --trust-remote-code (Qwen3-32B-NVFP4 loads without it; the flag would let model-repo code run in-container alongside HF_TOKEN + the cache mount). Documented the swap caveat in README. - Reliability: env_file -> { path: .env, required: false } so a fresh checkout without a .env still runs (only HF_TOKEN needs it). - Reliability: HF cache mount now ${HF_CACHE:-${HOME:-/root}/.cache/huggingface} so it never collapses to /.cache/huggingface when HOME is unset; HF_CACHE documented in .env.example. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3611229 commit a3ac62e

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ VLLM_MAX_MODEL_LEN=32768
2020
# Fraction of the 128 GB unified memory vLLM may reserve. Lower leaves headroom
2121
# for the OS and other mesh agents; raise toward 0.85 on a dedicated box.
2222
VLLM_GPU_MEM_UTIL=0.6
23+
24+
# Host path for the HuggingFace weight cache. Defaults to ~/.cache/huggingface
25+
# (or /root/.cache/huggingface if $HOME is unset). Set to reuse an existing cache
26+
# or to pin a specific disk.
27+
HF_CACHE=

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,14 @@ curl -fsS http://localhost:8000/health
5252
curl -s http://localhost:8000/v1/models # lists nvidia/Qwen3-32B-NVFP4
5353
```
5454

55-
Tunables live in `.env` (`VLLM_MODEL`, `VLLM_GPU_MEM_UTIL`, `VLLM_MAX_MODEL_LEN`, …).
56-
`VLLM_SERVED_NAME` must match the part after `vllm-local/` in `culture.yaml`.
57-
If vLLM rejects the `nvidia/` ModelOpt checkpoint, set `VLLM_MODEL` to the
58-
vLLM-native `RedHatAI/Qwen3-32B-NVFP4` and drop `--quantization` from the
59-
compose `command`.
55+
Tunables live in `.env` (`VLLM_MODEL`, `VLLM_GPU_MEM_UTIL`, `VLLM_MAX_MODEL_LEN`,
56+
`HF_CACHE`, …). `VLLM_SERVED_NAME` must match the part after `vllm-local/` in
57+
`culture.yaml`. The `.env` file is optional — without it the compose defaults
58+
apply and only gated model downloads (which need `HF_TOKEN`) are blocked.
59+
60+
The compose `command` intentionally omits `--trust-remote-code`: Qwen3-32B-NVFP4
61+
loads without it, and enabling it would let a model repo's custom code run
62+
in-container alongside `HF_TOKEN` and the mounted cache. Add it back only for a
63+
model whose repo ships custom modeling code. If vLLM rejects the `nvidia/`
64+
ModelOpt checkpoint, set `VLLM_MODEL` to the vLLM-native `RedHatAI/Qwen3-32B-NVFP4`
65+
and drop `--quantization` from the compose `command`.

docker-compose.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,18 @@ services:
2727
memlock: { soft: -1, hard: -1 }
2828
stack: { soft: 67108864, hard: 67108864 }
2929
env_file:
30-
- .env # HF_TOKEN lives here (gitignored)
30+
# Optional — only HF_TOKEN (for gated repos) really needs it. required:false
31+
# keeps `docker compose up` working on a fresh checkout with no .env present.
32+
- path: .env
33+
required: false
3134
environment:
3235
- HF_HOME=/root/.cache/huggingface
3336
- TOKENIZERS_PARALLELISM=false
3437
volumes:
35-
# Persist downloaded weights across container restarts.
36-
- ${HOME}/.cache/huggingface:/root/.cache/huggingface
38+
# Persist downloaded weights across restarts. HF_CACHE overrides the host
39+
# path; otherwise ~/.cache/huggingface, with /root as the fallback if HOME
40+
# is unset (so the mount never collapses to /.cache/huggingface).
41+
- ${HF_CACHE:-${HOME:-/root}/.cache/huggingface}:/root/.cache/huggingface
3742
ports:
3843
- "${VLLM_PORT:-8000}:8000"
3944
command:
@@ -49,7 +54,9 @@ services:
4954
- --gpu-memory-utilization=${VLLM_GPU_MEM_UTIL:-0.6}
5055
- --reasoning-parser=qwen3 # expose the <think> trace as reasoning_content (drop on older vLLM)
5156
- --enable-prefix-caching
52-
- --trust-remote-code
57+
# NOTE: --trust-remote-code is intentionally omitted. Qwen3-32B-NVFP4 loads
58+
# without it; add it back only for a model whose repo ships custom modeling
59+
# code (it lets that code run in-container alongside HF_TOKEN + the cache mount).
5360
healthcheck:
5461
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
5562
interval: 30s

0 commit comments

Comments
 (0)