@@ -1029,17 +1029,28 @@ RUN e="300:400"; p="/file" ; a=` + "`" + `stat -c "%u:%g
1029
1029
}
1030
1030
1031
1031
func testCopyWildcardCache (t * testing.T , sb integration.Sandbox ) {
1032
- integration .SkipOnPlatform (t , "windows" )
1033
1032
f := getFrontend (t , sb )
1034
1033
1035
- dockerfile := []byte (`
1034
+ dockerfile := []byte (integration .UnixOrWindows (
1035
+ `
1036
1036
FROM busybox AS base
1037
1037
COPY foo* files/
1038
1038
RUN cat /dev/urandom | head -c 100 | sha256sum > unique
1039
1039
COPY bar files/
1040
1040
FROM scratch
1041
1041
COPY --from=base unique /
1042
- ` )
1042
+ ` ,
1043
+ `
1044
+ FROM nanoserver AS base
1045
+ USER ContainerAdministrator
1046
+ WORKDIR /files
1047
+ COPY foo* /files/
1048
+ RUN echo test> /unique
1049
+ COPY bar /files/
1050
+ FROM nanoserver
1051
+ COPY --from=base /unique /
1052
+ ` ,
1053
+ ))
1043
1054
1044
1055
dir := integration .Tmpdir (
1045
1056
t ,
@@ -1115,8 +1126,9 @@ COPY --from=base unique /
1115
1126
require .NoError (t , err )
1116
1127
1117
1128
dt2 , err = os .ReadFile (filepath .Join (destDir , "unique" ))
1129
+ expectedStr := string (dt )
1118
1130
require .NoError (t , err )
1119
- require .NotEqual (t , string ( dt ), string (dt2 ))
1131
+ require .NotEqual (t , integration . UnixOrWindows ( expectedStr , expectedStr + " \r \n " ), string (dt2 ))
1120
1132
}
1121
1133
1122
1134
func testEmptyWildcard (t * testing.T , sb integration.Sandbox ) {
@@ -2801,7 +2813,6 @@ ADD %s /dest/
2801
2813
}
2802
2814
2803
2815
func testDockerfileAddArchive (t * testing.T , sb integration.Sandbox ) {
2804
- integration .SkipOnPlatform (t , "windows" )
2805
2816
f := getFrontend (t , sb )
2806
2817
f .RequiresBuildctl (t )
2807
2818
@@ -2820,10 +2831,12 @@ func testDockerfileAddArchive(t *testing.T, sb integration.Sandbox) {
2820
2831
err = tw .Close ()
2821
2832
require .NoError (t , err )
2822
2833
2823
- dockerfile := []byte (`
2824
- FROM scratch
2834
+ baseImage := integration .UnixOrWindows ("scratch" , "nanoserver" )
2835
+
2836
+ dockerfile := []byte (fmt .Sprintf (`
2837
+ FROM %s
2825
2838
ADD t.tar /
2826
- ` )
2839
+ ` , baseImage ) )
2827
2840
2828
2841
dir := integration .Tmpdir (
2829
2842
t ,
@@ -2851,10 +2864,10 @@ ADD t.tar /
2851
2864
err = gz .Close ()
2852
2865
require .NoError (t , err )
2853
2866
2854
- dockerfile = []byte (`
2855
- FROM scratch
2867
+ dockerfile = []byte (fmt . Sprintf ( `
2868
+ FROM %s
2856
2869
ADD t.tar.gz /
2857
- ` )
2870
+ ` , baseImage ) )
2858
2871
2859
2872
dir = integration .Tmpdir (
2860
2873
t ,
@@ -2875,10 +2888,10 @@ ADD t.tar.gz /
2875
2888
require .Equal (t , expectedContent , dt )
2876
2889
2877
2890
// COPY doesn't extract
2878
- dockerfile = []byte (`
2879
- FROM scratch
2891
+ dockerfile = []byte (fmt . Sprintf ( `
2892
+ FROM %s
2880
2893
COPY t.tar.gz /
2881
- ` )
2894
+ ` , baseImage ) )
2882
2895
2883
2896
dir = integration .Tmpdir (
2884
2897
t ,
@@ -2910,9 +2923,9 @@ COPY t.tar.gz /
2910
2923
defer server .Close ()
2911
2924
2912
2925
dockerfile = []byte (fmt .Sprintf (`
2913
- FROM scratch
2926
+ FROM %s
2914
2927
ADD %s /
2915
- ` , server .URL + "/t.tar.gz" ))
2928
+ ` , baseImage , server .URL + "/t.tar.gz" ))
2916
2929
2917
2930
dir = integration .Tmpdir (
2918
2931
t ,
@@ -2933,9 +2946,9 @@ ADD %s /
2933
2946
2934
2947
// https://github.com/moby/buildkit/issues/386
2935
2948
dockerfile = []byte (fmt .Sprintf (`
2936
- FROM scratch
2949
+ FROM %s
2937
2950
ADD %s /newname.tar.gz
2938
- ` , server .URL + "/t.tar.gz" ))
2951
+ ` , baseImage , server .URL + "/t.tar.gz" ))
2939
2952
2940
2953
dir = integration .Tmpdir (
2941
2954
t ,
@@ -4422,13 +4435,21 @@ COPY foo bar
4422
4435
}
4423
4436
4424
4437
func testMultiStageImplicitFrom (t * testing.T , sb integration.Sandbox ) {
4425
- integration .SkipOnPlatform (t , "windows" )
4426
4438
f := getFrontend (t , sb )
4427
4439
4428
- dockerfile := []byte (`
4440
+ dockerfile := []byte (integration .UnixOrWindows (
4441
+ `
4429
4442
FROM scratch
4430
4443
COPY --from=busybox /etc/passwd test
4431
- ` )
4444
+ ` , `
4445
+ FROM nanoserver AS build
4446
+ USER ContainerAdministrator
4447
+ RUN echo test> test
4448
+
4449
+ FROM nanoserver
4450
+ COPY --from=build /test /test
4451
+ ` ,
4452
+ ))
4432
4453
4433
4454
dir := integration .Tmpdir (
4434
4455
t ,
@@ -4457,17 +4478,26 @@ COPY --from=busybox /etc/passwd test
4457
4478
4458
4479
dt , err := os .ReadFile (filepath .Join (destDir , "test" ))
4459
4480
require .NoError (t , err )
4460
- require .Contains (t , string (dt ), "root" )
4481
+ require .Contains (t , string (dt ), integration . UnixOrWindows ( "root" , "test" ) )
4461
4482
4462
4483
// testing masked image will load actual stage
4463
4484
4464
- dockerfile = []byte (`
4485
+ dockerfile = []byte (integration .UnixOrWindows (
4486
+ `
4465
4487
FROM busybox AS golang
4466
4488
RUN mkdir -p /usr/bin && echo -n foo > /usr/bin/go
4467
4489
4468
4490
FROM scratch
4469
4491
COPY --from=golang /usr/bin/go go
4470
- ` )
4492
+ ` , `
4493
+ FROM nanoserver AS golang
4494
+ USER ContainerAdministrator
4495
+ RUN echo foo> go
4496
+
4497
+ FROM nanoserver
4498
+ COPY --from=golang /go /go
4499
+ ` ,
4500
+ ))
4471
4501
4472
4502
dir = integration .Tmpdir (
4473
4503
t ,
@@ -4495,17 +4525,18 @@ COPY --from=golang /usr/bin/go go
4495
4525
}
4496
4526
4497
4527
func testMultiStageCaseInsensitive (t * testing.T , sb integration.Sandbox ) {
4498
- integration .SkipOnPlatform (t , "windows" )
4499
4528
f := getFrontend (t , sb )
4500
4529
4501
- dockerfile := [] byte ( `
4502
- FROM scratch AS STAge0
4530
+ dockerfileStr := `
4531
+ FROM %s AS STAge0
4503
4532
COPY foo bar
4504
- FROM scratch AS staGE1
4533
+ FROM %s AS staGE1
4505
4534
COPY --from=staGE0 bar baz
4506
- FROM scratch
4535
+ FROM %s
4507
4536
COPY --from=stage1 baz bax
4508
- ` )
4537
+ `
4538
+ baseImage := integration .UnixOrWindows ("scratch" , "nanoserver" )
4539
+ dockerfile := []byte (fmt .Sprintf (dockerfileStr , baseImage , baseImage , baseImage ))
4509
4540
dir := integration .Tmpdir (
4510
4541
t ,
4511
4542
fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
@@ -4665,7 +4696,6 @@ RUN dir file1
4665
4696
}
4666
4697
4667
4698
func testOnBuildCleared (t * testing.T , sb integration.Sandbox ) {
4668
- integration .SkipOnPlatform (t , "windows" )
4669
4699
workers .CheckFeatureCompat (t , sb , workers .FeatureDirectPush )
4670
4700
f := getFrontend (t , sb )
4671
4701
@@ -4675,10 +4705,16 @@ func testOnBuildCleared(t *testing.T, sb integration.Sandbox) {
4675
4705
}
4676
4706
require .NoError (t , err )
4677
4707
4678
- dockerfile := []byte (`
4708
+ dockerfile := []byte (integration .UnixOrWindows (
4709
+ `
4679
4710
FROM busybox
4680
4711
ONBUILD RUN mkdir -p /out && echo -n 11 >> /out/foo
4681
- ` )
4712
+ ` , `
4713
+ FROM nanoserver
4714
+ USER ContainerAdministrator
4715
+ ONBUILD RUN mkdir \out && echo 11>> \out\foo
4716
+ ` ,
4717
+ ))
4682
4718
4683
4719
dir := integration .Tmpdir (
4684
4720
t ,
@@ -4738,9 +4774,9 @@ ONBUILD RUN mkdir -p /out && echo -n 11 >> /out/foo
4738
4774
4739
4775
dockerfile = []byte (fmt .Sprintf (`
4740
4776
FROM %s AS base
4741
- FROM scratch
4777
+ FROM %s
4742
4778
COPY --from=base /out /
4743
- ` , target2 ))
4779
+ ` , target2 , integration . UnixOrWindows ( "scratch" , "nanoserver" ) ))
4744
4780
4745
4781
dir = integration .Tmpdir (
4746
4782
t ,
@@ -4764,7 +4800,7 @@ ONBUILD RUN mkdir -p /out && echo -n 11 >> /out/foo
4764
4800
4765
4801
dt , err := os .ReadFile (filepath .Join (destDir , "foo" ))
4766
4802
require .NoError (t , err )
4767
- require .Equal (t , "11" , string (dt ))
4803
+ require .Equal (t , integration . UnixOrWindows ( "11" , "11 \r \n " ) , string (dt ))
4768
4804
}
4769
4805
4770
4806
func testOnBuildNamedContext (t * testing.T , sb integration.Sandbox ) {
@@ -5833,10 +5869,10 @@ COPY --from=build out .
5833
5869
}
5834
5870
5835
5871
func testBuiltinArgs (t * testing.T , sb integration.Sandbox ) {
5836
- integration .SkipOnPlatform (t , "windows" )
5837
5872
f := getFrontend (t , sb )
5838
5873
5839
- dockerfile := []byte (`
5874
+ dockerfile := []byte (integration .UnixOrWindows (
5875
+ `
5840
5876
FROM busybox AS build
5841
5877
ARG FOO
5842
5878
ARG BAR
@@ -5845,7 +5881,18 @@ RUN echo -n $HTTP_PROXY::$NO_PROXY::$FOO::$BAR::$BAZ > /out
5845
5881
FROM scratch
5846
5882
COPY --from=build /out /
5847
5883
5848
- ` )
5884
+ ` , `
5885
+ FROM nanoserver AS build
5886
+ USER ContainerAdministrator
5887
+ ARG FOO
5888
+ ARG BAR
5889
+ ARG BAZ=bazcontent
5890
+ RUN echo %HTTP_PROXY%::%NO_PROXY%::%FOO%::%BAR%::%BAZ%> out
5891
+ FROM nanoserver
5892
+ COPY --from=build out /
5893
+ ` ,
5894
+ ))
5895
+
5849
5896
dir := integration .Tmpdir (
5850
5897
t ,
5851
5898
fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
@@ -5880,7 +5927,9 @@ COPY --from=build /out /
5880
5927
5881
5928
dt , err := os .ReadFile (filepath .Join (destDir , "out" ))
5882
5929
require .NoError (t , err )
5883
- require .Equal (t , "hpvalue::npvalue::foocontents::::bazcontent" , string (dt ))
5930
+ // Windows can't interpret empty env variables, %BAR% handles empty values.
5931
+ expectedStr := integration .UnixOrWindows (`hpvalue::npvalue::foocontents::::bazcontent` , "hpvalue::npvalue::foocontents::%BAR%::bazcontent\r \n " )
5932
+ require .Equal (t , expectedStr , string (dt ))
5884
5933
5885
5934
// repeat with changed default args should match the old cache
5886
5935
destDir = t .TempDir ()
@@ -5907,7 +5956,8 @@ COPY --from=build /out /
5907
5956
5908
5957
dt , err = os .ReadFile (filepath .Join (destDir , "out" ))
5909
5958
require .NoError (t , err )
5910
- require .Equal (t , "hpvalue::npvalue::foocontents::::bazcontent" , string (dt ))
5959
+ expectedStr = integration .UnixOrWindows ("hpvalue::npvalue::foocontents::::bazcontent" , "hpvalue::npvalue::foocontents::%BAR%::bazcontent\r \n " )
5960
+ require .Equal (t , expectedStr , string (dt ))
5911
5961
5912
5962
// changing actual value invalidates cache
5913
5963
destDir = t .TempDir ()
@@ -5934,7 +5984,8 @@ COPY --from=build /out /
5934
5984
5935
5985
dt , err = os .ReadFile (filepath .Join (destDir , "out" ))
5936
5986
require .NoError (t , err )
5937
- require .Equal (t , "hpvalue2::::foocontents2::::bazcontent" , string (dt ))
5987
+ expectedStr = integration .UnixOrWindows ("hpvalue2::::foocontents2::::bazcontent" , "hpvalue2::%NO_PROXY%::foocontents2::%BAR%::bazcontent\r \n " )
5988
+ require .Equal (t , expectedStr , string (dt ))
5938
5989
}
5939
5990
5940
5991
func testTarContext (t * testing.T , sb integration.Sandbox ) {
@@ -6050,15 +6101,15 @@ COPY foo bar
6050
6101
}
6051
6102
6052
6103
func testFrontendUseForwardedSolveResults (t * testing.T , sb integration.Sandbox ) {
6053
- integration .SkipOnPlatform (t , "windows" )
6054
6104
c , err := client .New (sb .Context (), sb .Address ())
6055
6105
require .NoError (t , err )
6056
6106
defer c .Close ()
6057
6107
6058
- dockerfile := [] byte ( `
6059
- FROM scratch
6108
+ dockerfileStr := `
6109
+ FROM %s
6060
6110
COPY foo foo2
6061
- ` )
6111
+ `
6112
+ dockerfile := []byte (fmt .Sprintf (dockerfileStr , integration .UnixOrWindows ("scratch" , "nanoserver" )))
6062
6113
dir := integration .Tmpdir (
6063
6114
t ,
6064
6115
fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
0 commit comments