Skip to content

Commit edfe7ab

Browse files
committed
(docker) - added ability to build a specific distro/target
1 parent 6814b0a commit edfe7ab

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

build.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ The build script to execute.
1919
The build script target to run.
2020
.PARAMETER Configuration
2121
The build configuration to use.
22+
.PARAMETER DockerDistro
23+
The docker ditro to use.
24+
.PARAMETER DockerDotnetVersion
25+
The dotnet version for docker to use.
2226
.PARAMETER Verbosity
2327
Specifies the amount of information to be displayed.
2428
.PARAMETER WhatIf
@@ -36,6 +40,8 @@ Param(
3640
[string]$Script = "build.cake",
3741
[string]$Target = "Default",
3842
[string]$Configuration = "Release",
43+
[string]$DockerDistro = "",
44+
[string]$DockerDotnetVersion = "",
3945
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
4046
[string]$Verbosity = "Verbose",
4147
[Alias("DryRun","Noop")]
@@ -184,6 +190,8 @@ $Arguments = @{
184190
verbosity=$Verbosity;
185191
dryrun=$WhatIf;
186192
nuget_useinprocessclient=$true;
193+
docker_distro=$DockerDistro;
194+
docker_dotnetversion=$DockerDotnetVersion;
187195
}.GetEnumerator() | ForEach-Object { "--{0}=`"{1}`"" -f $_.key, $_.value };
188196

189197
# Start Cake

build/utils/artifacts.cake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ public class DockerImages
114114
}
115115
}
116116

117+
if (!string.IsNullOrEmpty(parameters.DockerDistro)) {
118+
dockerImages = dockerImages.Where(x => x.Distro == parameters.DockerDistro).ToList();
119+
}
120+
121+
if (!string.IsNullOrEmpty(parameters.DockerDotnetVersion)) {
122+
dockerImages = dockerImages.Where(x => x.TargetFramework == $"netcoreapp{parameters.DockerDotnetVersion}").ToList();
123+
}
124+
117125
var windowsImages = dockerImages.Where(x => x.OS == "windows").ToArray();
118126
var linuxImages = dockerImages.Where(x => x.OS == "linux").ToArray();
119127

build/utils/docker.cake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ void DockerBuild(DockerImage dockerImage, BuildParameters parameters)
4141
Rm = true,
4242
Tag = tags,
4343
File = $"{workDir}/Dockerfile",
44-
BuildArg = new []{ $"contentFolder=/content", "DOTNET_VARIANT=runtime", $"DOTNET_VERSION={targetframework.Replace("netcoreapp", "")}", $"DISTRO={distro}" },
44+
BuildArg = new []
45+
{
46+
$"contentFolder=/content",
47+
"DOTNET_VARIANT=runtime",
48+
$"DOTNET_VERSION={targetframework.Replace("netcoreapp", "")}",
49+
$"DISTRO={distro}"
50+
},
4551
// Pull = true,
4652
// Platform = platform // TODO this one is not supported on docker versions < 18.02
4753
};

build/utils/parameters.cake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ public class BuildParameters
1111
public string CoreFxVersion { get; private set; } = "netcoreapp2.1";
1212
public string FullFxVersion { get; private set; } = "net461";
1313

14+
public string DockerDistro { get; private set; }
15+
public string DockerDotnetVersion { get; private set; }
16+
1417
public bool EnabledUnitTests { get; private set; }
1518
public bool EnabledPublishGem { get; private set; }
1619
public bool EnabledPublishVsix { get; private set; }
@@ -70,6 +73,9 @@ public class BuildParameters
7073
Target = target,
7174
Configuration = context.Argument("configuration", "Release"),
7275

76+
DockerDistro = context.Argument("docker_distro", ""),
77+
DockerDotnetVersion = context.Argument("docker_dotnetversion", ""),
78+
7379
EnabledUnitTests = IsEnabled(context, "ENABLED_UNIT_TESTS"),
7480
EnabledPublishGem = IsEnabled(context, "ENABLED_PUBLISH_GEM"),
7581
EnabledPublishVsix = IsEnabled(context, "ENABLED_PUBLISH_VSIX"),

0 commit comments

Comments
 (0)