fix(docker): copy packed artifacts from the builder stage#28148
fix(docker): copy packed artifacts from the builder stage#28148abhay-codes07 wants to merge 1 commit into
Conversation
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
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
|
📊 PR Size: size/XS
|
Summary
The
Dockerfileis a multi-stage build. Stage 1 (builder) runsnpm ci,npm run build, andnpm packto producepackages/cli/dist/google-gemini-cli-*.tgzandpackages/core/dist/google-gemini-cli-core-*.tgz. But Stage 2 (runtime) copied those.tgzfiles from the build context instead of from the builder stage:As a result the builder stage's output was never used, and a plain
docker build .fails at thisCOPYunless the.tgzfiles were already packed onto the host first (whichscripts/build_sandbox.jsdoes via host-sidenpm run build+npm pack). That host pre-pack requirement is what madedocker build .fail on its own — issue #21308.Fix
Copy the artifacts from the builder stage with
--from=builderso the multi-stage build is self-contained:The builder stage's
WORKDIRis/buildand it packs intopackages/{cli,core}/dist/, so these paths resolve to the freshly-built tarballs.Verification
Built the image locally with all host
packages/**/*.tgzremoved first, so the only possible source of the tarballs is the builder stage:docker build .(no host pre-pack) succeeds; theCOPY --from=buildersteps resolve the tarballs,npm install -ginstalls both packages, and the in-Dockerfilegemini --versionsmoke test passes.docker run --rm --entrypoint gemini <image> --versionprints the expected version.With the previous context-based
COPY, the same clean build would fail because no.tgzexists in the context.Fixes #21308