Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

fix: retain the Docker profile plugin archive

EventHorizonXT20deeb696de8
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 33f01026..1ebbefc0 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -20,9 +20,10 @@ COPY ds-bot/ /src/ds-bot/
# ds-bot has no build step at install (client.js is committed), so pack it as-is
# and let `dsh plugin add` set up the web profile from dsh's own template.
RUN cd /src/ds-bot \
- && npm pack --pack-destination /tmp \
- && mv /tmp/ds-bot-*.tgz /tmp/ds-bot.tgz \
- && DSH_HOME=/opt/dsh-template dsh plugin --profile web add /tmp/ds-bot.tgz
+ && mkdir -p /opt/ds-bot \
+ && npm pack --pack-destination /opt/ds-bot \
+ && mv /opt/ds-bot/ds-bot-*.tgz /opt/ds-bot/ds-bot.tgz \
+ && DSH_HOME=/opt/dsh-template dsh plugin --profile web add /opt/ds-bot/ds-bot.tgz
FROM node:24-bookworm-slim
@@ -36,6 +37,9 @@ RUN apt-get update \
COPY --from=build /usr/local/ /usr/local/
COPY --from=build /opt/dsh-template /opt/dsh-template
+COPY --from=build /opt/ds-bot/ds-bot.tgz /opt/ds-bot/ds-bot.tgz
+# Persisted profiles from earlier images still refer to the old archive path.
+RUN ln -s /opt/ds-bot/ds-bot.tgz /tmp/ds-bot.tgz
COPY --chmod=0755 docker/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY docker/docker.patch.yml /opt/ds-bot/docker.patch.yml
diff --git a/docker/README.md b/docker/README.md
index 835362e2..081f22ec 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -176,8 +176,12 @@ docker compose up -d
```
A rebuild changes the image and the DSH it contains. An existing persisted
-profile is reused, and the entrypoint does not manage plugin upgrades. The
-image is built and tested with dsh `0.2.0-rc.2`, the version
+profile is reused, and the entrypoint does not manage plugin upgrades.
+The packed plugin stays at `/opt/ds-bot/ds-bot.tgz` for later dependency
+installs. `/tmp/ds-bot.tgz` links to it for profiles created by older images.
+A manual dependency install can therefore pick up the plugin bundled in the
+current image; restarting alone does not update the persisted profile.
+The image is built and tested with dsh `0.2.0-rc.2`, the version
DS Bot is verified with; a `DSH_VERSION` build arg exists, but other releases
are untested and newer ones change how the server binds.
@@ -238,7 +242,9 @@ After building the image, run `node docker/test.mjs ds-bot:local` from the
repository root. The test uses isolated, network-disabled containers and
temporary Docker volumes, with no host directory mounts or model calls. It
checks entrypoint permissions, first start, UID/GID changes, restored files,
-workspace ownership and web startup. All test containers and volumes are
-removed when it finishes.
+workspace ownership and the authenticated DS Bot API. It also checks that the
+runtime user can read and repack the profile's plugin archive offline, and
+that legacy archive references work without rewriting the persisted profile.
+All test containers and volumes are removed when it finishes.
CI builds the image from the Linux checkout and runs this test as part of the
required Test result check.
diff --git a/docker/test.mjs b/docker/test.mjs
index c905c0f7..0d3e6b13 100644
--- a/docker/test.mjs
+++ b/docker/test.mjs
@@ -43,6 +43,30 @@ function startHelp(uid, gid) {
run(['-e', `PUID=${uid}`, '-e', `PGID=${gid}`, image, '--help'])
}
+function checkPluginArchive(uid = 1000, gid = 1000) {
+ shell(`
+ gosu ${uid}:${gid} node --input-type=module <<'JS'
+ import assert from 'node:assert/strict'
+ import { spawnSync } from 'node:child_process'
+ import { accessSync, constants, mkdtempSync, readFileSync, rmSync } from 'node:fs'
+ import { fileURLToPath } from 'node:url'
+ const profile = JSON.parse(readFileSync('/data/profiles/web/package.json', 'utf8'))
+ const archive = profile.dependencies['ds-bot']
+ assert.ok(archive.startsWith('file:/'), 'the profile must use a local plugin archive')
+ accessSync(fileURLToPath(archive), constants.R_OK)
+ const dir = mkdtempSync('/tmp/ds-bot-pack-')
+ try {
+ const result = spawnSync('npm', ['pack', archive, '--offline', '--ignore-scripts', '--pack-destination', dir], {
+ encoding: 'utf8', env: { ...process.env, npm_config_cache: dir + '/cache' },
+ })
+ assert.equal(result.status, 0, result.stderr)
+ } finally {
+ rmSync(dir, { recursive: true, force: true })
+ }
+JS
+ `)
+}
+
function checkDataOwner(uid, gid) {
shell(`
test -z "$(find -P /data -xdev \\( ! -uid ${uid} -o ! -gid ${gid} \\) -print -quit)"
@@ -65,6 +89,8 @@ try {
/bin/sh -n /usr/local/bin/entrypoint.sh
`)
startHelp(1000, 1000)
+ checkPluginArchive()
+ console.log('PASS: the runtime user can read the profile plugin archive')
shell(`
test "$(stat -c %u:%g /data/profiles/web/package.json)" = 1000:1000
printf preserved > /data/review-state.txt
@@ -78,7 +104,23 @@ try {
`)
console.log('PASS: executable entrypoint and first start')
+ shell(`
+ node --input-type=module <<'JS'
+ import { readFileSync, writeFileSync } from 'node:fs'
+ const dir = '/data/profiles/web/'
+ const profile = JSON.parse(readFileSync(dir + 'package.json', 'utf8'))
+ const archive = profile.dependencies['ds-bot']
+ for (const file of ['package.json', 'pnpm-lock.yaml']) {
+ const path = dir + file
+ writeFileSync(path, readFileSync(path, 'utf8').replaceAll(archive, 'file:/tmp/ds-bot.tgz'))
+ }
+JS
+ sha256sum /data/profiles/web/package.json /data/profiles/web/pnpm-lock.yaml > /data/profile-before.sha256
+ `)
startHelp(1234, 1234)
+ shell('sha256sum --check /data/profile-before.sha256')
+ checkPluginArchive(1234, 1234)
+ console.log('PASS: legacy archive references stay usable without rewriting the persisted profile')
checkDataOwner(1234, 1234)
console.log('PASS: UID/GID migration preserves data and workspace link targets')
@@ -115,6 +157,24 @@ try {
await setTimeout(300)
}
assert.ok(ready, 'web server must answer HTTP after ownership migration')
+ const logs = docker(['logs', server])
+ const loginUrl = (logs.stdout + logs.stderr).match(/http:\/\/127\.0\.0\.1:3080\/\?token=[^\s]+/)?.[0]
+ assert.ok(loginUrl, 'web server must provide a login URL')
+ docker(['exec', server, 'node', '--input-type=module', '-e', `
+ import assert from 'node:assert/strict'
+ const login = await fetch(process.argv[1], { redirect: 'manual' })
+ const cookie = login.headers.getSetCookie().map(value => value.split(';')[0]).join('; ')
+ assert.ok(cookie, 'login must return a cookie')
+ const response = await fetch('http://127.0.0.1:3080/api/bot', {
+ method: 'POST',
+ headers: { 'content-type': 'application/json', cookie },
+ body: JSON.stringify({ endpoint: 'state', payload: {} }),
+ })
+ assert.ok(response.ok, 'the Bot API must answer')
+ const result = await response.json()
+ assert.ok(result.ok, result.error?.message)
+ assert.ok(Array.isArray(result.value.bots), 'the DS Bot plugin must load')
+ `, loginUrl])
const processOwner = docker(['exec', server, 'stat', '-c', '%u:%g', '/proc/1']).stdout.trim()
assert.equal(processOwner, '1234:1235', 'web process must run under the new identity')
const identity = docker(['exec', server, 'gosu', 'node', 'id']).stdout
@@ -124,7 +184,7 @@ try {
test "$(cat /data/restored/private.txt)" = restored
test -w /data/profiles/web/package.json
`])
- console.log('PASS: web startup and private data access under the new identity')
+ console.log('PASS: web startup, DS Bot API and private data access under the new identity')
} finally {
for (const container of containers) {
docker(['rm', '--force', container], { allowFailure: true })