Skip to content

Commit f1f24dc

Browse files
committed
dockerfile: mark commands invoked from ONBUILD with prefix
Signed-off-by: Tonis Tiigi <[email protected]>
1 parent ec8d92f commit f1f24dc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

frontend/dockerfile/dockerfile2llb/convert.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ func (e *envsFromState) Keys() []string {
860860
}
861861

862862
func dispatch(d *dispatchState, cmd command, opt dispatchOpt) error {
863+
d.cmdIsOnBuild = cmd.isOnBuild
863864
var err error
864865
// ARG command value could be ignored, so defer handling the expansion error
865866
_, isArg := cmd.Command.(*instructions.ArgCommand)
@@ -1015,6 +1016,7 @@ type dispatchState struct {
10151016
unregistered bool
10161017
stageName string
10171018
cmdIndex int
1019+
cmdIsOnBuild bool
10181020
cmdTotal int
10191021
prefixPlatform bool
10201022
outline outlineCapture
@@ -1093,7 +1095,8 @@ func (dss *dispatchStates) lastTarget() *dispatchState {
10931095

10941096
type command struct {
10951097
instructions.Command
1096-
sources []*dispatchState
1098+
sources []*dispatchState
1099+
isOnBuild bool
10971100
}
10981101

10991102
// initOnBuildTriggers initializes the onbuild triggers and creates the commands and dependecies for them.
@@ -1118,6 +1121,7 @@ func initOnBuildTriggers(d *dispatchState, triggers []string, allDispatchStates
11181121
if err != nil {
11191122
return false, err
11201123
}
1124+
cmd.isOnBuild = true
11211125
if len(cmd.sources) > 0 {
11221126
hasNewDeps = true
11231127
}
@@ -2066,6 +2070,9 @@ func prefixCommand(ds *dispatchState, str string, prefixPlatform bool, platform
20662070
}
20672071
ds.cmdIndex++
20682072
out += fmt.Sprintf("%*d/%d] ", int(1+math.Log10(float64(ds.cmdTotal))), ds.cmdIndex, ds.cmdTotal)
2073+
if ds.cmdIsOnBuild {
2074+
out += "ONBUILD "
2075+
}
20692076
return out + str
20702077
}
20712078

0 commit comments

Comments
 (0)