@@ -1028,17 +1028,28 @@ RUN e="300:400"; p="/file" ; a=` + "`" + `stat -c "%u:%g
1028
1028
}
1029
1029
1030
1030
func testCopyWildcardCache (t * testing.T , sb integration.Sandbox ) {
1031
- integration .SkipOnPlatform (t , "windows" )
1032
1031
f := getFrontend (t , sb )
1033
1032
1034
- dockerfile := []byte (`
1033
+ dockerfile := []byte (integration .UnixOrWindows (
1034
+ `
1035
1035
FROM busybox AS base
1036
1036
COPY foo* files/
1037
1037
RUN cat /dev/urandom | head -c 100 | sha256sum > unique
1038
1038
COPY bar files/
1039
1039
FROM scratch
1040
1040
COPY --from=base unique /
1041
- ` )
1041
+ ` ,
1042
+ `
1043
+ FROM nanoserver AS base
1044
+ USER ContainerAdministrator
1045
+ WORKDIR /files
1046
+ COPY foo* /files/
1047
+ RUN echo test> /unique
1048
+ COPY bar /files/
1049
+ FROM nanoserver
1050
+ COPY --from=base /unique /
1051
+ ` ,
1052
+ ))
1042
1053
1043
1054
dir := integration .Tmpdir (
1044
1055
t ,
@@ -1114,8 +1125,9 @@ COPY --from=base unique /
1114
1125
require .NoError (t , err )
1115
1126
1116
1127
dt2 , err = os .ReadFile (filepath .Join (destDir , "unique" ))
1128
+ expectedStr := string (dt )
1117
1129
require .NoError (t , err )
1118
- require .NotEqual (t , string ( dt ), string (dt2 ))
1130
+ require .NotEqual (t , integration . UnixOrWindows ( expectedStr , expectedStr + " \r \n " ), string (dt2 ))
1119
1131
}
1120
1132
1121
1133
func testEmptyWildcard (t * testing.T , sb integration.Sandbox ) {
@@ -2788,7 +2800,6 @@ ADD %s /dest/
2788
2800
}
2789
2801
2790
2802
func testDockerfileAddArchive (t * testing.T , sb integration.Sandbox ) {
2791
- integration .SkipOnPlatform (t , "windows" )
2792
2803
f := getFrontend (t , sb )
2793
2804
f .RequiresBuildctl (t )
2794
2805
@@ -2807,10 +2818,12 @@ func testDockerfileAddArchive(t *testing.T, sb integration.Sandbox) {
2807
2818
err = tw .Close ()
2808
2819
require .NoError (t , err )
2809
2820
2810
- dockerfile := []byte (`
2811
- FROM scratch
2821
+ baseImage := integration .UnixOrWindows ("scratch" , "nanoserver" )
2822
+
2823
+ dockerfile := []byte (fmt .Sprintf (`
2824
+ FROM %s
2812
2825
ADD t.tar /
2813
- ` )
2826
+ ` , baseImage ) )
2814
2827
2815
2828
dir := integration .Tmpdir (
2816
2829
t ,
@@ -2838,10 +2851,10 @@ ADD t.tar /
2838
2851
err = gz .Close ()
2839
2852
require .NoError (t , err )
2840
2853
2841
- dockerfile = []byte (`
2842
- FROM scratch
2854
+ dockerfile = []byte (fmt . Sprintf ( `
2855
+ FROM %s
2843
2856
ADD t.tar.gz /
2844
- ` )
2857
+ ` , baseImage ) )
2845
2858
2846
2859
dir = integration .Tmpdir (
2847
2860
t ,
@@ -2862,10 +2875,10 @@ ADD t.tar.gz /
2862
2875
require .Equal (t , expectedContent , dt )
2863
2876
2864
2877
// COPY doesn't extract
2865
- dockerfile = []byte (`
2866
- FROM scratch
2878
+ dockerfile = []byte (fmt . Sprintf ( `
2879
+ FROM %s
2867
2880
COPY t.tar.gz /
2868
- ` )
2881
+ ` , baseImage ) )
2869
2882
2870
2883
dir = integration .Tmpdir (
2871
2884
t ,
@@ -2897,9 +2910,9 @@ COPY t.tar.gz /
2897
2910
defer server .Close ()
2898
2911
2899
2912
dockerfile = []byte (fmt .Sprintf (`
2900
- FROM scratch
2913
+ FROM %s
2901
2914
ADD %s /
2902
- ` , server .URL + "/t.tar.gz" ))
2915
+ ` , baseImage , server .URL + "/t.tar.gz" ))
2903
2916
2904
2917
dir = integration .Tmpdir (
2905
2918
t ,
@@ -2920,9 +2933,9 @@ ADD %s /
2920
2933
2921
2934
// https://github.com/moby/buildkit/issues/386
2922
2935
dockerfile = []byte (fmt .Sprintf (`
2923
- FROM scratch
2936
+ FROM %s
2924
2937
ADD %s /newname.tar.gz
2925
- ` , server .URL + "/t.tar.gz" ))
2938
+ ` , baseImage , server .URL + "/t.tar.gz" ))
2926
2939
2927
2940
dir = integration .Tmpdir (
2928
2941
t ,
@@ -4409,13 +4422,21 @@ COPY foo bar
4409
4422
}
4410
4423
4411
4424
func testMultiStageImplicitFrom (t * testing.T , sb integration.Sandbox ) {
4412
- integration .SkipOnPlatform (t , "windows" )
4413
4425
f := getFrontend (t , sb )
4414
4426
4415
- dockerfile := []byte (`
4427
+ dockerfile := []byte (integration .UnixOrWindows (
4428
+ `
4416
4429
FROM scratch
4417
4430
COPY --from=busybox /etc/passwd test
4418
- ` )
4431
+ ` , `
4432
+ FROM nanoserver AS build
4433
+ USER ContainerAdministrator
4434
+ RUN echo test> test
4435
+
4436
+ FROM nanoserver
4437
+ COPY --from=build /test /test
4438
+ ` ,
4439
+ ))
4419
4440
4420
4441
dir := integration .Tmpdir (
4421
4442
t ,
@@ -4444,17 +4465,26 @@ COPY --from=busybox /etc/passwd test
4444
4465
4445
4466
dt , err := os .ReadFile (filepath .Join (destDir , "test" ))
4446
4467
require .NoError (t , err )
4447
- require .Contains (t , string (dt ), "root" )
4468
+ require .Contains (t , string (dt ), integration . UnixOrWindows ( "root" , "test" ) )
4448
4469
4449
4470
// testing masked image will load actual stage
4450
4471
4451
- dockerfile = []byte (`
4472
+ dockerfile = []byte (integration .UnixOrWindows (
4473
+ `
4452
4474
FROM busybox AS golang
4453
4475
RUN mkdir -p /usr/bin && echo -n foo > /usr/bin/go
4454
4476
4455
4477
FROM scratch
4456
4478
COPY --from=golang /usr/bin/go go
4457
- ` )
4479
+ ` , `
4480
+ FROM nanoserver AS golang
4481
+ USER ContainerAdministrator
4482
+ RUN echo foo> go
4483
+
4484
+ FROM nanoserver
4485
+ COPY --from=golang /go /go
4486
+ ` ,
4487
+ ))
4458
4488
4459
4489
dir = integration .Tmpdir (
4460
4490
t ,
@@ -4482,17 +4512,18 @@ COPY --from=golang /usr/bin/go go
4482
4512
}
4483
4513
4484
4514
func testMultiStageCaseInsensitive (t * testing.T , sb integration.Sandbox ) {
4485
- integration .SkipOnPlatform (t , "windows" )
4486
4515
f := getFrontend (t , sb )
4487
4516
4488
- dockerfile := [] byte ( `
4489
- FROM scratch AS STAge0
4517
+ dockerfileStr := `
4518
+ FROM %s AS STAge0
4490
4519
COPY foo bar
4491
- FROM scratch AS staGE1
4520
+ FROM %s AS staGE1
4492
4521
COPY --from=staGE0 bar baz
4493
- FROM scratch
4522
+ FROM %s
4494
4523
COPY --from=stage1 baz bax
4495
- ` )
4524
+ `
4525
+ baseImage := integration .UnixOrWindows ("scratch" , "nanoserver" )
4526
+ dockerfile := []byte (fmt .Sprintf (dockerfileStr , baseImage , baseImage , baseImage ))
4496
4527
dir := integration .Tmpdir (
4497
4528
t ,
4498
4529
fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
@@ -4652,7 +4683,6 @@ RUN dir file1
4652
4683
}
4653
4684
4654
4685
func testOnBuildCleared (t * testing.T , sb integration.Sandbox ) {
4655
- integration .SkipOnPlatform (t , "windows" )
4656
4686
workers .CheckFeatureCompat (t , sb , workers .FeatureDirectPush )
4657
4687
f := getFrontend (t , sb )
4658
4688
@@ -4662,10 +4692,16 @@ func testOnBuildCleared(t *testing.T, sb integration.Sandbox) {
4662
4692
}
4663
4693
require .NoError (t , err )
4664
4694
4665
- dockerfile := []byte (`
4695
+ dockerfile := []byte (integration .UnixOrWindows (
4696
+ `
4666
4697
FROM busybox
4667
4698
ONBUILD RUN mkdir -p /out && echo -n 11 >> /out/foo
4668
- ` )
4699
+ ` , `
4700
+ FROM nanoserver
4701
+ USER ContainerAdministrator
4702
+ ONBUILD RUN mkdir \out && echo 11>> \out\foo
4703
+ ` ,
4704
+ ))
4669
4705
4670
4706
dir := integration .Tmpdir (
4671
4707
t ,
@@ -4725,9 +4761,9 @@ ONBUILD RUN mkdir -p /out && echo -n 11 >> /out/foo
4725
4761
4726
4762
dockerfile = []byte (fmt .Sprintf (`
4727
4763
FROM %s AS base
4728
- FROM scratch
4764
+ FROM %s
4729
4765
COPY --from=base /out /
4730
- ` , target2 ))
4766
+ ` , target2 , integration . UnixOrWindows ( "scratch" , "nanoserver" ) ))
4731
4767
4732
4768
dir = integration .Tmpdir (
4733
4769
t ,
@@ -4751,7 +4787,7 @@ ONBUILD RUN mkdir -p /out && echo -n 11 >> /out/foo
4751
4787
4752
4788
dt , err := os .ReadFile (filepath .Join (destDir , "foo" ))
4753
4789
require .NoError (t , err )
4754
- require .Equal (t , "11" , string (dt ))
4790
+ require .Equal (t , integration . UnixOrWindows ( "11" , "11 \r \n " ) , string (dt ))
4755
4791
}
4756
4792
4757
4793
func testOnBuildNamedContext (t * testing.T , sb integration.Sandbox ) {
@@ -5820,10 +5856,10 @@ COPY --from=build out .
5820
5856
}
5821
5857
5822
5858
func testBuiltinArgs (t * testing.T , sb integration.Sandbox ) {
5823
- integration .SkipOnPlatform (t , "windows" )
5824
5859
f := getFrontend (t , sb )
5825
5860
5826
- dockerfile := []byte (`
5861
+ dockerfile := []byte (integration .UnixOrWindows (
5862
+ `
5827
5863
FROM busybox AS build
5828
5864
ARG FOO
5829
5865
ARG BAR
@@ -5832,7 +5868,18 @@ RUN echo -n $HTTP_PROXY::$NO_PROXY::$FOO::$BAR::$BAZ > /out
5832
5868
FROM scratch
5833
5869
COPY --from=build /out /
5834
5870
5835
- ` )
5871
+ ` , `
5872
+ FROM nanoserver AS build
5873
+ USER ContainerAdministrator
5874
+ ARG FOO
5875
+ ARG BAR
5876
+ ARG BAZ=bazcontent
5877
+ RUN echo %HTTP_PROXY%::%NO_PROXY%::%FOO%::%BAR%::%BAZ%> out
5878
+ FROM nanoserver
5879
+ COPY --from=build out /
5880
+ ` ,
5881
+ ))
5882
+
5836
5883
dir := integration .Tmpdir (
5837
5884
t ,
5838
5885
fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
@@ -5867,7 +5914,9 @@ COPY --from=build /out /
5867
5914
5868
5915
dt , err := os .ReadFile (filepath .Join (destDir , "out" ))
5869
5916
require .NoError (t , err )
5870
- require .Equal (t , "hpvalue::npvalue::foocontents::::bazcontent" , string (dt ))
5917
+ // Windows can't interpret empty env variables, %BAR% handles empty values.
5918
+ expectedStr := integration .UnixOrWindows (`hpvalue::npvalue::foocontents::::bazcontent` , "hpvalue::npvalue::foocontents::%BAR%::bazcontent\r \n " )
5919
+ require .Equal (t , expectedStr , string (dt ))
5871
5920
5872
5921
// repeat with changed default args should match the old cache
5873
5922
destDir = t .TempDir ()
@@ -5894,7 +5943,8 @@ COPY --from=build /out /
5894
5943
5895
5944
dt , err = os .ReadFile (filepath .Join (destDir , "out" ))
5896
5945
require .NoError (t , err )
5897
- require .Equal (t , "hpvalue::npvalue::foocontents::::bazcontent" , string (dt ))
5946
+ expectedStr = integration .UnixOrWindows ("hpvalue::npvalue::foocontents::::bazcontent" , "hpvalue::npvalue::foocontents::%BAR%::bazcontent\r \n " )
5947
+ require .Equal (t , expectedStr , string (dt ))
5898
5948
5899
5949
// changing actual value invalidates cache
5900
5950
destDir = t .TempDir ()
@@ -5921,7 +5971,8 @@ COPY --from=build /out /
5921
5971
5922
5972
dt , err = os .ReadFile (filepath .Join (destDir , "out" ))
5923
5973
require .NoError (t , err )
5924
- require .Equal (t , "hpvalue2::::foocontents2::::bazcontent" , string (dt ))
5974
+ expectedStr = integration .UnixOrWindows ("hpvalue2::::foocontents2::::bazcontent" , "hpvalue2::%NO_PROXY%::foocontents2::%BAR%::bazcontent\r \n " )
5975
+ require .Equal (t , expectedStr , string (dt ))
5925
5976
}
5926
5977
5927
5978
func testTarContext (t * testing.T , sb integration.Sandbox ) {
@@ -6037,15 +6088,15 @@ COPY foo bar
6037
6088
}
6038
6089
6039
6090
func testFrontendUseForwardedSolveResults (t * testing.T , sb integration.Sandbox ) {
6040
- integration .SkipOnPlatform (t , "windows" )
6041
6091
c , err := client .New (sb .Context (), sb .Address ())
6042
6092
require .NoError (t , err )
6043
6093
defer c .Close ()
6044
6094
6045
- dockerfile := [] byte ( `
6046
- FROM scratch
6095
+ dockerfileStr := `
6096
+ FROM %s
6047
6097
COPY foo foo2
6048
- ` )
6098
+ `
6099
+ dockerfile := []byte (fmt .Sprintf (dockerfileStr , integration .UnixOrWindows ("scratch" , "nanoserver" )))
6049
6100
dir := integration .Tmpdir (
6050
6101
t ,
6051
6102
fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
0 commit comments