From c01eb3b99f598c5b8ec004407550258ce639a17b Mon Sep 17 00:00:00 2001 From: Danyang Chen Date: Wed, 2 Dec 2026 12:07:36 +0800 Subject: [PATCH] runtime: require DSH_VERSION as an explicit build-arg Both stages of runtime/flybot-image/Dockerfile carried ARG DSH_VERSION=0.2.2-rc.1, so a bare docker build without --build-arg installed a release that contradicts runtime/ds-bot-upstream.pin.json (0.2.2-rc.5) and said nothing about it. Dropping the default alone would have been worse: npm resolves an empty "@deepseek-ai/dsh@" to "*". Each stage now declares the arg without a default and fails fast on an empty value before the first install, a recipe test guards the default, the guard order and the documented build paths, and COMPOSE_MANAGER.md points operators at the pin. Related #3489 --- docs/COMPOSE_MANAGER.md | 6 +++-- runtime/flybot-image/Dockerfile | 12 +++++++-- runtime/flybot-image/test/recipe.test.js | 33 ++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/docs/COMPOSE_MANAGER.md b/docs/COMPOSE_MANAGER.md index 358783b2f..50ec46030 100644 --- a/docs/COMPOSE_MANAGER.md +++ b/docs/COMPOSE_MANAGER.md @@ -21,8 +21,10 @@ The manager runs the isolated DS-Bot containers and reports verified state back Image contract: UID/GID1000, `/data` writable by that UID (image directory ownership is copied to a new named volume), read-only rootfs except `/data` and tmpfs `/tmp`, TCP8080 if optionally published, and a functioning Docker - HEALTHCHECK. Operators can build that image from `runtime/flybot-image/` and - pass the resulting `name@sha256:…` to `--compose-image`. See the + HEALTHCHECK. Operators can build that image from `runtime/flybot-image/` with + `--build-arg DSH_VERSION=` (the recipe + has no baked default and refuses an empty one), then pass the resulting + `name@sha256:…` to `--compose-image`. See the [runtime image workflow](../.github/workflows/flybot-runtime-image.yml) for the build inputs and [licensing notes](LICENSING.md) for redistribution status. A passing Docker healthcheck is required before the manager publishes the container route. Supply diff --git a/runtime/flybot-image/Dockerfile b/runtime/flybot-image/Dockerfile index cc5041b26..e501f5d3b 100644 --- a/runtime/flybot-image/Dockerfile +++ b/runtime/flybot-image/Dockerfile @@ -24,7 +24,13 @@ COPY flybot-workspace-web/PAGES_NOT_BUNDLED.md /PAGES_NOT_BUNDLED.md FROM ${NODE_IMAGE} AS build ARG NPM_REGISTRY=https://registry.npmjs.org/ -ARG DSH_VERSION=0.2.2-rc.1 +# DSH_VERSION is deliberately default-less. CI, docs/GETTING_STARTED.md and the +# deploy build all pass it from runtime/ds-bot-upstream.pin.json ("dsh"), so a +# bare build without the build-arg must fail here instead of quietly installing +# whatever default the recipe happened to carry. +ARG DSH_VERSION + +RUN test -n "$DSH_VERSION" || { echo "DSH_VERSION build-arg is required: pass --build-arg DSH_VERSION=" >&2; exit 1; } RUN apt-get update \ && apt-get install -y --no-install-recommends python3 make g++ \ @@ -40,7 +46,9 @@ RUN apt-get update \ FROM ${NODE_IMAGE} ARG NPM_REGISTRY=https://registry.npmjs.org/ -ARG DSH_VERSION=0.2.2-rc.1 +ARG DSH_VERSION + +RUN test -n "$DSH_VERSION" || { echo "DSH_VERSION build-arg is required: pass --build-arg DSH_VERSION=" >&2; exit 1; } RUN apt-get update \ && apt-get install -y --no-install-recommends \ diff --git a/runtime/flybot-image/test/recipe.test.js b/runtime/flybot-image/test/recipe.test.js index 15016b423..afc905961 100644 --- a/runtime/flybot-image/test/recipe.test.js +++ b/runtime/flybot-image/test/recipe.test.js @@ -45,6 +45,39 @@ test('image matches the compose manager contract (UID 1000, port 8080, healthche assert.match(engine, /'target': '\/data'/) }) +test('the recipe takes DSH_VERSION from the build-arg and never bakes a default', () => { + const docker = read('Dockerfile') + const pin = JSON.parse(readFileSync(join(repo, 'runtime', 'ds-bot-upstream.pin.json'), 'utf8')) + assert.match(pin.dsh, /^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z]+)*$/, 'the pin must name a concrete DSH version') + + // A default here is how 0.2.2-rc.1 outlived the pin: a bare `docker build` + // installed the stale release without failing. Fail fast instead. + assert.doesNotMatch(docker, /^\s*ARG DSH_VERSION=/m) + let guarded = 0 + for (const stage of docker.split(/^FROM /m).slice(1)) { + const lines = stage.split('\n') + const arg = lines.findIndex((line) => /^\s*ARG DSH_VERSION\s*$/.test(line)) + const guard = lines.findIndex((line) => /test -n "\$DSH_VERSION"/.test(line)) + const use = lines.findIndex((line, index) => index !== guard && /\$\{?DSH_VERSION\}?/.test(line)) + if (arg === -1) { + assert.equal(use, -1, 'a stage that installs DSH packages must declare DSH_VERSION as a required build-arg') + continue + } + assert.ok(guard > arg, 'each stage must reject an empty DSH_VERSION') + assert.ok(use === -1 || guard < use, 'the DSH_VERSION check must run before the version is first used') + guarded += 1 + } + assert.equal(guarded, 2, 'the build stage and the final stage both install DSH packages') + + // Every documented build path reads the version from the pin, so a literal + // cannot drift away from it. + for (const rel of ['.github/workflows/flybot-runtime-image.yml', 'docs/GETTING_STARTED.md', 'runtime/flybot-image/README.md']) { + const text = readFileSync(join(repo, rel), 'utf8') + assert.doesNotMatch(text, /DSH_VERSION=["']?[0-9][^"'\s$]*/, `${rel} must not pass a literal DSH_VERSION`) + assert.match(text, /ds-bot-upstream\.pin\.json|steps\.pin\.outputs\.dsh/, `${rel} must read DSH_VERSION from the pin`) + } +}) + test('the shell health probe accepts a ready DSH listener and fails on an unavailable service', async (t) => { let status = 401 const server = createServer((_req, res) => res.writeHead(status).end())