From 8c370bb218dce643f2946c7333b7eeb22211b167 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 10 Nov 2026 11:30:54 +0000 Subject: [PATCH 01/10] docs: document sidecar updates and version pairing --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 1e21e322..331cfd0f 100644 --- a/README.md +++ b/README.md @@ -792,6 +792,23 @@ docker build --target host -t code-vaults/gcb-host:dev . While the image exists locally, Docker uses it instead of pulling from the registry. Another machine or CI builds the same Dockerfile and tags, rather than pulling `:dev`. +### Updating the sidecar + +Pin a released `gcb-host` image by version or digest; do not use `:dev` or `pull_policy: never` for updates. + +```sh +docker compose pull gcb-host +docker compose up -d --no-deps --force-recreate gcb-host +``` + +Verify `gcb --version`, the socket, and `gcb doctor` after the recreate. To roll back, put the previous +version or digest back in compose and run the same pull/recreate steps. + +Use the same release line on both sides. Typed host replies and the active-audit ping need at least +`0.7.0` on the host and client; `gcb authorize --broker-container` needs `0.8.0` on the host. `gcb doctor` +is the update health check: a non-zero result should alert, not trigger an automatic restart; a failed +socket or daemon check is the restart case, while a configuration error needs an operator to fix the file. + For idsh's dev image, name the client image as a stage and copy only the gcb packages into the base: ```dockerfile From 8ad032e9dc584109edf2ecab0f1570f2d65ff894 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 10 Nov 2026 11:40:47 +0000 Subject: [PATCH 02/10] docs: correct sidecar update verification --- README.md | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 331cfd0f..d688df52 100644 --- a/README.md +++ b/README.md @@ -794,21 +794,34 @@ or CI builds the same Dockerfile and tags, rather than pulling `:dev`. ### Updating the sidecar -Pin a released `gcb-host` image by version or digest; do not use `:dev` or `pull_policy: never` for updates. +Pin a released `gcb-host` image by version or digest; do not use `:dev` or `pull_policy: never` for +updates. The generated service is named `gcb` by default (`gcb compose --name ` changes it). + +Changing the image tag alone does not change the default `npx --package gcb-host@` command. +Either render compose again, set the package spec to the same version, or change the command to use +the image's installed binary: `["gcb", "daemon", "--config", "/etc/git-cred-broker/config/broker.config.yml"]`. ```sh -docker compose pull gcb-host -docker compose up -d --no-deps --force-recreate gcb-host +docker compose pull gcb +docker compose up -d --no-deps --force-recreate gcb ``` -Verify `gcb --version`, the socket, and `gcb doctor` after the recreate. To roll back, put the previous -version or digest back in compose and run the same pull/recreate steps. +Verify the running sidecar, not just the host CLI: -Use the same release line on both sides. Typed host replies and the active-audit ping need at least -`0.7.0` on the host and client; `gcb authorize --broker-container` needs `0.8.0` on the host. `gcb doctor` -is the update health check: a non-zero result should alert, not trigger an automatic restart; a failed -socket or daemon check is the restart case, while a configuration error needs an operator to fix the file. +```sh +docker compose exec gcb npx --yes --package 'gcb-host@0.8.0' gcb --version +docker compose exec gcb npx --yes --package 'gcb-host@0.8.0' gcb doctor \ + --config /etc/git-cred-broker/config/broker.config.yml +gcb --version # in the pushing environment; must be the same release line +``` + +`gcb doctor` checks configuration and the audit path; it is not a daemon-liveness probe. Check +liveness from the pushing environment with `gcb probe --repo `: exit `0` means allowed, +`1` denied, and `3` means the broker is unreachable. Alert on a non-zero doctor result; restart only +when `probe` returns `3` or the socket is gone; a configuration error needs an operator. +Use the same release line on both sides. Typed host replies and the active-audit ping need at least +`0.7.0`; `gcb authorize --broker-container` needs host `0.8.0`. For idsh's dev image, name the client image as a stage and copy only the gcb packages into the base: ```dockerfile From a18a83325d6ed79688b129970099b2a894bfaf61 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 10 Nov 2026 11:51:53 +0000 Subject: [PATCH 03/10] docs: drop the unsupported npx update path --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d688df52..ebb38659 100644 --- a/README.md +++ b/README.md @@ -797,9 +797,19 @@ or CI builds the same Dockerfile and tags, rather than pulling `:dev`. Pin a released `gcb-host` image by version or digest; do not use `:dev` or `pull_policy: never` for updates. The generated service is named `gcb` by default (`gcb compose --name ` changes it). -Changing the image tag alone does not change the default `npx --package gcb-host@` command. -Either render compose again, set the package spec to the same version, or change the command to use -the image's installed binary: `["gcb", "daemon", "--config", "/etc/git-cred-broker/config/broker.config.yml"]`. +The released image contains the `gcb` binary and starts `gcb daemon`. If a generated compose still +uses `npx --package gcb-host@...`, replace its command with that binary; npx is not an update +mechanism: + +```yaml +command: + - gcb + - daemon + - --config + - /etc/git-cred-broker/config/broker.config.yml +``` + +Use the mounted config path from the compose command; the path above is the generated default. ```sh docker compose pull gcb @@ -809,9 +819,8 @@ docker compose up -d --no-deps --force-recreate gcb Verify the running sidecar, not just the host CLI: ```sh -docker compose exec gcb npx --yes --package 'gcb-host@0.8.0' gcb --version -docker compose exec gcb npx --yes --package 'gcb-host@0.8.0' gcb doctor \ - --config /etc/git-cred-broker/config/broker.config.yml +docker compose exec gcb gcb --version +docker compose exec gcb gcb doctor --config /etc/git-cred-broker/config/broker.config.yml gcb --version # in the pushing environment; must be the same release line ``` From b10e8da9d08950354f415ecf4b75258012df06e3 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 10 Nov 2026 11:55:37 +0000 Subject: [PATCH 04/10] docs: do not describe npx as a sidecar update path --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ebb38659..4ac28c54 100644 --- a/README.md +++ b/README.md @@ -797,9 +797,8 @@ or CI builds the same Dockerfile and tags, rather than pulling `:dev`. Pin a released `gcb-host` image by version or digest; do not use `:dev` or `pull_policy: never` for updates. The generated service is named `gcb` by default (`gcb compose --name ` changes it). -The released image contains the `gcb` binary and starts `gcb daemon`. If a generated compose still -uses `npx --package gcb-host@...`, replace its command with that binary; npx is not an update -mechanism: +The released image contains the `gcb` binary and starts `gcb daemon`. Ensure the compose command +runs that binary: ```yaml command: From e9d3d907bff872eae080441c22a6b904640226ab Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 10 Nov 2026 11:59:22 +0000 Subject: [PATCH 05/10] feat: remove the npx sidecar mode from compose --- ...26-09-30-git-credential-broker-verified.md | 2 +- .changeset/compose-host-image.md | 7 ++++ AGENTS.md | 2 +- DEVELOPMENT.md | 5 --- README.md | 21 +++++------- docker-compose.example.yml | 11 ++----- packages/host/src/commands/compose.ts | 33 +++++-------------- test/unit/commands.test.ts | 26 ++++++--------- 8 files changed, 39 insertions(+), 68 deletions(-) create mode 100644 .changeset/compose-host-image.md diff --git a/.agents/notes/verified/architecture/2026-09-30-git-credential-broker-verified.md b/.agents/notes/verified/architecture/2026-09-30-git-credential-broker-verified.md index c9c99394..0b13bdf7 100644 --- a/.agents/notes/verified/architecture/2026-09-30-git-credential-broker-verified.md +++ b/.agents/notes/verified/architecture/2026-09-30-git-credential-broker-verified.md @@ -90,7 +90,7 @@ deploy-sidecar.sh 写容器内路径)就不会有这个问题;把两者合 五个 shell 脚本已全部改成 CLI 子命令,并随包发布到 npm(`git-credential-broker`):`setup` (原 container-setup.sh)、`init`(原 host-setup.sh)、`compose`(原 deploy-sidecar.sh 的 compose 生成)、`probe`、`diagnose`。宿主不再需要 checkout 或构建 —— `compose` 产出的 sidecar -直接 `npx` 拉取已发布的包。同一个 bin 既是 git 的 credential helper(`get|store|erase`), +使用已发布 host 镜像里的 `gcb`。同一个 bin 既是 git 的 credential helper(`get|store|erase`), 也是管理 CLI。 **新增 `stage`:把"代码在哪"变成一条命令。** 原 `deploy-sidecar.sh` 会拒绝脏工作树,合并成 CLI 时我把 diff --git a/.changeset/compose-host-image.md b/.changeset/compose-host-image.md new file mode 100644 index 00000000..6afdf7de --- /dev/null +++ b/.changeset/compose-host-image.md @@ -0,0 +1,7 @@ +--- +"gcb-host": minor +--- + +`compose` now emits the released `ghcr.io/code-vaults/gcb-host:` image and runs its installed +`gcb daemon` binary. It no longer generates an `npx --package gcb-host` command or accepts `--package`. +The `--code` staged-code mode is unchanged. diff --git a/AGENTS.md b/AGENTS.md index f3a477d8..5de4c166 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -77,7 +77,7 @@ sources must stay erasable (`erasableSyntaxOnly` is on: no enums, no parameter p - **Only cover the deployment shapes this project actually supports.** The supported shapes are the installed `gcb-client` in the container, the installed `gcb-host` (or a staged commit with its production dependencies) on the host, the rendered sidecar, and a source checkout with a - `gcb` shim for development. Do not add guards, probes, commands or tests for one-off `npx` + `gcb` shim for development. Do not add guards, probes, commands or tests for one-off execution setup, direct imports of command modules, arbitrary later PATH changes, or native Windows beyond the existing refusal and its real-platform CI job. `setup` cannot know the PATH of a later git process; do not pretend a setup-time check is a diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 129809c8..ae75c9aa 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -119,11 +119,6 @@ gcb compose --dir "$DEPLOY" --socket-dir "$SOCKET_DIR" \ > "$DEPLOY/docker-compose.yml" ``` -Change only the `exec npx --yes --package … gcb` prefix to `exec gcb`, keeping `daemon --config …`: - -```sh -exec gcb daemon --config /etc/git-cred-broker/config/broker.config.yml -``` The dev image already installs the package; do **not** keep a staged `/opt/gcb` mount, or the image's code is ignored. diff --git a/README.md b/README.md index 4ac28c54..93e82bb8 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ npm install -g gcb-host `gcb-client` has no runtime dependencies. `gcb-host` depends on `yaml`; npm installs it there. Do not install both globally on the same machine: they race for the same `gcb` bin. Run `setup` from the -installed client; one-off `npx` execution is not a supported installation shape. +installed client; one-off execution is not a supported installation shape. Or run from a checkout. Node 24 strips TypeScript types, but the workspaces still need their dependencies: @@ -108,10 +108,8 @@ the compose command in [Quick start](#quick-start-sidecar): docker build --target host -t code-vaults/gcb-host:dev . ``` -The image's `CMD` starts `gcb daemon`, but `compose` still renders the registry-fetching `npx` -command by default. Keep the rendered `sh -c` wrapper (it applies `GCB_PROXY`) and change only its -final `exec npx ...` to `exec gcb daemon --config ...`; see -[DEVELOPMENT.md](DEVELOPMENT.md#use-your-build). +The image's `CMD` starts `gcb daemon`; the rendered command runs that installed binary and keeps the +`sh -c` wrapper that applies `GCB_PROXY`. See [DEVELOPMENT.md](DEVELOPMENT.md#use-your-build). Debian packages use the Aliyun mirror by default in this image; pass `--build-arg APT_MIRROR=` to build against another mirror. @@ -177,9 +175,8 @@ The exact command, flags and required values come from ## Quick start: sidecar -Docker only. Run `init` and `compose` from an installed `gcb-host`. The image is stock `node:24-slim`; -the default sidecar fetches `gcb-host` with `npx` at start, while `--code` runs a staged commit with no -registry access at boot. +Docker only. Run `init` and `compose` from an installed `gcb-host`. The default sidecar uses the +released `gcb-host` image and runs its installed `gcb daemon`; `--code` runs a staged commit instead. ```sh DEPLOY=/srv/git-cred-broker # the deployment directory @@ -229,8 +226,7 @@ guess. The runtime route is deliberately a superset: a directory bind-mounted in counts as shared, because any container that can rewrite the broker's code is as good a reason not to stage there as the agent is. -The sidecar fetches the published `gcb-host` package with `npx` at start. To pin a reviewed commit -instead, run `gcb stage --to "$DEPLOY/app"`, install its dependencies in that directory with +The sidecar runs the installed `gcb` from the released host image. To pin a reviewed commit instead, run `gcb stage --to "$DEPLOY/app"`, install its dependencies in that directory with `corepack yarn install`, and pass `--code "$DEPLOY/app"` to `compose`. Run `stage` from the repository root you intend to export, or pass `--repo `: it defaults to the current directory and exports that repository's `HEAD`, never the working tree. `stage` is export-only: it does not install @@ -268,7 +264,7 @@ gcb setup install and a dev shim) and `credential.useHttpPath` (without the latter, git sends no repository path and the broker can only authorize host-wide). The helper is resolved by the git process later, not by `setup`: that process must have `gcb` on its PATH. Run setup from the installed client, not -a one-off `npx` process. +a one-off execution. It also rewrites `git@github.com:` remotes to https **inside the container only** so the host's SSH workflow is untouched, and writes a CA bundle @@ -348,8 +344,7 @@ a sidecar it is inside the container: ```sh DEPLOY=/srv/git-cred-broker -cd "$DEPLOY" && docker compose exec gcb \ - npx --yes --package gcb-host gcb \ +cd "$DEPLOY" && docker compose exec gcb gcb \ diagnose --config /etc/git-cred-broker/config/broker.config.yml ``` diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 115b8675..98f9573a 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -16,7 +16,7 @@ services: # The usual NAS case. The image installs the package at start, so there is no checkout to copy # and nothing to build. Only this container mounts the private key; the socket directory is # the only thing shared with the DSH container. - image: node:24-slim + image: ghcr.io/code-vaults/gcb-host:0.8.0 container_name: git-cred-broker restart: unless-stopped # Must match the uid/gid of the container that will use the socket, or it is unusable. @@ -24,15 +24,12 @@ services: user: '1000:1000' read_only: true tmpfs: - # npx needs somewhere writable for its cache; /tmp is a tmpfs above. - /tmp cap_drop: - ALL security_opt: - no-new-privileges:true environment: - # npx needs somewhere writable for its cache; /tmp is a tmpfs above. - - npm_config_cache=/tmp/npm-cache # Egress: the socket needs no proxy, the broker's own calls to github.com do. - http_proxy=${http_proxy:-${HTTP_PROXY:-}} - https_proxy=${https_proxy:-${HTTPS_PROXY:-}} @@ -41,7 +38,7 @@ services: command: - sh - -c - - exec npx --yes --package 'gcb-host' gcb daemon --config /etc/git-cred-broker/config/broker.config.yml + - exec gcb daemon --config /etc/git-cred-broker/config/broker.config.yml volumes: # The configuration directory, not one file: an atomic replacement on the host must stay # visible to the container's watcher. Put broker.config.yml in ./config; the key and refresh @@ -72,9 +69,7 @@ services: # The same host directory the broker binds, or the two are not sharing a socket at all. - /srv/git-broker-socket:/run/git-broker -# Pin a released version (`npx --yes --package 'gcb-host@'`) if you would rather not -# resolve latest on every start; `compose` pins the version it was generated from. The first -# functional release is 0.0.1; 0.0.0 is an empty placeholder. +# Pin the released image tag or digest; `compose` pins the version it was generated from. # # The host-process alternative, for a host that has Node and a service manager: # diff --git a/packages/host/src/commands/compose.ts b/packages/host/src/commands/compose.ts index 216e3f52..212d402d 100644 --- a/packages/host/src/commands/compose.ts +++ b/packages/host/src/commands/compose.ts @@ -3,8 +3,8 @@ * * The broker runs in its own container with the private key mounted read-only, no published ports, * no capabilities and a read-only root filesystem; the only surface it shares with anything else is - * the socket directory. The container fetches the published package, so there is no checkout to - * copy and nothing to build on the host. + * the socket directory. The released image contains the package, so there is no checkout to copy and + * nothing to build on the host. * * The mount targets are constants from `deployment.ts`, shared with `init --mode sidecar`, so the * paths recorded in `broker.config.yml` and the paths this file mounts cannot drift apart. @@ -33,10 +33,8 @@ export interface ComposeInput { readonly socketDir: string /** `uid:gid` the sidecar runs as; must match the container that needs the socket. */ readonly user: string - /** Base image. */ + /** Base image; the released host image contains the `gcb` binary. */ readonly image: string - /** Npm spec to run, e.g. `gcb@0.0.0`. */ - readonly packageSpec: string /** Compose service and container name. */ readonly name: string /** @@ -96,14 +94,8 @@ export function renderCompose(input: ComposeInput): string { ? `# It runs the code mounted read-only from ${input.code}, which is whatever \`stage\` put there — # see the STAGED.json beside it for the commit. stage does not install dependencies or build: # run \`corepack yarn install\` in that directory first, then the source entry point runs here.` - : `# The image fetches the published package at start: -# -# npx --yes --package '${input.packageSpec}' gcb daemon -# -# To avoid depending on the registry at boot, either render this file with --code to -# run staged code from a mount, or point --image at an image of your own that already has the -# package installed, and change \`command\` to the binary in it: -# ["gcb", "daemon", "--config", "${mountedConfigPath}"]` + : `# The image contains gcb-host and the command below runs its installed \`gcb\` binary. +# To pin a reviewed commit instead, render this file with --code .` // The egress lines belong to both renders: a --code deployment is a sidecar too, and without them it // would carry no proxy variables at all, so the daemon would go direct and hang rather than refuse. @@ -117,13 +109,8 @@ export function renderCompose(input: ComposeInput): string { # Runtime override: a URL pins a proxy, an empty value goes direct, unset keeps the above. - GCB_PROXY=\${GCB_PROXY-default}` - const environment = fromCode - ? ` + const environment = ` environment:${egress}` - : ` - environment: - # npx needs somewhere writable for its cache; /tmp is a tmpfs above. - - npm_config_cache=/tmp/npm-cache${egress}` // A bind mount for a path that does not exist becomes a directory, and the broker would then read a // directory instead of a token — for every action, not only the personal ones. Emit it once `authorize` @@ -134,7 +121,7 @@ export function renderCompose(input: ComposeInput): string { '\n # for a path that does not exist would become a directory, and the broker would read that.' const start = fromCode ? `exec node --conditions=development ${CODE_DIR}/packages/host/bin/gcb.js daemon --config ${mountedConfigArg}` - : `exec npx --yes --package '${input.packageSpec}' gcb daemon --config ${mountedConfigArg}` + : `exec gcb daemon --config ${mountedConfigArg}` const command = ` - sh - -c - | @@ -217,8 +204,7 @@ Print a Docker sidecar definition for the broker (to stdout). Pair it with a con --code Run code mounted from this host directory instead of fetching the package at start (as \`stage\` exports it); nothing is fetched or built at boot --user UID the sidecar runs as (default: this user) - --image Base image (default: node:24-slim) - --package npm spec to run (default: gcb-host@) + --image Base image (default: ghcr.io/code-vaults/gcb-host:) --name Service and container name (default: gcb) -h, --help Show this help ` @@ -281,8 +267,7 @@ export function runCompose(argv: readonly string[]): number { configPath: configFile, socketDir, user, - image: args.value('image') ?? 'node:24-slim', - packageSpec: args.value('package') ?? `gcb-host@${PACKAGE_VERSION}`, + image: args.value('image') ?? `ghcr.io/code-vaults/gcb-host:${PACKAGE_VERSION}`, name: args.value('name') ?? 'gcb', code: args.value('code'), }), diff --git a/test/unit/commands.test.ts b/test/unit/commands.test.ts index 7c91017c..42a12e96 100644 --- a/test/unit/commands.test.ts +++ b/test/unit/commands.test.ts @@ -1723,8 +1723,7 @@ describe('compose', () => { dir: '/volume1/docker/git-cred-broker', socketDir: '/srv/shared/git-broker', user: '1026:100', - image: 'node:24-slim', - packageSpec: 'gcb-host@0.0.0', + image: 'ghcr.io/code-vaults/gcb-host:0.0.0', name: 'git-cred-broker', }) @@ -1818,8 +1817,7 @@ describe('compose', () => { configPath: '/srv/custom/broker.yml', socketDir: '/srv/shared/git-broker', user: '1026:100', - image: 'node:24-slim', - packageSpec: 'gcb-host@0.0.0', + image: 'ghcr.io/code-vaults/gcb-host:0.0.0', name: 'git-cred-broker', }) assert.match(custom, /\/srv\/custom:\/etc\/git-cred-broker\/config:ro/) @@ -1832,8 +1830,7 @@ describe('compose', () => { configPath: '/srv/custom/broker live.yml', socketDir: '/srv/shared/git-broker', user: '1026:100', - image: 'node:24-slim', - packageSpec: 'gcb-host@0.0.0', + image: 'ghcr.io/code-vaults/gcb-host:0.0.0', name: 'git-cred-broker', }) assert.match(custom, /--config '\/etc\/git-cred-broker\/config\/broker live\.yml'/) @@ -1842,8 +1839,7 @@ describe('compose', () => { configPath: '/srv/custom/br$ker "x".yml', socketDir: '/srv/shared/git-broker', user: '1026:100', - image: 'node:24-slim', - packageSpec: 'gcb-host@0.0.0', + image: 'ghcr.io/code-vaults/gcb-host:0.0.0', name: 'git-cred-broker', }) assert.match(dollar, /--config '\/etc\/git-cred-broker\/config\/br\$\$ker "x"\.yml'/) @@ -1863,8 +1859,7 @@ describe('compose', () => { configPath: link, socketDir: '/srv/shared/git-broker', user: '1026:100', - image: 'node:24-slim', - packageSpec: 'gcb-host@0.0.0', + image: 'ghcr.io/code-vaults/gcb-host:0.0.0', name: 'git-cred-broker', }) assert.equal( @@ -1924,8 +1919,7 @@ describe('compose', () => { dir: '/srv/broker #1', socketDir: '/srv/socket #2', user: '1026:100', - image: 'node:24-slim', - packageSpec: 'gcb-host@0.0.0', + image: 'ghcr.io/code-vaults/gcb-host:0.0.0', name: 'git-cred-broker', }) assert.equal(custom.includes('- "/srv/broker #1:/etc/git-cred-broker/config:ro"'), true) @@ -1943,8 +1937,9 @@ describe('compose', () => { assert.match(rendered, /user: "1026:100"/) }) - it('runs the daemon from the published package, not from a copied checkout', () => { - assert.match(rendered, /npx --yes --package 'gcb-host@0\.0\.0' gcb daemon/) + it('runs the installed gcb binary from the host image', () => { + assert.match(rendered, /exec gcb daemon/) + assert.equal(/npx/.test(rendered), false) assert.match(rendered, new RegExp(`--config '${SIDECAR.configPath}'`)) }) @@ -1953,8 +1948,7 @@ describe('compose', () => { dir: '/volume1/docker/git-cred-broker', socketDir: '/srv/shared/git-broker', user: '1026:100', - image: 'node:24-slim', - packageSpec: 'gcb-host@0.0.0', + image: 'ghcr.io/code-vaults/gcb-host:0.0.0', name: 'git-cred-broker', code: '/volume1/docker/git-cred-broker/app', }) From bef2275a24f4741d24c777feea2892569913dad4 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 10 Nov 2026 12:02:49 +0000 Subject: [PATCH 06/10] chore: make the compose npx removal a patch --- .changeset/compose-host-image.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/compose-host-image.md b/.changeset/compose-host-image.md index 6afdf7de..46bcac4b 100644 --- a/.changeset/compose-host-image.md +++ b/.changeset/compose-host-image.md @@ -1,5 +1,5 @@ --- -"gcb-host": minor +"gcb-host": patch --- `compose` now emits the released `ghcr.io/code-vaults/gcb-host:` image and runs its installed From c4b05e0c652290e0bde6607ad43ff4c8d00a9514 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 10 Nov 2026 12:10:56 +0000 Subject: [PATCH 07/10] chore: add Renovate config for the compose example --- .renovaterc | 7 +++++++ docker-compose.example.yml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .renovaterc diff --git a/.renovaterc b/.renovaterc new file mode 100644 index 00000000..ed84c045 --- /dev/null +++ b/.renovaterc @@ -0,0 +1,7 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["github>1stG/configs"], + "docker-compose": { + "managerFilePatterns": ["/(^|/)docker-compose[^/]*\\.ya?ml$/"] + } +} diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 98f9573a..df622ab2 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -13,7 +13,7 @@ services: git-cred-broker: - # The usual NAS case. The image installs the package at start, so there is no checkout to copy + # The usual NAS case. The released image contains gcb-host, so there is no checkout to copy # and nothing to build. Only this container mounts the private key; the socket directory is # the only thing shared with the DSH container. image: ghcr.io/code-vaults/gcb-host:0.8.0 From a8c45556cfcf1793cd125175e66eba8f73c2aaa9 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 10 Nov 2026 12:16:45 +0000 Subject: [PATCH 08/10] chore: use Renovate's default compose file matching --- .renovaterc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.renovaterc b/.renovaterc index ed84c045..58bde8cb 100644 --- a/.renovaterc +++ b/.renovaterc @@ -1,7 +1,4 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["github>1stG/configs"], - "docker-compose": { - "managerFilePatterns": ["/(^|/)docker-compose[^/]*\\.ya?ml$/"] - } + "extends": ["github>1stG/configs"] } From 1b4fb15c9a35dd4d6b96b6ed95593e4c338dfedb Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 10 Nov 2026 12:40:33 +0000 Subject: [PATCH 09/10] fix: reject --package and keep the proxy wrapper --- README.md | 15 +++------------ packages/host/src/commands/compose.ts | 3 +++ test/unit/commands.test.ts | 10 ++++++++++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 93e82bb8..25b0df45 100644 --- a/README.md +++ b/README.md @@ -792,18 +792,9 @@ or CI builds the same Dockerfile and tags, rather than pulling `:dev`. Pin a released `gcb-host` image by version or digest; do not use `:dev` or `pull_policy: never` for updates. The generated service is named `gcb` by default (`gcb compose --name ` changes it). -The released image contains the `gcb` binary and starts `gcb daemon`. Ensure the compose command -runs that binary: - -```yaml -command: - - gcb - - daemon - - --config - - /etc/git-cred-broker/config/broker.config.yml -``` - -Use the mounted config path from the compose command; the path above is the generated default. +The released image contains the `gcb` binary and starts `gcb daemon`. Keep the generated `sh -c` +wrapper: it applies `GCB_PROXY`, and its final `exec` already runs the installed binary. Do not replace +the whole `command` with a bare `gcb daemon` list. ```sh docker compose pull gcb diff --git a/packages/host/src/commands/compose.ts b/packages/host/src/commands/compose.ts index 212d402d..ae8bf44f 100644 --- a/packages/host/src/commands/compose.ts +++ b/packages/host/src/commands/compose.ts @@ -221,6 +221,9 @@ export function runCompose(argv: readonly string[]): number { say(COMPOSE_USAGE) return 0 } + if (argv.some(argument => argument === '--package' || argument.startsWith('--package='))) { + fail('--package is not supported; pin the released image with --image instead') + } const explicitConfig = args.value('config') const dirArg = args.value('dir') const configPath = path.resolve( diff --git a/test/unit/commands.test.ts b/test/unit/commands.test.ts index 42a12e96..e4ef55e8 100644 --- a/test/unit/commands.test.ts +++ b/test/unit/commands.test.ts @@ -1727,6 +1727,16 @@ describe('compose', () => { name: 'git-cred-broker', }) + it('rejects the removed --package option', () => { + const result = spawnSync( + 'node', + ['--conditions=development', 'packages/host/bin/gcb.js', 'compose', '--socket-dir', '/tmp', '--package', 'gcb-host@0.7.0'], + { cwd: path.resolve('.'), encoding: 'utf8' }, + ) + assert.equal(result.status, 1) + assert.match(result.stderr, /--package is not supported/u) + }) + it('mounts the key read-only and publishes no ports', () => { assert.match(rendered, /app\.pem:\/etc\/git-cred-broker\/app\.pem:ro/) assert.match(rendered, /volume1\/docker\/git-cred-broker:\/etc\/git-cred-broker\/config:ro/) From 2097bd7ec61ed6a4bdbcbe0408651efed1cbfe31 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 10 Nov 2026 12:57:46 +0000 Subject: [PATCH 10/10] docs: correct version pairing and sidecar update layout --- .renovaterc | 4 ++- DEVELOPMENT.md | 1 - README.md | 37 ++++++++++++++------------- packages/host/src/commands/compose.ts | 8 +++--- test/unit/commands.test.ts | 7 +++++ 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.renovaterc b/.renovaterc index 58bde8cb..bebeb9d0 100644 --- a/.renovaterc +++ b/.renovaterc @@ -1,4 +1,6 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["github>1stG/configs"] + "extends": [ + "github>1stG/configs" + ] } diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index ae75c9aa..66a41903 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -119,7 +119,6 @@ gcb compose --dir "$DEPLOY" --socket-dir "$SOCKET_DIR" \ > "$DEPLOY/docker-compose.yml" ``` - The dev image already installs the package; do **not** keep a staged `/opt/gcb` mount, or the image's code is ignored. Then recreate from the deployment directory, choosing the proxy at runtime: diff --git a/README.md b/README.md index 25b0df45..c2080cad 100644 --- a/README.md +++ b/README.md @@ -787,6 +787,24 @@ docker build --target host -t code-vaults/gcb-host:dev . While the image exists locally, Docker uses it instead of pulling from the registry. Another machine or CI builds the same Dockerfile and tags, rather than pulling `:dev`. +For idsh's dev image, name the client image as a stage and copy only the gcb packages into the base: + +```dockerfile +ARG BASE=devockr/idsh:base +ARG GCB_CLIENT_IMAGE=code-vaults/gcb-client:dev +FROM ${GCB_CLIENT_IMAGE} AS gcb-client +FROM ${BASE} + +COPY --from=gcb-client /usr/local/lib/node_modules/gcb-core /usr/local/lib/node_modules/gcb-core +COPY --from=gcb-client /usr/local/lib/node_modules/gcb-client /usr/local/lib/node_modules/gcb-client +RUN ln -s /usr/local/lib/node_modules/gcb-client/bin/gcb.js /usr/local/bin/gcb +``` + +Copy the two package directories, not all of `/usr/local/lib/node_modules`: the idsh base already has +its own `corepack` and `npm`, and a whole-directory copy would replace them. That default is for a +local build; CI and production pass a published version instead, e.g. +`--build-arg GCB_CLIENT_IMAGE=ghcr.io/code-vaults/gcb-client:`. + ### Updating the sidecar Pin a released `gcb-host` image by version or digest; do not use `:dev` or `pull_policy: never` for @@ -815,24 +833,7 @@ liveness from the pushing environment with `gcb probe --repo `: exit when `probe` returns `3` or the socket is gone; a configuration error needs an operator. Use the same release line on both sides. Typed host replies and the active-audit ping need at least -`0.7.0`; `gcb authorize --broker-container` needs host `0.8.0`. -For idsh's dev image, name the client image as a stage and copy only the gcb packages into the base: - -```dockerfile -ARG BASE=devockr/idsh:base -ARG GCB_CLIENT_IMAGE=code-vaults/gcb-client:dev -FROM ${GCB_CLIENT_IMAGE} AS gcb-client -FROM ${BASE} - -COPY --from=gcb-client /usr/local/lib/node_modules/gcb-core /usr/local/lib/node_modules/gcb-core -COPY --from=gcb-client /usr/local/lib/node_modules/gcb-client /usr/local/lib/node_modules/gcb-client -RUN ln -s /usr/local/lib/node_modules/gcb-client/bin/gcb.js /usr/local/bin/gcb -``` - -Copy the two package directories, not all of `/usr/local/lib/node_modules`: the idsh base already has -its own `corepack` and `npm`, and a whole-directory copy would replace them. That default is for a -local build; CI and production pass a published version instead, e.g. -`--build-arg GCB_CLIENT_IMAGE=ghcr.io/code-vaults/gcb-client:`. +`0.3.0`; `gcb authorize --broker-container` needs host `0.8.0`. ## App permissions by action diff --git a/packages/host/src/commands/compose.ts b/packages/host/src/commands/compose.ts index ae8bf44f..b0216a74 100644 --- a/packages/host/src/commands/compose.ts +++ b/packages/host/src/commands/compose.ts @@ -39,8 +39,8 @@ export interface ComposeInput { readonly name: string /** * Host directory holding the broker's code, as `stage` exports it. When given, the sidecar runs - * that code with the image's Node instead of fetching the package at start: no registry access at - * boot, and the commit that runs is the one you reviewed. + * that code with the image's Node instead of running the image's installed binary: no registry + * access at boot, and the commit that runs is the one you reviewed. */ readonly code?: string } @@ -201,8 +201,8 @@ Print a Docker sidecar definition for the broker (to stdout). Pair it with a con --config The sidecar's config, checked before anything is printed (default: $GIT_BROKER_CONFIG, else ./broker.config.yml) --socket-dir Host directory the pushing container already mounts - --code Run code mounted from this host directory instead of fetching the package - at start (as \`stage\` exports it); nothing is fetched or built at boot + --code Run code mounted from this host directory instead of the installed binary + (as \`stage\` exports it); nothing is fetched or built at boot --user UID the sidecar runs as (default: this user) --image Base image (default: ghcr.io/code-vaults/gcb-host:) --name Service and container name (default: gcb) diff --git a/test/unit/commands.test.ts b/test/unit/commands.test.ts index e4ef55e8..87d63cb5 100644 --- a/test/unit/commands.test.ts +++ b/test/unit/commands.test.ts @@ -27,6 +27,7 @@ import { helpRequested, } from '../../packages/core/src/support.ts' import type { BrokerConfig, GithubAppHostConfig } from '../../packages/core/src/types.ts' +import { PACKAGE_VERSION } from '../../packages/core/src/version.ts' import { renderCompose, runCompose } from '../../packages/host/src/commands/compose.ts' import { runDiagnose } from '../../packages/host/src/commands/diagnose.ts' import { @@ -1810,6 +1811,12 @@ describe('compose', () => { }) as typeof process.stdout.write try { assert.equal(runCompose(['--socket-dir', '/srv/sock']), 0) + assert.match( + output, + new RegExp( + `image: ghcr[.]io/code-vaults/gcb-host:${PACKAGE_VERSION.replaceAll('.', '[.]')}`, + ), + ) } finally { process.stdout.write = original if (previous === undefined) {