dockerfile: add support for ONBUILD in combination with from#5357
Merged
tonistiigi merged 2 commits intomoby:masterfrom Oct 1, 2024
Merged
dockerfile: add support for ONBUILD in combination with from#5357tonistiigi merged 2 commits intomoby:masterfrom
tonistiigi merged 2 commits intomoby:masterfrom
Conversation
This avoids many temporary conversion between maps/slices and shell.EnvGetter. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
98e9189 to
cac7523
Compare
This adds support for the ONBUILD commands to refer to other stages in commands like `COPY --from=` or `RUN --mount=from=` . The source may be a stage in the calling Dockerfile, implicit image or named build context. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
cac7523 to
4cf7a1a
Compare
profnandaa
reviewed
Sep 27, 2024
| } | ||
|
|
||
| func testOnBuildNamedContext(t *testing.T, sb integration.Sandbox) { | ||
| integration.SkipOnPlatform(t, "windows") |
Collaborator
crazy-max
approved these changes
Oct 1, 2024
Member
There was a problem hiding this comment.
As far as I hate ONBUILD pattern, this LGTM after testing with several use cases (mounts, cache, named context). The nested onbuild implementation is as good as cursed though 🙈
Follow-ups to consider:
- Update docs https://docs.docker.com/reference/dockerfile/#onbuild (cc @dvdksn)
- Should we have some additional build checks for this command? (cc @colinhemmings @daghack)
- Could we have a way to disable ONBUILD?
| d.init() | ||
|
|
||
| if len(d.image.Config.OnBuild) > 0 { | ||
| if b, err := initOnBuildTriggers(d, d.image.Config.OnBuild, allDispatchStates); err != nil { |
Member
There was a problem hiding this comment.
Should we set a prefix to show this is coming from ONBUILD?
Member
Author
There was a problem hiding this comment.
If it has a prefix then I think it means "add the onbuild rule to current image config" (this is what is shown in legacy builder I think). Here it is actually running the command.
ledermann
added a commit
to ledermann/docker-rails-base
that referenced
this pull request
Feb 18, 2025
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.
This adds support for the ONBUILD commands to refer to
other stages in commands like
COPY --from=orRUN --mount=from=. The source may be a stage in thecalling Dockerfile, implicit image or named build context.
depends on #5349
fixes #4568 (comment)
fixes #959
fixes #816
fixes #817