Skip to content

feat(cli): Publish the CLI Docker image as getsentry/sentry-cli - #2513

Open
sentry-junior[bot] wants to merge 4 commits into
mainfrom
feat/cli-docker-image
Open

sentry-junior[bot] wants to merge 4 commits into
mainfrom
feat/cli-docker-image

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1965. Ships the v4 CLI as the getsentry/sentry-cli Docker image, following getsentry/spotlight: a thin base image with the compiled binary dropped in.

What changes

  • packages/cli/Dockerfile: gcr.io/distroless/cc-debian12 with the standalone Linux binary at /usr/local/bin/sentry as the entrypoint, WORKDIR /work, and the update check off, since a container can't upgrade its own image.
  • cli-build.yml: a new build-docker job takes the Linux binaries from build-binary and pushes a multi-arch (amd64/arm64) image to ghcr.io/getsentry/toolkit/sentry-cli, tagged with the commit, then smoke-tests it on both architectures. There's no layer cache, so release images never build from a cache that main filled.
  • .craft.yml: docker targets that copy the release commit's image to Docker Hub getsentry/sentry-cli, tagged with the version and latest.
  • Docs: Docker sections in Installation and "Migrating from v3".

The GHCR name is toolkit/sentry-cli because ghcr.io/getsentry/toolkit holds the nightly binpatch artifacts, and sentry cli upgrade lists that package's tags.

Differences from the v3 image

  • Same image name and the same /work working directory, so mounting the project at /work still works once commands are renamed.
  • The entrypoint is sentry and gets every argument. v3's entrypoint script dropped a leading sentry-cli argument and ran a shell on request. There's no sentry-cli on PATH.
  • Distroless instead of Alpine, and larger: about 156 MB uncompressed and 46 MB gzipped for amd64, against about 13 MB compressed for v3. The binary alone is 128 MB (about 42 MB gzipped).
  • No shell. --entrypoint sh and CI jobs that clear the entrypoint and run a script in the image, such as GitLab CI, no longer work. The docs show copying the binary into your own image with COPY --from=getsentry/sentry-cli instead.
  • distroless has no package manager, so a Debian 12 build stage supplies the extra files. libatomic.so.1 is needed because the binary's Node runtime links it.
  • git is kept for v3 parity: v3 had libgit2 built in, and v4 runs git for release set-commits --auto, release propose-version, and code-mappings upload against the mounted checkout. Only the git binary and its libraries (libpcre2-8, zlib) are copied, about 6 MB. Local read commands work; remote helpers such as git-remote-https aren't included. Git trusts /work, where the host user's checkout is mounted; a checkout mounted somewhere else and read as root needs --user set to the checkout owner.

Release plan

  • Merge timing: merge with, or just before, v4.0.0. After merge, the next packages/cli release pushes to Docker Hub and moves latest, which is 3.8.2 today, so a 0.x release in between would put a 0.x build there.
  • Prereleases: Craft's docker target has no prerelease check, so a prerelease also moves latest.

Needs a person

  1. The first push creates ghcr.io/getsentry/toolkit/sentry-cli as a private package. getsentry/publish reads it with its own GITHUB_TOKEN, so before the first release a package admin needs to make it public or give getsentry/publish read access.
  2. Docker Hub: getsentry/publish pushes as sentrybuilder for every repo, and that account pushed getsentry/sentry-cli:3.8.2. No new grant should be needed. Check that its token isn't limited to particular repos.
  3. At v4 launch, remove the Docker Hub (latest) target from getsentry/sentry-cli's .craft.yml. Otherwise a 3.x maintenance release moves latest back.
  4. The Docker Hub overview text is edited by hand.

via @BYK.

--

View Session [Sentry]

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 <[email protected]>
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Nov 26, 2026 4:20pm UTC
sentry-local Ready Ready Preview Nov 26, 2026 4:20pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📊 MCP Server Token Cost Report

Summary

  • Total Tokens: 67760 tokens
  • Tool Count: 76 tools
  • Average: 892 tokens/tool

Per-Tool Breakdown

Tool Tokens % of Total
get_issue_details 3967 5.9%
get_alert_rule 2245 3.3%
find_releases 1805 2.7%
get_issue_activity 1759 2.6%
update_alert_rule 1653 2.4%
get_replay_details 1602 2.4%
create_alert_rule 1506 2.2%
get_monitor_details 1501 2.2%
update_metric_monitor 1479 2.2%
create_metric_monitor 1458 2.2%
get_event_stacktrace 1381 2%
update_issue 1380 2%
render_sentry_chart 1362 2%
get_snapshot 1308 1.9%
get_profile 1291 1.9%
get_agent_conversation_details 1278 1.9%
find_monitors 1261 1.9%
search_logs 1248 1.8%
search_traces 1246 1.8%
get_alert_options 1236 1.8%
search_profiles 1228 1.8%
search_metrics 1216 1.8%
search_errors 1214 1.8%
get_profile_details 1200 1.8%
find_related_issues 1171 1.7%
get_uptime_monitor_details 1163 1.7%
create_monitor 1135 1.7%
onboarding_status_update 1109 1.6%
search_issue_events 1103 1.6%
search_replays 1095 1.6%
render_issue_chart 1061 1.6%
get_release_details 1056 1.6%
get_dashboard_details 1052 1.6%
search_issues 977 1.4%
search_docs 973 1.4%
find_alert_rules 908 1.3%
update_uptime_monitor 873 1.3%
create_uptime_monitor 871 1.3%
search_agent_conversations 830 1.2%
find_dropped_events 819 1.2%
get_metric_monitor_details 797 1.2%
create_project 793 1.2%
update_dsn 765 1.1%
get_issue_user_reports 630 0.9%
get_latest_base_snapshot 623 0.9%
find_dashboards 553 0.8%
link_issue 545 0.8%
find_uptime_monitors 537 0.8%
get_issue_breadcrumbs 492 0.7%
unlink_issue 476 0.7%
find_metric_monitors 471 0.7%
get_issue_tag_values 469 0.7%
update_project 441 0.7%
get_sentry_resource 429 0.6%
submit_feedback_to_sentry_team 426 0.6%
add_issue_note 404 0.6%
delete_monitor_environment 363 0.5%
find_teams 351 0.5%
find_projects 346 0.5%
delete_alert_rule 345 0.5%
delete_uptime_monitor 333 0.5%
delete_metric_monitor 331 0.5%
create_dsn 326 0.5%
add_team_to_project 324 0.5%
remove_team_from_project 320 0.5%
find_dsns 319 0.5%
find_organizations 311 0.5%
get_snapshot_image 302 0.4%
analyze_issue_with_seer 300 0.4%
get_event_attachment 299 0.4%
get_trace_details 282 0.4%
create_team 266 0.4%
get_span_details 263 0.4%
whoami 261 0.4%
get_sentry_mcp_info 142 0.2%
get_doc 102 0.2%

Note: This measures the static overhead of tool definitions sent to LLM clients with every request. Lower is better.

MCP Apps views

Each ui:// view as a host receives it from resources/read.

View MIME type Raw Gzip Brotli Budget % of budget
ui://sentry/chart/v5.html text/html;profile=mcp-app 19,234 B 7,915 B 7,020 B 24,576 B 78.3%

The budget applies to raw bytes, and the view's generator fails over it.

Comment thread packages/cli/.dockerignore Resolved
@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 26, 2026 11:15
@sentry-junior
sentry-junior Bot requested a review from BYK November 26, 2026 11:15
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 26, 2026

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debian instead of Alpine, and much larger: roughly 295 MB uncompressed for amd64, against about 13 MB compressed for v3. Most of that is the 128 MB binary.

How small can we go if we try to stick to Alpine and use Musl bulids?

@sentry-junior

sentry-junior Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Short answer: about half the size. I built a musl version of the binary and measured it in Alpine images (amd64):

Image Uncompressed gzip
This PR (bookworm-slim + git + libatomic1) 295 MB 95 MB
Alpine 3.22 + musl binary + libstdc++ + git 165 MB 52 MB
Alpine 3.22 + musl binary + libstdc++, no git 153 MB 46 MB
v3 image — ~13 MB

The binary is the floor: the musl one is 141 MB raw and ~42 MB gzipped, and Alpine adds only a few MB on top. Most of what we'd save is Debian's base (~28 MB gz) and git's Perl dependency (Alpine's git doesn't need Perl). It only needs libstdc++ (which pulls in libgcc), not libatomic. In the musl image, --version works, auth status exits 10, and release propose-version reads the commit from a mounted checkout.

The catch is that script/build.ts and fossilize can't build musl binaries yet. fossilize only downloads Node from nodejs.org/dist, and nodejs.org doesn't publish musl Node. The musl builds come from unofficial-builds.nodejs.org (linux-x64-musl and linux-arm64-musl exist for v26.13.1, the LTS we use). For this test I put that Node in fossilize's cache under a linux-x64-musl name and built normally: stripping, removing NODE_OPTIONS and hole-punching all worked. To ship it we'd need:

  • linux-x64-musl and linux-arm64-musl build targets, plus a way to get the unofficial musl Node, either in fossilize or by downloading it in build.ts. Those builds are community-run and can lag behind official releases.
  • No V8 code cache, because that cache is only generated for the host platform. Startup is around 15% slower, same as our cross-built arm64 binary today.
  • An arm64 musl test. I could only run amd64 here.

This would also give Alpine users a standalone binary. src/lib/binary.ts already looks for sentry-linux-<arch>-musl assets, but the build doesn't produce them, so the installer sends musl users to npm instead.

Want me to switch this PR to Alpine + musl (adding the musl targets to the CLI build), or ship Debian now and do musl as a follow-up?

@sentry-junior
sentry-junior Bot requested a review from BYK November 26, 2026 11:31

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want me to switch this PR to Alpine + musl (adding the musl targets to the CLI build), or ship Debian now and do musl as a follow-up?

Sounds good but before that let's also try a distroless base if we can?

Finally, if you think it makes sense, file an issue to fossilize so we can add musl support? It's my project at the end of the day and we can get a fork under getsentry org for you to work on it

@sentry-junior

sentry-junior Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

I tried distroless. It works with the glibc binary we already build, so the Docker image doesn't need musl. Sizes for amd64:

Image Uncompressed gzip
This PR (bookworm-slim + git + libatomic1) 295 MB 95 MB
Alpine + musl binary + git 165 MB 52 MB
distroless/cc-debian12 + glibc binary + libatomic.so.1 + git 158 MB 47 MB
distroless/cc-debian12 + glibc binary + libatomic.so.1 152 MB 44 MB
distroless/cc-debian12:debug (adds a busybox shell), no git 153 MB 45 MB

Details:

  • cc-debian12 already has glibc, libstdc++ and libgcc. The only thing missing is libatomic.so.1, which I copied in from a bookworm build stage. --version works and auth status exits 10.
  • distroless has no package manager. For git, I copied just /usr/bin/git and the libraries ldd lists from that stage, which adds about 6 MB. release propose-version read the commit from a mounted checkout. The commands we run (rev-parse, log, remote get-url) are built into that one binary, but git helpers such as git-remote-https aren't there, so fetching or pushing over HTTPS wouldn't work. A root container reading a checkout owned by the host user also needs safe.directory set, which would have to be a copied-in /etc/gitconfig since there's no shell to run git config.
  • No shell. --entrypoint sh and GitLab-style jobs that clear the entrypoint and run script: don't work: GitLab needs sh in the image, and both v3 (Alpine) and this PR have one. The :debug tag adds busybox for about 1 MB, but distroless doesn't recommend :debug for production use.

The options:

  1. distroless cc-debian12 + copied git (47 MB gz): smallest, and no build changes, but no shell, so the GitLab pattern breaks.
  2. distroless cc-debian12:debug + copied git (~48 MB gz): has a shell via busybox, on a tag that distroless labels debug-only.
  3. Alpine + musl (52 MB gz): a real shell, apk git, and supported GitLab usage, but it needs musl targets in fossilize and the CLI build.

I'd go with 3 if keeping a shell matters, and 1 if it doesn't. Which one?

fossilize musl issue: I think it's worth doing even if the image goes distroless, because Alpine users of the installer still get sent to npm. I wrote the issue for BYK/fossilize: add linux-x64-musl/linux-arm64-musl platforms that download from unofficial-builds.nodejs.org and resolve versions against its index.json (with a SHASUMS256.txt check), plus the evidence that strip, NODE_OPTIONS removal, inject and hole-punch already work on the unofficial musl Node. I haven't filed it yet: I need your explicit OK to open an issue on BYK/fossilize.

@sentry-junior
sentry-junior Bot requested a review from BYK November 26, 2026 11:44

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

distroless cc-debian12 + copied git (47 MB gz): smallest, and no build changes, but no shell, so the GitLab pattern breaks.

Let's go with this. What's the GitLab pattern tho?

Re fossilize: I forked it to getsentry/fossilize so let's get a patch up there and make an upstream PR?

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.
@sentry-junior

sentry-junior Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Switched to distroless in bcb7d46.

Result for amd64: 156 MB uncompressed, 46 MB gzipped. It runs --version and auth status. release propose-version reads a checkout mounted at /work, both as root and with --user 1000:1000, and the smoke-test script passes.

What changed besides the base image:

  • The Debian 12 stage copies only these into distroless: git, libpcre2-8, zlib, libatomic.so.1, and /etc/gitconfig.
  • Git's safe.directory is now just /work instead of *.

The GitLab pattern. GitLab's Docker executor runs a job's script: lines with a shell inside the job image. The usual way to use a CLI image like ours as the job image is to clear the entrypoint and call the binary from the script:

upload-sourcemaps:
  image:
    name: getsentry/sentry-cli
    entrypoint: [""]
  script:
    - sentry-cli sourcemaps upload ./dist

That needs sh in the image. v3 had one because it was Alpine; distroless doesn't, so the job fails before running anything. Bitbucket Pipelines and CircleCI's docker executor work the same way.

The docs now drop that example. They tell users to either install the CLI in the job, or copy the binary into their own glibc-based image:

COPY --from=getsentry/sentry-cli /usr/local/bin/sentry /usr/local/bin/sentry

I checked that the binary runs from debian:bookworm-slim with libatomic1 installed. If GitLab matters enough, the :debug distroless base adds a busybox shell for about 1 MB.

Correction to my musl comments above. I said nodejs.org doesn't publish musl Node. That's wrong for x64: official linux-x64-musl builds exist, including v26.13.1, and #2518 already builds sentry-linux-x64-musl with fossilize 0.10.1 unchanged. Only linux-arm64-musl is missing from nodejs.org/dist, so the fossilize patch is narrower: fall back to unofficial-builds.nodejs.org for platforms nodejs.org doesn't have, with a SHASUMS256.txt check. That work is underway on getsentry/fossilize, and an upstream PR to BYK/fossilize will follow.

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 <[email protected]>

This branch was successfully deployed

2 active deployments
Preview – sentry-local — b09a89c6 Deployed Nov 26, 2026 by vercel[bot]
Preview – cli — b09a89c6 Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant