Skip to content

Commit

Permalink
Debian 12 Docker Image for Kubernetes Tentacle (#997)
Browse files Browse the repository at this point in the history
* Change image to build Debian 12 by default

* Also build a Debian 11 version to support SHA1 issue on Windows 2012
  • Loading branch information
kevjt authored Sep 13, 2024
1 parent ab76266 commit a060e65
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
23 changes: 17 additions & 6 deletions build/Build.Pack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

partial class Build
{
const string KubernetesTentacleContainerRuntimeDepsTag = "8.0-bookworm-slim";

//We don't sign linux packages when building locally
readonly bool SignLinuxPackages = !IsLocalBuild;

Expand Down Expand Up @@ -151,7 +153,10 @@ void CreateLinuxPackages(string runtimeId)
.Description("Builds and pushes the kubernetes tentacle multi-arch container image")
.Executes(() =>
{
BuildAndPushOrLoadKubernetesTentacleContainerImage(push: true, load: false, "docker.packages.octopushq.com");
//Debian 12
BuildAndPushOrLoadKubernetesTentacleContainerImage(push: true, load: false, KubernetesTentacleContainerRuntimeDepsTag, "docker.packages.octopushq.com");
//Debian 11
BuildAndPushOrLoadKubernetesTentacleContainerImage(push: true, load: false, "6.0-bullseye-slim", "docker.packages.octopushq.com", tagSuffix: "bullseye-slim");
});

[PublicAPI]
Expand All @@ -161,7 +166,7 @@ void CreateLinuxPackages(string runtimeId)
.DependsOn(PackDebianPackage)
.Executes(() =>
{
BuildAndPushOrLoadKubernetesTentacleContainerImage(push: false, load: true);
BuildAndPushOrLoadKubernetesTentacleContainerImage(push: false, load: true, KubernetesTentacleContainerRuntimeDepsTag);
});

[PublicAPI]
Expand All @@ -175,7 +180,7 @@ void CreateLinuxPackages(string runtimeId)
const int port = 32000;
var hostPort = $"{host}:{port}";
BuildAndPushOrLoadKubernetesTentacleContainerImage(push: true, load: false, host: hostPort);
BuildAndPushOrLoadKubernetesTentacleContainerImage(push: true, load: false, KubernetesTentacleContainerRuntimeDepsTag, host: hostPort);
});

[PublicAPI]
Expand All @@ -185,7 +190,7 @@ void CreateLinuxPackages(string runtimeId)
.DependsOn(PackDebianPackage)
.Executes(() =>
{
BuildAndPushOrLoadKubernetesTentacleContainerImage(push: false, load: true, includeDebugger: true);
BuildAndPushOrLoadKubernetesTentacleContainerImage(push: false, load: true, KubernetesTentacleContainerRuntimeDepsTag, includeDebugger: true);
});

[PublicAPI]
Expand Down Expand Up @@ -565,7 +570,7 @@ void PackTarballs(string framework, string runtimeId)
$"tentacle-{FullSemVer}-{framework}-{runtimeId}.tar.gz");
}

void BuildAndPushOrLoadKubernetesTentacleContainerImage(bool push, bool load, string? host = null, bool includeDebugger = false)
void BuildAndPushOrLoadKubernetesTentacleContainerImage(bool push, bool load, string runtimeDepsImageTag, string? host = null, bool includeDebugger = false, string? tagSuffix = null)
{
var hostPrefix = host is not null ? $"{host}/" : string.Empty;
DockerTasks.DockerBuildxBuild(settings =>
Expand All @@ -581,11 +586,17 @@ void BuildAndPushOrLoadKubernetesTentacleContainerImage(bool push, bool load, st
: "./docker/kubernetes-agent-tentacle/dev/Dockerfile";
var tag = $"{hostPrefix}octopusdeploy/kubernetes-agent-tentacle:{FullSemVer}";
if (!string.IsNullOrEmpty(tagSuffix))
{
tag += $"-{tagSuffix}";
}
if (includeDebugger)
tag += "-debug";
settings = settings
.AddBuildArg($"BUILD_NUMBER={FullSemVer}", $"BUILD_DATE={DateTime.UtcNow:O}")
.AddBuildArg($"BUILD_NUMBER={FullSemVer}", $"BUILD_DATE={DateTime.UtcNow:O}", $"RuntimeDepsTag={runtimeDepsImageTag}")
.SetPlatform(DockerPlatform)
.SetTag(tag)
.SetFile(dockerfile)
Expand Down
6 changes: 5 additions & 1 deletion docker/kubernetes-agent-tentacle/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ARG RuntimeDepsTag


FROM golang:1.22 as bootstrapRunnerBuilder

ARG TARGETARCH
Expand All @@ -9,7 +12,8 @@ WORKDIR /bootstrapRunner
# Note: the given ldflags remove debug symbols
RUN go build -ldflags "-s -w" -o "bin/bootstrapRunner"

FROM mcr.microsoft.com/dotnet/runtime-deps:6.0

FROM mcr.microsoft.com/dotnet/runtime-deps:$RuntimeDepsTag

ARG BUILD_NUMBER
ARG BUILD_DATE
Expand Down
6 changes: 5 additions & 1 deletion docker/kubernetes-agent-tentacle/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ARG RuntimeDepsTag


FROM golang:1.22 as bootstrapRunnerBuilder

ARG TARGETARCH
Expand All @@ -9,7 +12,8 @@ WORKDIR /bootstrapRunner
# Note: the given ldflags remove debug symbols
RUN go build -ldflags "-s -w" -o "bin/bootstrapRunner"

FROM mcr.microsoft.com/dotnet/runtime-deps:6.0

FROM mcr.microsoft.com/dotnet/runtime-deps:$RuntimeDepsTag

ARG BUILD_NUMBER
ARG BUILD_DATE
Expand Down

0 comments on commit a060e65

Please sign in to comment.