Skip to content

fix(docker): copy packed artifacts from the builder stage#28148

Open
abhay-codes07 wants to merge 1 commit into
google-gemini:mainfrom
abhay-codes07:fix/dockerfile-copy-from-builder-21308
Open

fix(docker): copy packed artifacts from the builder stage#28148
abhay-codes07 wants to merge 1 commit into
google-gemini:mainfrom
abhay-codes07:fix/dockerfile-copy-from-builder-21308

Conversation

@abhay-codes07

Copy link
Copy Markdown

Summary

The Dockerfile is a multi-stage build. Stage 1 (builder) runs npm ci, npm run build, and npm pack to produce packages/cli/dist/google-gemini-cli-*.tgz and packages/core/dist/google-gemini-cli-core-*.tgz. But Stage 2 (runtime) copied those .tgz files from the build context instead of from the builder stage:

COPY --chown=node:node packages/cli/dist/google-gemini-cli-*.tgz /tmp/gemini-cli.tgz
COPY --chown=node:node packages/core/dist/google-gemini-cli-core-*.tgz /tmp/gemini-core.tgz

As a result the builder stage's output was never used, and a plain docker build . fails at this COPY unless the .tgz files were already packed onto the host first (which scripts/build_sandbox.js does via host-side npm run build + npm pack). That host pre-pack requirement is what made docker build . fail on its own — issue #21308.

Fix

Copy the artifacts from the builder stage with --from=builder so the multi-stage build is self-contained:

COPY --from=builder --chown=node:node /build/packages/cli/dist/google-gemini-cli-*.tgz /tmp/gemini-cli.tgz
COPY --from=builder --chown=node:node /build/packages/core/dist/google-gemini-cli-core-*.tgz /tmp/gemini-core.tgz

The builder stage's WORKDIR is /build and it packs into packages/{cli,core}/dist/, so these paths resolve to the freshly-built tarballs.

Verification

Built the image locally with all host packages/**/*.tgz removed first, so the only possible source of the tarballs is the builder stage:

  • docker build . (no host pre-pack) succeeds; the COPY --from=builder steps resolve the tarballs, npm install -g installs both packages, and the in-Dockerfile gemini --version smoke test passes.
  • docker run --rm --entrypoint gemini <image> --version prints the expected version.

With the previous context-based COPY, the same clean build would fail because no .tgz exists in the context.

Fixes #21308

The runtime stage installed the CLI from `packages/{cli,core}/dist/*.tgz`
copied out of the build context, even though the builder stage already
runs `npm run build` and `npm pack` to produce exactly those artifacts.
The builder stage's output was never used, so a plain `docker build .`
failed at the COPY step unless the `.tgz` files had been packed onto the
host first (e.g. via `scripts/build_sandbox.js`).

Copy the artifacts with `--from=builder` so the multi-stage build is
self-contained and `docker build .` works on its own.

Fixes google-gemini#21308
@abhay-codes07 abhay-codes07 requested a review from a team as a code owner June 25, 2026 18:42
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the Docker build process by correctly leveraging multi-stage build capabilities. By sourcing the packed artifacts from the 'builder' stage rather than the host context, the build becomes self-contained and more reliable, fixing an issue where builds would fail unless the environment was manually prepared beforehand.

Highlights

  • Self-contained Docker build: Updated the Dockerfile to copy artifacts directly from the builder stage instead of the build context, ensuring the build process is self-contained.
  • Removed host dependency: Eliminated the requirement for pre-packing .tgz files on the host machine, resolving build failures when running 'docker build' in isolation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the size/xs An extra small PR label Jun 25, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/XS

  • Lines changed: 8
  • Additions: +6
  • Deletions: -2
  • Files changed: 1

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the Dockerfile to copy the packed npm artifacts from the builder stage rather than the build context, making the Docker build self-contained. There are no review comments, so I have no feedback to provide.

@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt priority/p2 Important but can be addressed in a future release. size/xs An extra small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker build fails because dist packages are not generated before COPY

1 participant