Support durable base-image build context#3004
Merged
Merged
Conversation
Contributor
|
I've reviewed the changes in PR #3004. The implementation looks correct and well-tested:
The code follows existing patterns in the codebase and properly handles the edge case where Torch base images need their requirements.txt to persist for external Docker builds. LGTM |
Contributor
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
base-image dockerfile --build-context-dirflag for external base-image builders.cog_buildartifacts, such asrequirements.txt, when callers provide a durable context directory.Root Cause
base-image dockerfilecan emit Dockerfiles that reference a named BuildKit context:COPY --from=cog_build requirements.txt /tmp/requirements.txtThat path is needed for Torch base images because the base-image generator writes Torch, torchvision, torchaudio, and OpenCV requirements into
requirements.txt.After the
.cog/buildrefactor,base-image dockerfilestages those files in a temporary.cog/builddirectory created viadotcog.OpenTemp(). The temp directory is cleaned up before the command exits, so external builders likecog-base-imagescannot provide the requiredcog_buildcontext to Docker.This PR lets external callers opt into a durable staging directory without changing the default cleanup behavior.
Verification
go test ./pkg/dockerfile ./pkg/cli -count=1--build-context-dir /tmp/cog-base-context-checkand verified:COPY --from=cog_build requirements.txt /tmp/requirements.txt/tmp/cog-base-context-check/requirements.txtexists after command exittorch==2.11.0git diff --check