@@ -126,6 +126,8 @@ var allTests = integration.TestFuncs(
126
126
testEnvEmptyFormatting ,
127
127
testCacheMultiPlatformImportExport ,
128
128
testOnBuildCleared ,
129
+ testOnBuildInheritedStageRun ,
130
+ testOnBuildInheritedStageWithFrom ,
129
131
testOnBuildNewDeps ,
130
132
testOnBuildNamedContext ,
131
133
testOnBuildWithCacheMount ,
@@ -5028,6 +5030,101 @@ func testOnBuildNamedContext(t *testing.T, sb integration.Sandbox) {
5028
5030
require .Equal (t , []byte ("hello" ), dt )
5029
5031
}
5030
5032
5033
+ func testOnBuildInheritedStageRun (t * testing.T , sb integration.Sandbox ) {
5034
+ integration .SkipOnPlatform (t , "windows" )
5035
+ workers .CheckFeatureCompat (t , sb , workers .FeatureDirectPush )
5036
+ f := getFrontend (t , sb )
5037
+
5038
+ dockerfile := []byte (`
5039
+ FROM busybox AS base
5040
+ ONBUILD RUN mkdir -p /out && echo -n 11 >> /out/foo
5041
+
5042
+ FROM base AS mid
5043
+ RUN cp /out/foo /out/bar
5044
+
5045
+ FROM scratch
5046
+ COPY --from=mid /out/bar /
5047
+ ` )
5048
+
5049
+ dir := integration .Tmpdir (
5050
+ t ,
5051
+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
5052
+ )
5053
+
5054
+ c , err := client .New (sb .Context (), sb .Address ())
5055
+ require .NoError (t , err )
5056
+ defer c .Close ()
5057
+
5058
+ destDir := t .TempDir ()
5059
+
5060
+ _ , err = f .Solve (sb .Context (), c , client.SolveOpt {
5061
+ Exports : []client.ExportEntry {
5062
+ {
5063
+ Type : client .ExporterLocal ,
5064
+ OutputDir : destDir ,
5065
+ },
5066
+ },
5067
+ LocalMounts : map [string ]fsutil.FS {
5068
+ dockerui .DefaultLocalNameDockerfile : dir ,
5069
+ dockerui .DefaultLocalNameContext : dir ,
5070
+ },
5071
+ }, nil )
5072
+ require .NoError (t , err )
5073
+
5074
+ dt , err := os .ReadFile (filepath .Join (destDir , "bar" ))
5075
+ require .NoError (t , err )
5076
+ require .Equal (t , "11" , string (dt ))
5077
+ }
5078
+
5079
+ func testOnBuildInheritedStageWithFrom (t * testing.T , sb integration.Sandbox ) {
5080
+ integration .SkipOnPlatform (t , "windows" )
5081
+ workers .CheckFeatureCompat (t , sb , workers .FeatureDirectPush )
5082
+ f := getFrontend (t , sb )
5083
+
5084
+ dockerfile := []byte (`
5085
+ FROM alpine AS src
5086
+ RUN mkdir -p /in && echo -n 12 > /in/file
5087
+
5088
+ FROM busybox AS base
5089
+ ONBUILD COPY --from=src /in/file /out/foo
5090
+
5091
+ FROM base AS mid
5092
+ RUN cp /out/foo /out/bar
5093
+
5094
+ FROM scratch
5095
+ COPY --from=mid /out/bar /
5096
+ ` )
5097
+
5098
+ dir := integration .Tmpdir (
5099
+ t ,
5100
+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
5101
+ )
5102
+
5103
+ c , err := client .New (sb .Context (), sb .Address ())
5104
+ require .NoError (t , err )
5105
+ defer c .Close ()
5106
+
5107
+ destDir := t .TempDir ()
5108
+
5109
+ _ , err = f .Solve (sb .Context (), c , client.SolveOpt {
5110
+ Exports : []client.ExportEntry {
5111
+ {
5112
+ Type : client .ExporterLocal ,
5113
+ OutputDir : destDir ,
5114
+ },
5115
+ },
5116
+ LocalMounts : map [string ]fsutil.FS {
5117
+ dockerui .DefaultLocalNameDockerfile : dir ,
5118
+ dockerui .DefaultLocalNameContext : dir ,
5119
+ },
5120
+ }, nil )
5121
+ require .NoError (t , err )
5122
+
5123
+ dt , err := os .ReadFile (filepath .Join (destDir , "bar" ))
5124
+ require .NoError (t , err )
5125
+ require .Equal (t , "12" , string (dt ))
5126
+ }
5127
+
5031
5128
func testOnBuildNewDeps (t * testing.T , sb integration.Sandbox ) {
5032
5129
integration .SkipOnPlatform (t , "windows" )
5033
5130
workers .CheckFeatureCompat (t , sb , workers .FeatureDirectPush )
0 commit comments