@@ -527,6 +527,7 @@ public async Task BuildCommand_Publish()
527527 TagInfo . GetFullyQualifiedName ( repoName , sharedTag )
528528 } ,
529529 It . IsAny < IDictionary < string , string > > ( ) ,
530+ It . IsAny < IEnumerable < string > > ( ) ,
530531 It . IsAny < bool > ( ) ,
531532 It . IsAny < bool > ( ) ) ) ;
532533
@@ -694,6 +695,61 @@ public async Task BuildCommand_BuildArgs()
694695 It . IsAny < List < string > > ( ) ,
695696 It . Is < Dictionary < string , string > > (
696697 args => args . Count == 3 && args [ "arg1" ] == "val1" && args [ "arg2" ] == "val2b" && args [ "arg3" ] == "val3" ) ,
698+ It . IsAny < IEnumerable < string > > ( ) ,
699+ It . IsAny < bool > ( ) ,
700+ It . IsAny < bool > ( ) ) ) ;
701+ dockerServiceMock . Verify (
702+ o => o . GetImageSize ( It . IsAny < string > ( ) , false ) ) ;
703+ }
704+
705+ /// <summary>
706+ /// Verifies that Docker build options can be passed through to the Docker build command.
707+ /// </summary>
708+ [ Fact ]
709+ public async Task BuildCommand_DockerBuildOptions ( )
710+ {
711+ const string repoName = "runtime" ;
712+ const string tag = "tag" ;
713+ const string baseImageRepo = "baserepo" ;
714+ string baseImageTag = $ "{ baseImageRepo } :basetag";
715+
716+ using TempFolderContext tempFolderContext = TestHelper . UseTempFolder ( ) ;
717+ Mock < IDockerService > dockerServiceMock = CreateDockerServiceMock ( ) ;
718+
719+ BuildCommand command = CreateBuildCommand (
720+ dockerService : dockerServiceMock . Object ,
721+ copyImageService : Mock . Of < ICopyImageService > ( ) ,
722+ manifestServiceFactory : CreateManifestServiceFactoryMock ( ) . Object ,
723+ imageCacheService : new ImageCacheService ( Mock . Of < ILogger < ImageCacheService > > ( ) , Mock . Of < IGitService > ( ) ) ) ;
724+ command . Options . Manifest = Path . Combine ( tempFolderContext . Path , "manifest.json" ) ;
725+ command . Options . DockerBuildOptions = [ "--ulimit nofile=65536:65536" , "--network host" ] ;
726+
727+ Platform platform = CreatePlatform (
728+ DockerfileHelper . CreateDockerfile ( "1.0/runtime/os" , tempFolderContext , baseImageTag ) ,
729+ new string [ ] { tag } ) ;
730+
731+ Manifest manifest = CreateManifest (
732+ CreateRepo ( repoName ,
733+ CreateImage (
734+ new Platform [ ]
735+ {
736+ platform
737+ } ) )
738+ ) ;
739+
740+ File . WriteAllText ( Path . Combine ( tempFolderContext . Path , command . Options . Manifest ) , JsonConvert . SerializeObject ( manifest ) ) ;
741+
742+ command . LoadManifest ( ) ;
743+ await command . ExecuteAsync ( ) ;
744+
745+ dockerServiceMock . Verify (
746+ o => o . BuildImage (
747+ It . IsAny < string > ( ) ,
748+ It . IsAny < string > ( ) ,
749+ It . IsAny < string > ( ) ,
750+ It . IsAny < List < string > > ( ) ,
751+ It . IsAny < IDictionary < string , string > > ( ) ,
752+ It . Is < IEnumerable < string > > ( args => args . SequenceEqual ( command . Options . DockerBuildOptions ) ) ,
697753 It . IsAny < bool > ( ) ,
698754 It . IsAny < bool > ( ) ) ) ;
699755 dockerServiceMock . Verify (
@@ -757,6 +813,7 @@ public async Task BuildCommand_NoBaseImage_Build()
757813 TagInfo . GetFullyQualifiedName ( repoName , sharedTag )
758814 } ,
759815 It . IsAny < IDictionary < string , string > > ( ) ,
816+ It . IsAny < IEnumerable < string > > ( ) ,
760817 It . IsAny < bool > ( ) ,
761818 It . IsAny < bool > ( ) ) ) ;
762819 dockerServiceMock . Verify (
@@ -949,7 +1006,7 @@ public async Task BuildCommand_NoBaseImage_Cached()
9491006 o . BuildImage (
9501007 PathHelper . NormalizePath ( Path . Combine ( tempFolderContext . Path , runtimeDepsLinuxDockerfileRelativePath ) ) ,
9511008 It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < IEnumerable < string > > ( ) , It . IsAny < IDictionary < string , string > > ( ) ,
952- It . IsAny < bool > ( ) , It . IsAny < bool > ( ) ) ,
1009+ It . IsAny < IEnumerable < string > > ( ) , It . IsAny < bool > ( ) , It . IsAny < bool > ( ) ) ,
9531010 Times . Never ) ;
9541011 dockerServiceMock . Verify (
9551012 o => o . GetImageSize ( It . IsAny < string > ( ) , false ) ,
@@ -1679,7 +1736,7 @@ public async Task BuildCommand_Caching_SharedDockerfile_MissingSourceImageInfoEn
16791736 dockerServiceMock . Verify ( o =>
16801737 o . BuildImage (
16811738 It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < IEnumerable < string > > ( ) ,
1682- It . IsAny < IDictionary < string , string > > ( ) , It . IsAny < bool > ( ) , It . IsAny < bool > ( ) ) ,
1739+ It . IsAny < IDictionary < string , string > > ( ) , It . IsAny < IEnumerable < string > > ( ) , It . IsAny < bool > ( ) , It . IsAny < bool > ( ) ) ,
16831740 Times . Never ) ;
16841741
16851742 dockerServiceMock . VerifyNoOtherCalls ( ) ;
@@ -1987,6 +2044,7 @@ public async Task BuildCommand_Caching_SharedDockerfile_MissingSourceImageInfoEn
19872044 It . IsAny < string > ( ) ,
19882045 It . IsAny < IEnumerable < string > > ( ) ,
19892046 It . IsAny < IDictionary < string , string > > ( ) ,
2047+ It . IsAny < IEnumerable < string > > ( ) ,
19902048 It . IsAny < bool > ( ) ,
19912049 It . IsAny < bool > ( ) ) ) ;
19922050 dockerServiceMock . Verify ( o => o . GetImageSize ( $ "{ runtimeDeps3Repo } :{ tag } ", false ) ) ;
@@ -2193,6 +2251,7 @@ public async Task BuildCommand_Caching_SharedDockerfile_NoExistingImageInfoEntri
21932251 It . IsAny < string > ( ) ,
21942252 new string [ ] { expectedTag } ,
21952253 It . IsAny < IDictionary < string , string > > ( ) ,
2254+ It . IsAny < IEnumerable < string > > ( ) ,
21962255 It . IsAny < bool > ( ) ,
21972256 It . IsAny < bool > ( ) ) ,
21982257 Times . Once ) ;
@@ -2436,6 +2495,7 @@ public async Task BuildCommand_SharedDockerfile()
24362495 It . IsAny < string > ( ) ,
24372496 new string [ ] { expectedTag } ,
24382497 It . IsAny < IDictionary < string , string > > ( ) ,
2498+ It . IsAny < IEnumerable < string > > ( ) ,
24392499 It . IsAny < bool > ( ) ,
24402500 It . IsAny < bool > ( ) ) ,
24412501 Times . Once ) ;
@@ -2653,7 +2713,7 @@ public async Task BuildCommand_Caching_TagUpdate()
26532713 o . BuildImage (
26542714 PathHelper . NormalizePath ( Path . Combine ( tempFolderContext . Path , runtimeDepsLinuxDockerfileRelativePath ) ) ,
26552715 It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < IEnumerable < string > > ( ) , It . IsAny < IDictionary < string , string > > ( ) ,
2656- It . IsAny < bool > ( ) , It . IsAny < bool > ( ) ) ,
2716+ It . IsAny < IEnumerable < string > > ( ) , It . IsAny < bool > ( ) , It . IsAny < bool > ( ) ) ,
26572717 Times . Never ) ;
26582718 dockerServiceMock . Verify (
26592719 o => o . GetImageSize ( It . IsAny < string > ( ) , false ) ,
@@ -2912,7 +2972,7 @@ public async Task BuildCommand_Caching_SharedDockerfile_TagUpdate()
29122972 dockerServiceMock . Verify ( o =>
29132973 o . BuildImage (
29142974 It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < IEnumerable < string > > ( ) ,
2915- It . IsAny < IDictionary < string , string > > ( ) , It . IsAny < bool > ( ) , It . IsAny < bool > ( ) ) ,
2975+ It . IsAny < IDictionary < string , string > > ( ) , It . IsAny < IEnumerable < string > > ( ) , It . IsAny < bool > ( ) , It . IsAny < bool > ( ) ) ,
29162976 Times . Never ) ;
29172977 dockerServiceMock . Verify ( o => o . GetCreatedDate ( It . IsAny < string > ( ) , false ) ) ;
29182978
@@ -3272,6 +3332,7 @@ public async Task BuildCommand_MirroredImages(bool hasCachedImage, string srcBas
32723332 It . IsAny < string > ( ) ,
32733333 It . IsAny < IEnumerable < string > > ( ) ,
32743334 It . IsAny < IDictionary < string , string > > ( ) ,
3335+ It . IsAny < IEnumerable < string > > ( ) ,
32753336 It . IsAny < bool > ( ) ,
32763337 It . IsAny < bool > ( ) ) ) ;
32773338
@@ -3417,6 +3478,7 @@ public async Task BuildCommand_MirroredImages_External(string baseImageRegistry,
34173478 It . IsAny < string > ( ) ,
34183479 It . IsAny < IEnumerable < string > > ( ) ,
34193480 It . IsAny < IDictionary < string , string > > ( ) ,
3481+ It . IsAny < IEnumerable < string > > ( ) ,
34203482 It . IsAny < bool > ( ) ,
34213483 It . IsAny < bool > ( ) ) ) ;
34223484 dockerServiceMock . Verify ( o => o . GetImageSize ( $ "{ RegistryOverride } /{ SamplesRepo } :{ Tag } ", false ) ) ;
@@ -3558,6 +3620,7 @@ public async Task BuildCommand_MirroredImages_BaseImageTagOverride()
35583620 It . IsAny < string > ( ) ,
35593621 It . IsAny < IEnumerable < string > > ( ) ,
35603622 It . IsAny < IDictionary < string , string > > ( ) ,
3623+ It . IsAny < IEnumerable < string > > ( ) ,
35613624 It . IsAny < bool > ( ) ,
35623625 It . IsAny < bool > ( ) ) ) ;
35633626 dockerServiceMock . Verify (
@@ -3621,6 +3684,7 @@ private static Mock<IDockerService> CreateDockerServiceMock(string buildOutput =
36213684 It . IsAny < string > ( ) ,
36223685 It . IsAny < IEnumerable < string > > ( ) ,
36233686 It . IsAny < IDictionary < string , string > > ( ) ,
3687+ It . IsAny < IEnumerable < string > > ( ) ,
36243688 It . IsAny < bool > ( ) ,
36253689 It . IsAny < bool > ( ) ) )
36263690 . Returns ( buildOutput ?? string . Empty ) ;
0 commit comments