-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dockerfile: add support for ONBUILD in combination with from #5357
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
@@ -4674,6 +4677,325 @@ ONBUILD RUN mkdir -p /out && echo -n 11 >> /out/foo | |||
require.Equal(t, "11", string(dt)) | |||
} | |||
|
|||
func testOnBuildNamedContext(t *testing.T, sb integration.Sandbox) { | |||
integration.SkipOnPlatform(t, "windows") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we set a prefix to show this is coming from ONBUILD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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