Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/COMPOSE_MANAGER.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<dsh in runtime/ds-bot-upstream.pin.json>` (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
Expand Down
12 changes: 10 additions & 2 deletions runtime/flybot-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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=<dsh from runtime/ds-bot-upstream.pin.json>" >&2; exit 1; }

RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 make g++ \
Expand All @@ -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=<dsh from runtime/ds-bot-upstream.pin.json>" >&2; exit 1; }

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand Down
33 changes: 33 additions & 0 deletions runtime/flybot-image/test/recipe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Loading