Skip to content

build(docker): Run the image on distroless to cut OS vulnerabilities - #166

Merged
armenzg merged 1 commit into
mainfrom
ci/distroless-image
Nov 9, 2026
Merged

armenzg merged 1 commit into
mainfrom
ci/distroless-image

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Nearly all of the image's Grype findings come from Debian packages in python:3.15.2-slim that the app never uses, such as perl, ncurses, and apt. None come from our Python dependencies. When one of those packages gets a fix upstream before the base image does, the scan fails. That's what is happening now with zlib1g.

The image now runs on gcr.io/distroless/cc-debian13:nonroot. It has glibc and the C++ runtime that grpcio needs, but no shell, package manager, or perl. Distroless has no Python, so the builder installs a uv-managed Python under /python and copies it over with the venv. Tcl/Tk, pip, headers, and docs get removed first.

Local Grype scan of each image:

  • Before: 183 findings, 61 High, 2 fixable High (zlib1g), so only-fixed + severity-cutoff: high fails.
  • After: 44 findings, 11 High, 0 fixable High, so the scan passes. What's left is in glibc and the gcc runtime libs, plus 2 Medium/Low CPython findings that only 3.16 fixes.

The image is about the same size (191 MB vs 189 MB). Most of that is the venv. The Test starting check gets its 400. grpc, Secret Manager, cryptography, and ssl all import. The app runs as uid 65532 instead of nobody.

Trade-offs to consider:

  • There's no shell in the image, so docker exec … sh no longer works. The distroless :debug tags add busybox if that's ever needed.
  • uv's Python is a python-build-standalone build, which statically bundles OpenSSL, zlib, sqlite, and so on. Grype only sees it as the python binary, so fixes to those bundled libraries come with new Python builds, not Debian updates.
  • Only the minor version (UV_PYTHON=3.15) is pinned. The patch release is whatever the pinned uv release installs, so Dependabot's uv image bumps now bring Python patch updates. Before, Dependabot bumped the python: tag.
  • distroless/cc-debian13:nonroot is a moving tag, so each Cloud Build picks up the latest OS fixes. Dependabot won't propose changes to it.

via @armenzg.

--

View Session [Sentry]

Co-Authored-By: Armen Zambrano Gasparnian <44410+armenzg@users.noreply.github.com>
@armenzg
armenzg marked this pull request as ready for review November 9, 2026 14:21
@armenzg
armenzg requested a review from a team as a code owner November 9, 2026 14:21
@armenzg
armenzg merged commit 6f5e76a into main Nov 9, 2026
18 checks passed
@armenzg
armenzg deleted the ci/distroless-image branch November 9, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant