Skip to content

fix(ci): set build_target to 'application' to reduce Docker image size#7913

Merged
xurui-c merged 2 commits into
getsentry:masterfrom
aldy505:fix/ci/build-target-application
May 5, 2026
Merged

fix(ci): set build_target to 'application' to reduce Docker image size#7913
xurui-c merged 2 commits into
getsentry:masterfrom
aldy505:fix/ci/build-target-application

Conversation

@aldy505

@aldy505 aldy505 commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator

Should be done after #7909 is merged

@aldy505
aldy505 requested a review from a team as a code owner April 29, 2026 07:20
@aldy505

aldy505 commented May 3, 2026

Copy link
Copy Markdown
Collaborator Author

@kylemumma I don't have write access. Any chance I can get this merged before May 14?

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0b7b2c8. Configure here.

image_name: 'snuba'
platforms: linux/${{ matrix.platform }}
dockerfile_path: 'Dockerfile'
build_target: 'application'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Production build job missing build_target setting

High Severity

The build_target: 'application' is added to build-multiplatform but not to the build-production job (line 49–60), which pushes to Google Artifact Registry. Without build_target, Docker defaults to building the last stage in the Dockerfile, which is testing — a bloated image containing dev dependencies and Rust toolchains. The Google AR "production" image now diverges from the GHCR images in a way it didn't before this change.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0b7b2c8. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Self-hosted build does not care about the build-production. This is wrong.

platforms: linux/${{ matrix.platform }}
dockerfile_path: 'Dockerfile'
build_target: 'application'
tag_suffix: -${{ matrix.platform }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The build-production job is missing build_target: 'application', causing the production image to be built from the testing stage with unnecessary dev dependencies and build artifacts.
Severity: HIGH

Suggested Fix

In the .github/workflows/image.yml file, add the build_target: 'application' parameter to the build-production job, similar to how it has been added to the build-multiplatform job in this pull request. This will ensure the correct, stripped-down application stage is used for the production image.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: .github/workflows/image.yml#L35

Potential issue: The `build-production` job in the `image.yml` workflow does not specify
a `build_target`. Because the final stage in the associated Dockerfile is `testing`,
Docker defaults to building this stage for production. This `testing` stage includes
development dependencies, the full Rust toolchain, and source code, none of which should
be in a production image. This results in a significantly larger and potentially less
secure production container. While the pull request correctly adds `build_target:
'application'` to the `build-multiplatform` job, it fails to apply the same necessary
fix to the `build-production` job.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Invalid. There is:

snuba/Dockerfile

Lines 146 to 152 in b5a6b12

FROM application_base AS application
USER 0
RUN set -ex; \
apt-get purge -y --auto-remove $(cat /tmp/build-deps.txt); \
rm /tmp/build-deps.txt; \
rm -rf /var/lib/apt/lists/*;
USER snuba

@xurui-c
xurui-c merged commit b4824ad into getsentry:master May 5, 2026
47 of 49 checks passed
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.

3 participants