Skip to content

Commit

Permalink
Move bootstrapBuild into Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
scme0 committed Mar 18, 2024
1 parent 23d7750 commit 85793c7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 66 deletions.
4 changes: 0 additions & 4 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
"type": "string",
"description": "Specifies the platforms to build the docker images in. Multiple platforms must be comma-separated. Defaults to 'linux/arm64,linux/amd64'"
},
"GolangContainerImageTag": {
"type": "string",
"description": "The tag to use when building the bootstrapRunner with the Golang Container Image"
},
"Help": {
"type": "boolean",
"description": "Shows the help text for this build assembly"
Expand Down
11 changes: 1 addition & 10 deletions build/Build.Pack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ partial class Build

[Parameter("The version of upx to use when building the bootstrapRunner executable for the Kubernetes Tentacle")] string UpxVersion = "4.2.2";

[Parameter("The tag to use when building the bootstrapRunner with the Golang Container Image")] string GolangContainerImageTag = "1.22";

[PublicAPI]
Target PackOsxTarballs => _ => _
.Description("Packs the OS/X tarballs containing the published binaries.")
Expand Down Expand Up @@ -548,13 +546,6 @@ void PackTarballs(string runtimeId)

void BuildAndPushOrLoadKubernetesTentacleContainerImage(bool push, bool load, string? host = null, bool includeDebugger = false, bool useUpx = true)
{
DockerTasks.DockerRun(settings => settings.EnableRm()
.SetVolume("./docker/kubernetes-tentacle/bootstrapRunner:/usr/src/bootstrapRunner")
.SetWorkdir("/usr/src/bootstrapRunner")
.SetEnv($"UPX_VERSION={UpxVersion}", $"PLATFORMS={DockerPlatform}", $"USE_UPX={useUpx.ToString().ToLowerInvariant()}")
.SetImage($"golang:{GolangContainerImageTag}")
.SetCommand("./build.sh"));

var hostPrefix = host is not null ? $"{host}/" : string.Empty;
DockerTasks.DockerBuildxBuild(settings =>
{
Expand All @@ -573,7 +564,7 @@ void BuildAndPushOrLoadKubernetesTentacleContainerImage(bool push, bool load, st
tag += "-debug";

settings = settings
.AddBuildArg($"BUILD_NUMBER={FullSemVer}", $"BUILD_DATE={DateTime.UtcNow:O}")
.AddBuildArg($"BUILD_NUMBER={FullSemVer}", $"BUILD_DATE={DateTime.UtcNow:O}", $"UPX_VERSION={UpxVersion}")
.SetPlatform(DockerPlatform)
.SetTag(tag)
.SetFile(dockerfile)
Expand Down
25 changes: 24 additions & 1 deletion docker/kubernetes-tentacle/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
FROM golang:1.22 as bootstrapRunnerBuilder

ARG TARGETARCH
ARG TARGETOS
ARG UPX_VERSION="4.2.2"

COPY docker/kubernetes-tentacle/bootstrapRunner/* /bootstrapRunner/
WORKDIR /bootstrapRunner

# need to install xz-utils to unpack upx
RUN apt update
RUN apt install -y xz-utils

#download upx and unpack
RUN curl -OL "https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-${TARGETARCH}_${TARGETOS}.tar.xz"
RUN tar -x -f "upx-${UPX_VERSION}-${TARGETARCH}_${TARGETOS}.tar.xz"

# build bootstrapRunner
# Note: the given ldflags remove debug symbols
RUN go build -ldflags "-s -w" -o "bin/bootstrapRunner"
# upx reduces the size of the exe
RUN "./upx-${UPX_VERSION}-${TARGETARCH}_${TARGETOS}/upx" "bin/bootstrapRunner"

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

ARG BUILD_NUMBER
Expand All @@ -9,7 +32,7 @@ ARG TARGETVARIANT
EXPOSE 10933

COPY docker/kubernetes-tentacle/scripts/* /scripts/
COPY docker/kubernetes-tentacle/bootstrapRunner/bin/bootstrapRunner-${TARGETOS}-${TARGETARCH} /bootstrapRunner
COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/bootstrapRunner /bootstrapRunner
RUN chmod +x /scripts/*.sh

WORKDIR /tmp
Expand Down
51 changes: 0 additions & 51 deletions docker/kubernetes-tentacle/bootstrapRunner/build.sh

This file was deleted.

0 comments on commit 85793c7

Please sign in to comment.