diff --git a/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs b/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs index c8901ef..bfd0fbd 100644 --- a/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs +++ b/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs @@ -13,6 +13,7 @@ using Nuke.Common.Tooling; using Nuke.Common.Tools.Docker; using Nuke.Common.Tools.DotNet; +using Nuke.Common.Utilities.Collections; using Serilog; using VirtoCloud.Client.Api; using VirtoCloud.Client.Model; @@ -171,7 +172,7 @@ private async Task PrepareDockerContextMethod() DockerImageName = $"{DockerUsername}/{EnvironmentName.ToLowerInvariant()}"; } - DockerImageTag ??= DateTime.Now.ToString("MMddyyHHmmss"); + DockerImageTag ??= new string[] { DateTime.Now.ToString("MMddyyHHmmss") }; DockerfilePath = dockerfilePath; DiscoveryPath = modulesPath; ProbingPath = Path.Combine(platformDirectory, "app_data", "modules"); @@ -263,7 +264,7 @@ private static void CopyPlatformDirectory(AbsolutePath platformDirectory, Absolu var envHelmParameters = env.Helm.Parameters; envHelmParameters["platform.image.repository"] = DockerImageName; - envHelmParameters["platform.image.tag"] = DockerImageTag; + envHelmParameters["platform.image.tag"] = DockerImageTag[0]; await cloudClient.UpdateEnvironmentAsync(env); }); @@ -375,9 +376,9 @@ private void SaveCloudToken(string token) model.Helm.Parameters["platform.image.repository"] = DockerImageName; } - if(!string.IsNullOrEmpty(DockerImageTag)) + if(!DockerImageTag.IsNullOrEmpty()) { - model.Helm.Parameters["platform.image.tag"] = DockerImageTag; + model.Helm.Parameters["platform.image.tag"] = DockerImageTag[0]; } diff --git a/src/VirtoCommerce.Build/Docker/Build.Docker.cs b/src/VirtoCommerce.Build/Docker/Build.Docker.cs index 4f7a7d2..c6306f1 100644 --- a/src/VirtoCommerce.Build/Docker/Build.Docker.cs +++ b/src/VirtoCommerce.Build/Docker/Build.Docker.cs @@ -1,6 +1,9 @@ +using System.Collections.Generic; +using System.Linq; using Nuke.Common; using Nuke.Common.Tools.Docker; using Nuke.Common.Utilities; +using Nuke.Common.Utilities.Collections; using Serilog; namespace VirtoCommerce.Build @@ -26,11 +29,27 @@ public static string DockerUsername [Parameter("Docker Password")] public static string DockerPassword { get; set; } [Parameter("Docker Registry Url")] public static string DockerRegistryUrl { get; set; } [Parameter("Docker Image Name")] public static string DockerImageName { get; set; } - [Parameter("Docker Image Tag")] public static string DockerImageTag { get; set; } + [Parameter("Docker Image Tag")] public static string[] DockerImageTag { get; set; } [Parameter("Dockerfile Path")] public static string DockerfilePath { get; set; } [Parameter("Docker build context path")] public static string DockerBuildContextPath { get; set; } - private static string DockerImageFullName => string.IsNullOrEmpty(DockerImageTag) ? DockerImageName : DockerImageName.Append($":{DockerImageTag}"); + private static string[] DockerImageFullName + { + get + { + if (DockerImageTag.IsNullOrEmpty()) + { + return new string[] { DockerImageName }; + } + + var result = new List(); + foreach(var tag in DockerImageTag) + { + result.Add(DockerImageName.Append($":{tag}")); + } + return result.ToArray(); + } + } public static bool DockerCredentialsPassed => !string.IsNullOrEmpty(DockerUsername) && !string.IsNullOrEmpty(DockerPassword); Target DockerLogin => _ => _ @@ -64,9 +83,21 @@ public static string DockerUsername .DependsOn(DockerLogin) .Executes(() => { - var settings = new DockerImagePushSettings() - .SetName(DockerImageFullName); + DockerImagePushSettings settings; + if(DockerImageTag?.Length > 1) + { + settings = new DockerImagePushSettings() + .SetName(DockerImageName) + .SetAllTags(true); + } + else + { + settings = new DockerImagePushSettings() + .SetName(DockerImageFullName[0]); + } + DockerTasks.DockerImagePush(settings); + }); public Target BuildAndPush => _ => _