From 6b375ad68d01bda68c684f4ac80449caec6ce6b6 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:55:45 +0000 Subject: [PATCH 1/3] feat(cli): Publish the CLI Docker image as getsentry/sentry-cli Build a multi-arch (amd64, arm64) image from the standalone Linux binaries on debian:bookworm-slim, push it to ghcr.io/getsentry/toolkit/sentry-cli tagged with the commit, and copy the release commit's image to Docker Hub getsentry/sentry-cli (version and latest) with Craft docker targets. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com> --- .craft.yml | 12 +++ .github/workflows/cli-build.yml | 51 ++++++++++++ .../src/content/docs/getting-started.mdx | 31 +++++++ .../src/content/docs/migrating-from-v3.md | 18 ++++ docs/cli/README.md | 5 +- package.json | 2 +- packages/cli/.dockerignore | 3 + packages/cli/Dockerfile | 28 +++++++ scripts/cli-docker-smoke-test.mjs | 78 ++++++++++++++++++ scripts/cli-docker-smoke-test.test.mjs | 82 +++++++++++++++++++ 10 files changed, 307 insertions(+), 3 deletions(-) create mode 100644 packages/cli/.dockerignore create mode 100644 packages/cli/Dockerfile create mode 100644 scripts/cli-docker-smoke-test.mjs create mode 100644 scripts/cli-docker-smoke-test.test.mjs diff --git a/.craft.yml b/.craft.yml index 2cda5cb1a1..597f27e741 100644 --- a/.craft.yml +++ b/.craft.yml @@ -133,6 +133,18 @@ workspaces: assert_match version.to_s, shell_output("#{bin}/sentry --version").chomp end end + # The Docker image: cli-build.yml pushes it to GHCR, tagged with the + # release commit, and these copy it to Docker Hub. + - name: docker + id: Docker Hub (release) + source: ghcr.io/getsentry/toolkit/sentry-cli + target: getsentry/sentry-cli + - name: docker + id: Docker Hub (latest) + source: ghcr.io/getsentry/toolkit/sentry-cli + target: + image: getsentry/sentry-cli + format: "{{{image}}}:latest" # No preReleaseCommand: Craft bumps package.json through the npm target. packages/logger: changelog: diff --git a/.github/workflows/cli-build.yml b/.github/workflows/cli-build.yml index b7a50aa042..6f5f978388 100644 --- a/.github/workflows/cli-build.yml +++ b/.github/workflows/cli-build.yml @@ -257,6 +257,57 @@ jobs: ' <<< "$manifest" > /dev/null done + # Pushes the multi-arch CLI image, tagged with the commit. At release, the + # Craft docker targets copy the release commit's image to Docker Hub. + build-docker: + name: Build Docker Image + needs: build-binary + runs-on: ubuntu-latest + timeout-minutes: 20 + permissions: + contents: read + packages: write + env: + IMAGE: ghcr.io/getsentry/toolkit/sentry-cli:${{ github.sha }} + PLATFORMS: linux/amd64,linux/arm64 + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + persist-credentials: false + - name: Download Linux x64 binary + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 + with: + name: sentry-linux-x64 + path: packages/cli/dist-bin + - name: Download Linux arm64 binary + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 + with: + name: sentry-linux-arm64 + path: packages/cli/dist-bin + # Node calls the architecture x64; Docker's TARGETARCH calls it amd64. + - name: Rename the x64 binary for Docker + run: mv packages/cli/dist-bin/sentry-linux-x64 packages/cli/dist-bin/sentry-linux-amd64 + - name: Login to GHCR + uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + # The arm64 image runs apt-get at build time and the smoke test runs it. + - name: Set up QEMU + uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + - name: Build and push + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 + with: + context: packages/cli + platforms: ${{ env.PLATFORMS }} + push: true + tags: ${{ env.IMAGE }} + - name: Smoke test + run: node scripts/cli-docker-smoke-test.mjs "$IMAGE" "$PLATFORMS" + build-npm: name: Build npm Package runs-on: ubuntu-latest diff --git a/apps/cli-docs/src/content/docs/getting-started.mdx b/apps/cli-docs/src/content/docs/getting-started.mdx index 2dfa943e9f..a09e3d24f8 100644 --- a/apps/cli-docs/src/content/docs/getting-started.mdx +++ b/apps/cli-docs/src/content/docs/getting-started.mdx @@ -150,6 +150,37 @@ Homebrew installs shell completions but can't install agent skills into your hom sentry cli setup --no-modify-path --no-completions ``` +## Docker + +The [`getsentry/sentry-cli`](https://hub.docker.com/r/getsentry/sentry-cli) +image runs the CLI on amd64 and arm64 Linux. Its entrypoint is `sentry` and its +working directory is `/work`, so mount your project there and pass a token: + +```bash +docker run --rm -v "$PWD:/work" -e SENTRY_AUTH_TOKEN getsentry/sentry-cli sourcemap upload ./dist +``` + +Each release is tagged with its version, and `latest` follows the newest +release. Pin a version tag in CI. The image doesn't check for updates; pull a +newer tag to upgrade. + +The image includes `git`, so commands such as `release set-commits --auto` and +`release propose-version` read the mounted checkout. Credentials and caches are +not kept between runs, so use `SENTRY_AUTH_TOKEN` rather than `sentry auth +login`. + +CI systems that run their own script in the image, such as GitLab CI, need +the entrypoint cleared. `sentry` is on the `PATH`: + +```yaml +upload-sourcemaps: + image: + name: getsentry/sentry-cli + entrypoint: [""] + script: + - sentry sourcemap upload ./dist +``` + ## Package Managers Install globally with your preferred package manager (the npm packages require **Node.js 20+**; on **22.15+** the built-in `node:sqlite` is used, on 20–22.14 a bundled WASM fallback is used transparently): diff --git a/apps/cli-docs/src/content/docs/migrating-from-v3.md b/apps/cli-docs/src/content/docs/migrating-from-v3.md index 83ff0121a8..61818a8484 100644 --- a/apps/cli-docs/src/content/docs/migrating-from-v3.md +++ b/apps/cli-docs/src/content/docs/migrating-from-v3.md @@ -62,6 +62,24 @@ sentry --version sentry auth status ``` +### Docker + +The v4 image keeps the `getsentry/sentry-cli` name and the `/work` working +directory, so `docker run --rm -v "$PWD:/work" getsentry/sentry-cli ` +keeps working once you update the [command names](#command-changes). v3 +releases stay available under their version tags. What changed: + +- The entrypoint runs `sentry` directly. The v3 entrypoint dropped a leading + `sentry-cli` argument and ran `sh` when asked; v4 passes every argument to + `sentry`. Use `--entrypoint sh` for a shell. +- The binary is `/usr/local/bin/sentry`. There is no `sentry-cli` on the + `PATH`, so scripts that clear the entrypoint, such as GitLab CI jobs, call + `sentry`. +- The base image is Debian (`debian:bookworm-slim`) instead of Alpine, and it + includes `git`. + +See [Docker](../getting-started/#docker) for usage. + ## The `sentry-cli` → `sentry` rename If you only ever call the top-level binary, the simplest bridge is a plain diff --git a/docs/cli/README.md b/docs/cli/README.md index b00096715c..602d6afd43 100644 --- a/docs/cli/README.md +++ b/docs/cli/README.md @@ -14,8 +14,9 @@ CLI releases build it from that workspace. Start here for repository guides: [command conventions](../../packages/cli/CONTRIBUTING.md) — implementation details and command design. - [CLI build workflow](../../.github/workflows/cli-build.yml) and - [release configuration](../../.craft.yml) — binaries, npm packaging, and - release-gated website artifacts. + [release configuration](../../.craft.yml) — binaries, npm packaging, the + [Docker image](../../packages/cli/Dockerfile), and release-gated website + artifacts. - [Website packaging](../../apps/cli-docs/vercel/build-output.mjs) — the Vercel routes for `/install`, and the `/install/` function that serves the install script with `SENTRY_HANDOFF` set. diff --git a/package.json b/package.json index b8bad5a16f..ac7311021c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "scripts": { "docs:check": "node scripts/check-doc-links.mjs", - "test:ci-projects": "node --test scripts/ci-projects.test.mjs scripts/check-workspace-deps.test.mjs scripts/cli-nightly-version.test.mjs scripts/cli-nightly-watchdog.test.mjs scripts/platform-setup-pr.test.mjs scripts/codemod-version-changed.test.mjs scripts/cloudflare-deployment.test.mjs scripts/deploy-workflow.test.mjs scripts/migrate-cloudflare-token.test.mjs scripts/oxc-config.test.mjs scripts/cli-lint-rules.test.mjs scripts/workflow-policy.test.mjs scripts/tsconfig-policy.test.mjs", + "test:ci-projects": "node --test scripts/ci-projects.test.mjs scripts/check-workspace-deps.test.mjs scripts/cli-docker-smoke-test.test.mjs scripts/cli-nightly-version.test.mjs scripts/cli-nightly-watchdog.test.mjs scripts/platform-setup-pr.test.mjs scripts/codemod-version-changed.test.mjs scripts/cloudflare-deployment.test.mjs scripts/deploy-workflow.test.mjs scripts/migrate-cloudflare-token.test.mjs scripts/oxc-config.test.mjs scripts/cli-lint-rules.test.mjs scripts/workflow-policy.test.mjs scripts/tsconfig-policy.test.mjs", "dev": "pnpm --filter '@sentry/mcp-cloudflare...' --if-present run build && dotenv -e .env -e .env.local -- pnpm --parallel --filter @sentry/mcp-cloudflare --filter @sentry/mcp-core --filter @sentry/mcp-server-mocks --if-present run dev", "dev:stdio": "pnpm --filter '@sentry/mcp-core...' --if-present run build 1>&2 && dotenv -e .env -e .env.local -- pnpm --silent --dir packages/cli run cli mcp", "build": "dotenv -e .env -e .env.local -- pnpm -r --filter '!sentry' --filter '!sentry-cli-docs' --if-present run build", diff --git a/packages/cli/.dockerignore b/packages/cli/.dockerignore new file mode 100644 index 0000000000..96bfae3737 --- /dev/null +++ b/packages/cli/.dockerignore @@ -0,0 +1,3 @@ +** +!dist-bin/sentry-linux-amd64 +!dist-bin/sentry-linux-arm64 diff --git a/packages/cli/Dockerfile b/packages/cli/Dockerfile new file mode 100644 index 0000000000..3df1a8b59a --- /dev/null +++ b/packages/cli/Dockerfile @@ -0,0 +1,28 @@ +# The getsentry/sentry-cli image: the standalone Linux binary on a slim +# Debian base. cli-build.yml builds it from this directory after copying in +# dist-bin/sentry-linux-amd64 and dist-bin/sentry-linux-arm64 (the +# `script/build.ts` outputs, renamed from x64 to Docker's amd64). +FROM debian:bookworm-slim + +LABEL org.opencontainers.image.source="https://github.com/getsentry/toolkit" \ + org.opencontainers.image.description="Sentry CLI" \ + org.opencontainers.image.licenses="FSL-1.1-Apache-2.0" + +# The Node runtime in the binary links libatomic, which slim images leave out. +# `release set-commits --auto`, `release propose-version`, and +# `code-mappings upload` read the mounted checkout with git. A checkout mounted +# from the host belongs to another user, so git must trust every directory. +RUN apt-get update \ + && apt-get install -y --no-install-recommends git libatomic1 \ + && rm -rf /var/lib/apt/lists/* \ + && git config --system --add safe.directory '*' + +ARG TARGETARCH +COPY --chmod=555 dist-bin/sentry-linux-$TARGETARCH /usr/local/bin/sentry + +# A container can't upgrade its own image; pull a newer tag instead. +ENV SENTRY_CLI_NO_UPDATE_CHECK=1 + +# Same as the v3 image: mount the project at /work. +WORKDIR /work +ENTRYPOINT ["/usr/local/bin/sentry"] diff --git a/scripts/cli-docker-smoke-test.mjs b/scripts/cli-docker-smoke-test.mjs new file mode 100644 index 0000000000..0b1eb8450d --- /dev/null +++ b/scripts/cli-docker-smoke-test.mjs @@ -0,0 +1,78 @@ +/** + * Smoke-tests the CLI Docker image that cli-build.yml pushes. On each platform + * the CLI starts, and git reads the checkout mounted at /work, the image's + * working directory. Run it from the repository root: + * + * node scripts/cli-docker-smoke-test.mjs [,...] + */ +import { execFileSync } from "node:child_process"; +import { pathToFileURL } from "node:url"; + +/** + * Throws when the image fails a check on any platform. + * + * @param {object} options + * @param {string} options.image - Image reference to run. + * @param {string[]} options.platforms - Platforms to run it on, such as + * `linux/arm64`. + * @param {string} options.checkout - Host checkout to mount at /work. + * @param {string} options.head - Commit that checkout is at. + * @param {(args: string[]) => string} options.docker - Runs `docker` with the + * arguments and returns its stdout; throws on a non-zero exit. + * @returns {Map} The CLI version that each platform printed. + */ +export function smokeTestImage({ image, platforms, checkout, head, docker }) { + const versions = new Map(); + for (const platform of platforms) { + const run = ["run", "--rm", "--platform", platform]; + const version = docker([...run, image, "--version"]).trim(); + if (!version) { + throw new Error(`${platform}: sentry --version printed nothing`); + } + const mountedHead = docker([ + ...run, + "--volume", + `${checkout}:/work`, + "--entrypoint", + "git", + image, + "rev-parse", + "HEAD", + ]).trim(); + if (mountedHead !== head) { + throw new Error( + `${platform}: git in /work read ${mountedHead}, expected ${head}`, + ); + } + versions.set(platform, version); + } + return versions; +} + +if ( + process.argv[1] && + import.meta.url === pathToFileURL(process.argv[1]).href +) { + const [image, platforms] = process.argv.slice(2); + if (!image || !platforms) { + throw new Error( + "Usage: node scripts/cli-docker-smoke-test.mjs [,...]", + ); + } + const versions = smokeTestImage({ + image, + platforms: platforms.split(","), + checkout: process.cwd(), + head: execFileSync("git", ["rev-parse", "HEAD"], { + encoding: "utf8", + }).trim(), + docker: (args) => + execFileSync("docker", args, { + encoding: "utf8", + stdio: ["ignore", "pipe", "inherit"], + }), + }); + for (const [platform, version] of versions) { + console.log(`${platform}: sentry ${version}; git reads /work`); + } +} diff --git a/scripts/cli-docker-smoke-test.test.mjs b/scripts/cli-docker-smoke-test.test.mjs new file mode 100644 index 0000000000..f3272fbf56 --- /dev/null +++ b/scripts/cli-docker-smoke-test.test.mjs @@ -0,0 +1,82 @@ +import assert from "node:assert/strict"; +import test from "node:test"; +import { smokeTestImage } from "./cli-docker-smoke-test.mjs"; + +const IMAGE = "ghcr.io/getsentry/toolkit/sentry-cli:abc123"; +const HEAD = "abc123"; +const PLATFORMS = ["linux/amd64", "linux/arm64"]; + +/** A fake `docker` that records its calls and answers like a working image. */ +function fakeDocker({ version = "4.0.0", mountedHead = HEAD } = {}) { + const calls = []; + const docker = (args) => { + calls.push(args); + return args.includes("--version") ? `${version}\n` : `${mountedHead}\n`; + }; + return { calls, docker }; +} + +test("runs the CLI and reads the mounted checkout on every platform", () => { + const { calls, docker } = fakeDocker(); + + const versions = smokeTestImage({ + image: IMAGE, + platforms: PLATFORMS, + checkout: "/repo", + head: HEAD, + docker, + }); + + assert.deepEqual([...versions.keys()], PLATFORMS); + assert.deepEqual( + calls, + PLATFORMS.flatMap((platform) => [ + ["run", "--rm", "--platform", platform, IMAGE, "--version"], + [ + "run", + "--rm", + "--platform", + platform, + "--volume", + "/repo:/work", + "--entrypoint", + "git", + IMAGE, + "rev-parse", + "HEAD", + ], + ]), + ); +}); + +test("fails when git in /work reads another commit", () => { + const { docker } = fakeDocker({ mountedHead: "def456" }); + + assert.throws( + () => + smokeTestImage({ + image: IMAGE, + platforms: PLATFORMS, + checkout: "/repo", + head: HEAD, + docker, + }), + /linux\/amd64: git in \/work read def456, expected abc123/, + ); +}); + +test("fails when the CLI prints no version", () => { + const { docker } = fakeDocker({ version: "" }); + + assert.throws( + () => + smokeTestImage({ + image: IMAGE, + platforms: PLATFORMS, + checkout: "/repo", + head: HEAD, + docker, + }), + /linux\/amd64: sentry --version printed nothing/, + ); +}); From bcb7d461e216ded79c3f52f4fb3f9e8fc2b7207c Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 11:57:44 +0000 Subject: [PATCH 2/3] feat(cli): build the Docker image on distroless Switch the base from debian:bookworm-slim to gcr.io/distroless/cc-debian12 and copy in only libatomic, the git binary and its two libraries from a Debian 12 stage. The amd64 image goes from 295 MB to 156 MB uncompressed (95 MB to 46 MB gzipped). git now trusts only the /work mount point. The image has no shell, so the docs replace the GitLab entrypoint example with a COPY --from pattern. --- .../src/content/docs/getting-started.mdx | 26 +++++++-------- .../src/content/docs/migrating-from-v3.md | 8 ++--- packages/cli/Dockerfile | 33 ++++++++++++------- 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/apps/cli-docs/src/content/docs/getting-started.mdx b/apps/cli-docs/src/content/docs/getting-started.mdx index a09e3d24f8..728f3ffc13 100644 --- a/apps/cli-docs/src/content/docs/getting-started.mdx +++ b/apps/cli-docs/src/content/docs/getting-started.mdx @@ -165,20 +165,18 @@ release. Pin a version tag in CI. The image doesn't check for updates; pull a newer tag to upgrade. The image includes `git`, so commands such as `release set-commits --auto` and -`release propose-version` read the mounted checkout. Credentials and caches are -not kept between runs, so use `SENTRY_AUTH_TOKEN` rather than `sentry auth -login`. - -CI systems that run their own script in the image, such as GitLab CI, need -the entrypoint cleared. `sentry` is on the `PATH`: - -```yaml -upload-sourcemaps: - image: - name: getsentry/sentry-cli - entrypoint: [""] - script: - - sentry sourcemap upload ./dist +`release propose-version` read a checkout mounted at `/work`. Credentials and +caches are not kept between runs, so use `SENTRY_AUTH_TOKEN` rather than +`sentry auth login`. + +The image is built on [distroless](https://github.com/GoogleContainerTools/distroless) +and has no shell, so CI systems that run a script inside the job's image, such +as GitLab CI, can't use it as the job image. Install the CLI in the job instead, +or copy the binary into your own glibc-based image. The binary also needs +`libatomic1`: + +```dockerfile +COPY --from=getsentry/sentry-cli /usr/local/bin/sentry /usr/local/bin/sentry ``` ## Package Managers diff --git a/apps/cli-docs/src/content/docs/migrating-from-v3.md b/apps/cli-docs/src/content/docs/migrating-from-v3.md index 61818a8484..dbfc432a97 100644 --- a/apps/cli-docs/src/content/docs/migrating-from-v3.md +++ b/apps/cli-docs/src/content/docs/migrating-from-v3.md @@ -71,11 +71,11 @@ releases stay available under their version tags. What changed: - The entrypoint runs `sentry` directly. The v3 entrypoint dropped a leading `sentry-cli` argument and ran `sh` when asked; v4 passes every argument to - `sentry`. Use `--entrypoint sh` for a shell. -- The binary is `/usr/local/bin/sentry`. There is no `sentry-cli` on the - `PATH`, so scripts that clear the entrypoint, such as GitLab CI jobs, call `sentry`. -- The base image is Debian (`debian:bookworm-slim`) instead of Alpine, and it +- The base image is distroless instead of Alpine, so there is no shell. Jobs + that clear the entrypoint and run a script in the image, such as GitLab CI + jobs, need another way to install the CLI. +- The binary is `/usr/local/bin/sentry`; there is no `sentry-cli`. The image includes `git`. See [Docker](../getting-started/#docker) for usage. diff --git a/packages/cli/Dockerfile b/packages/cli/Dockerfile index 3df1a8b59a..7a6c593ff6 100644 --- a/packages/cli/Dockerfile +++ b/packages/cli/Dockerfile @@ -1,21 +1,32 @@ -# The getsentry/sentry-cli image: the standalone Linux binary on a slim -# Debian base. cli-build.yml builds it from this directory after copying in +# The getsentry/sentry-cli image: the standalone Linux binary on distroless. +# cli-build.yml builds it from this directory after copying in # dist-bin/sentry-linux-amd64 and dist-bin/sentry-linux-arm64 (the # `script/build.ts` outputs, renamed from x64 to Docker's amd64). -FROM debian:bookworm-slim + +# distroless has no package manager, so take the extra files from Debian 12, +# which distroless/cc-debian12 is built from. The Node runtime in the binary +# links libatomic. `release set-commits --auto`, `release propose-version`, and +# `code-mappings upload` read the mounted checkout with git, which needs +# libpcre2 and zlib. A checkout mounted from the host belongs to another user, +# so git must trust the /work mount point. +FROM debian:bookworm-slim AS deps +RUN apt-get update \ + && apt-get install -y --no-install-recommends git libatomic1 \ + && git config --system --add safe.directory /work \ + && mkdir /deps \ + && cp -L --parents /etc/gitconfig /usr/bin/git \ + /usr/lib/*-linux-gnu/libatomic.so.1 \ + /lib/*-linux-gnu/libpcre2-8.so.0 \ + /lib/*-linux-gnu/libz.so.1 \ + /deps/ + +FROM gcr.io/distroless/cc-debian12 LABEL org.opencontainers.image.source="https://github.com/getsentry/toolkit" \ org.opencontainers.image.description="Sentry CLI" \ org.opencontainers.image.licenses="FSL-1.1-Apache-2.0" -# The Node runtime in the binary links libatomic, which slim images leave out. -# `release set-commits --auto`, `release propose-version`, and -# `code-mappings upload` read the mounted checkout with git. A checkout mounted -# from the host belongs to another user, so git must trust every directory. -RUN apt-get update \ - && apt-get install -y --no-install-recommends git libatomic1 \ - && rm -rf /var/lib/apt/lists/* \ - && git config --system --add safe.directory '*' +COPY --from=deps /deps/ / ARG TARGETARCH COPY --chmod=555 dist-bin/sentry-linux-$TARGETARCH /usr/local/bin/sentry From a625635be4ed96627c074e53c1937562a0f9775e Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 12:10:05 +0000 Subject: [PATCH 3/3] ref(cli): pin the Docker base images and smoke-test git through sentry Pin debian:bookworm-slim and distroless/cc-debian12 by digest. The smoke test now runs `release propose-version --json` through the entrypoint, so it checks that the CLI finds the git copied into the distroless image and reads the checkout mounted at /work. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com> --- packages/cli/Dockerfile | 4 ++-- scripts/cli-docker-smoke-test.mjs | 22 +++++++++++++--------- scripts/cli-docker-smoke-test.test.mjs | 17 ++++++++++------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/packages/cli/Dockerfile b/packages/cli/Dockerfile index 7a6c593ff6..2956ae003f 100644 --- a/packages/cli/Dockerfile +++ b/packages/cli/Dockerfile @@ -9,7 +9,7 @@ # `code-mappings upload` read the mounted checkout with git, which needs # libpcre2 and zlib. A checkout mounted from the host belongs to another user, # so git must trust the /work mount point. -FROM debian:bookworm-slim AS deps +FROM debian:bookworm-slim@sha256:e67eeead736ff7bbe258ef088bff683635c561b1fcfefad0806c1df4ab49ce0e AS deps RUN apt-get update \ && apt-get install -y --no-install-recommends git libatomic1 \ && git config --system --add safe.directory /work \ @@ -20,7 +20,7 @@ RUN apt-get update \ /lib/*-linux-gnu/libz.so.1 \ /deps/ -FROM gcr.io/distroless/cc-debian12 +FROM gcr.io/distroless/cc-debian12@sha256:e5d81ddde149641e2a9ba55be4545bc125c67de07508b03ba4c22e6eb0ded5aa LABEL org.opencontainers.image.source="https://github.com/getsentry/toolkit" \ org.opencontainers.image.description="Sentry CLI" \ diff --git a/scripts/cli-docker-smoke-test.mjs b/scripts/cli-docker-smoke-test.mjs index 0b1eb8450d..a67da671cf 100644 --- a/scripts/cli-docker-smoke-test.mjs +++ b/scripts/cli-docker-smoke-test.mjs @@ -1,6 +1,7 @@ /** * Smoke-tests the CLI Docker image that cli-build.yml pushes. On each platform - * the CLI starts, and git reads the checkout mounted at /work, the image's + * the CLI starts, and `release propose-version` reads the commit through the + * git copied into the image from the checkout mounted at /work, the image's * working directory. Run it from the repository root: * * node scripts/cli-docker-smoke-test.mjs [,...] @@ -29,19 +30,22 @@ export function smokeTestImage({ image, platforms, checkout, head, docker }) { if (!version) { throw new Error(`${platform}: sentry --version printed nothing`); } - const mountedHead = docker([ + // propose-version needs a token but makes no API call. + const proposed = docker([ ...run, + "--env", + "SENTRY_AUTH_TOKEN=smoke-test", "--volume", `${checkout}:/work`, - "--entrypoint", - "git", image, - "rev-parse", - "HEAD", - ]).trim(); + "release", + "propose-version", + "--json", + ]); + const mountedHead = JSON.parse(proposed).version; if (mountedHead !== head) { throw new Error( - `${platform}: git in /work read ${mountedHead}, expected ${head}`, + `${platform}: propose-version in /work read ${mountedHead}, expected ${head}`, ); } versions.set(platform, version); @@ -73,6 +77,6 @@ if ( }), }); for (const [platform, version] of versions) { - console.log(`${platform}: sentry ${version}; git reads /work`); + console.log(`${platform}: sentry ${version}; propose-version reads /work`); } } diff --git a/scripts/cli-docker-smoke-test.test.mjs b/scripts/cli-docker-smoke-test.test.mjs index f3272fbf56..acfb556b36 100644 --- a/scripts/cli-docker-smoke-test.test.mjs +++ b/scripts/cli-docker-smoke-test.test.mjs @@ -11,7 +11,9 @@ function fakeDocker({ version = "4.0.0", mountedHead = HEAD } = {}) { const calls = []; const docker = (args) => { calls.push(args); - return args.includes("--version") ? `${version}\n` : `${mountedHead}\n`; + return args.includes("--version") + ? `${version}\n` + : JSON.stringify({ version: mountedHead, source: "git" }); }; return { calls, docker }; } @@ -37,19 +39,20 @@ test("runs the CLI and reads the mounted checkout on every platform", () => { "--rm", "--platform", platform, + "--env", + "SENTRY_AUTH_TOKEN=smoke-test", "--volume", "/repo:/work", - "--entrypoint", - "git", IMAGE, - "rev-parse", - "HEAD", + "release", + "propose-version", + "--json", ], ]), ); }); -test("fails when git in /work reads another commit", () => { +test("fails when propose-version in /work reads another commit", () => { const { docker } = fakeDocker({ mountedHead: "def456" }); assert.throws( @@ -61,7 +64,7 @@ test("fails when git in /work reads another commit", () => { head: HEAD, docker, }), - /linux\/amd64: git in \/work read def456, expected abc123/, + /linux\/amd64: propose-version in \/work read def456, expected abc123/, ); });