@@ -3504,9 +3504,13 @@ COPY --chmod=0644 foo /
3504
3504
COPY --chmod=777 bar /baz
3505
3505
COPY --chmod=0 foo /foobis
3506
3506
3507
+ ARG mode
3508
+ COPY --chmod=${mode} foo /footer
3509
+
3507
3510
RUN stat -c "%04a" /foo > /out/fooperm
3508
3511
RUN stat -c "%04a" /baz > /out/barperm
3509
3512
RUN stat -c "%04a" /foobis > /out/foobisperm
3513
+ RUN stat -c "%04a" /footer > /out/footerperm
3510
3514
FROM scratch
3511
3515
COPY --from=base /out /
3512
3516
` )
@@ -3531,6 +3535,9 @@ COPY --from=base /out /
3531
3535
OutputDir : destDir ,
3532
3536
},
3533
3537
},
3538
+ FrontendAttrs : map [string ]string {
3539
+ "build-arg:mode" : "755" ,
3540
+ },
3534
3541
LocalMounts : map [string ]fsutil.FS {
3535
3542
dockerui .DefaultLocalNameDockerfile : dir ,
3536
3543
dockerui .DefaultLocalNameContext : dir ,
@@ -3550,6 +3557,10 @@ COPY --from=base /out /
3550
3557
dt , err = os .ReadFile (filepath .Join (destDir , "foobisperm" ))
3551
3558
require .NoError (t , err )
3552
3559
require .Equal (t , "0000\n " , string (dt ))
3560
+
3561
+ dt , err = os .ReadFile (filepath .Join (destDir , "footerperm" ))
3562
+ require .NoError (t , err )
3563
+ require .Equal (t , "0755\n " , string (dt ))
3553
3564
}
3554
3565
3555
3566
func testCopyInvalidChmod (t * testing.T , sb integration.Sandbox ) {
@@ -3852,9 +3863,14 @@ FROM busybox AS build
3852
3863
ADD --chmod=644 %[1]s /tmp/foo1
3853
3864
ADD --chmod=755 %[1]s /tmp/foo2
3854
3865
ADD --chmod=0413 %[1]s /tmp/foo3
3866
+
3867
+ ARG mode
3868
+ ADD --chmod=${mode} %[1]s /tmp/foo4
3869
+
3855
3870
RUN stat -c "%%04a" /tmp/foo1 >> /dest && \
3856
3871
stat -c "%%04a" /tmp/foo2 >> /dest && \
3857
- stat -c "%%04a" /tmp/foo3 >> /dest
3872
+ stat -c "%%04a" /tmp/foo3 >> /dest && \
3873
+ stat -c "%%04a" /tmp/foo4 >> /dest
3858
3874
3859
3875
FROM scratch
3860
3876
COPY --from=build /dest /dest
@@ -3878,6 +3894,9 @@ COPY --from=build /dest /dest
3878
3894
OutputDir : destDir ,
3879
3895
},
3880
3896
},
3897
+ FrontendAttrs : map [string ]string {
3898
+ "build-arg:mode" : "400" ,
3899
+ },
3881
3900
LocalMounts : map [string ]fsutil.FS {
3882
3901
dockerui .DefaultLocalNameDockerfile : dir ,
3883
3902
dockerui .DefaultLocalNameContext : dir ,
@@ -3887,7 +3906,7 @@ COPY --from=build /dest /dest
3887
3906
3888
3907
dt , err := os .ReadFile (filepath .Join (destDir , "dest" ))
3889
3908
require .NoError (t , err )
3890
- require .Equal (t , []byte ("0644\n 0755\n 0413\n " ), dt )
3909
+ require .Equal (t , []byte ("0644\n 0755\n 0413\n 0400 \ n " ), dt )
3891
3910
}
3892
3911
3893
3912
func testAddInvalidChmod (t * testing.T , sb integration.Sandbox ) {
0 commit comments