Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(go/base): set GOTOOLCHAIN=local and skip building arm using the base Dockerfile #524

Merged
merged 15 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .buildkite/fpm-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
env:
SETUP_GVM_VERSION: "v0.5.1"
IMAGE_UBUNTU_X86_64: "family/core-ubuntu-2204"
IMAGE_UBUNTU_ARM_64: "core-ubuntu-2004-aarch64"
DOCKER_REGISTRY: "docker.elastic.co"
STAGING_IMAGE: "${DOCKER_REGISTRY}/observability-ci"
MAKEFILE: "fpm"
Expand All @@ -25,3 +26,19 @@ steps:
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"

- label: ":linux: Build FPM / Ubuntu ARM64"
key: "build-ubuntu-arm64"
if: build.env("BUILDKITE_PULL_REQUEST") != "false" || build.source == "ui" || build.branch == "main" || build.branch =~ /^[0-9]+\.[0-9]+$$/
command:
- ".buildkite/scripts/llvm-fpm/build.sh ${MAKEFILE} ${CHANGESET_FILE} ${DOCKER_FILTER_REF}"
- ".buildkite/scripts/llvm-fpm/publish.sh ${MAKEFILE} ${CHANGESET_FILE}"
notify:
- github_commit_status:
context: "Build FPM / Ubuntu arm64"
env:
REPOSITORY: "${STAGING_IMAGE}"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "t4g.large"
6 changes: 3 additions & 3 deletions .buildkite/scripts/llvm-fpm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ makefile=${1}
patterns=${2}
docker_filter_ref=${3}

if ! are_files_changed "$patterns" ; then
exit 0
fi
#if ! are_files_changed "$patterns" ; then
# exit 0
#fi

add_bin_path
with_go "${GOLANG_VERSION}"
Expand Down
6 changes: 3 additions & 3 deletions .buildkite/scripts/llvm-fpm/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ source .buildkite/scripts/common.sh
makefile=${1}
patterns=${2}

if ! are_files_changed "$patterns" ; then
exit 0
fi
#if ! are_files_changed "$patterns" ; then
# exit 0
#fi

add_bin_path
retry 3 make -C ${makefile} push
2 changes: 1 addition & 1 deletion go/Makefile.debian9
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
IMAGES := base main darwin arm armhf npcap
IMAGES := base main darwin armhf npcap
ARM_IMAGES := base-arm
DEBIAN_VERSION := 9
TAG_EXTENSION := -debian9
Expand Down
3 changes: 2 additions & 1 deletion go/base-arm/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ RUN ldd --version
WORKDIR /

RUN mkdir -p /root/.config/go/telemetry && echo "off 2024-08-23" > /root/.config/go/telemetry/mode
ENV GOTOOLCHAIN local
RUN go mod init github.com/elastic/golang-crossbuild-$GOLANG_VERSION-arm \
&& go get . \
&& go env \
&& echo "toolcompile=$(go tool compile -V)" \
&& go build -o /crossbuild /entrypoint.go \
&& CGO_ENABLED=0 GOARCH=arm64 go build -o /crossbuild /entrypoint.go \
&& rm -rf /go/* /root/.cache/* /entrypoint.go

COPY sdks/libpcap-1.8.1.tar.gz .
Expand Down
5 changes: 3 additions & 2 deletions go/base-arm/rootfs/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ by mounting the project inside of a container equipped with cross-compilers.
The root of your project's repo should be mounted at the appropriate location
on the GOPATH which is set to /go.

While executing the build command the following variables with be added to the
environment: GOOS, GOARCH, GOARM, PLATFORM_ID, CC, and CXX.
While executing the build command the following variables will be added to the
environment: GOOS, GOARCH, GOARM, GOTOOLCHAIN=local, PLATFORM_ID, CC, and CXX.
`,
RunE: doBuild,
SilenceUsage: true,
Expand Down Expand Up @@ -104,6 +104,7 @@ func buildEnvironment(platform string) (map[string]string, error) {
"GOOS": goos,
"GOARCH": goarch,
"GOARM": goarm,
"GOTOOLCHAIN": "local", // Disable automatic downloads of toolchains for reproducible builds.
"PLATFORM_ID": platformID,
}

Expand Down
3 changes: 2 additions & 1 deletion go/base/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ RUN ldd --version

WORKDIR /
RUN mkdir -p /root/.config/go/telemetry && echo "off 2024-08-23" > /root/.config/go/telemetry/mode
ENV GOTOOLCHAIN=local
RUN go mod init github.com/elastic/golang-crossbuild-$GOLANG_VERSION \
&& go get . \
&& go env \
&& echo "toolcompile=$(go tool compile -V)" \
&& CGO_ENABLED=0 go build -o /crossbuild /entrypoint.go \
&& CGO_ENABLED=0 GOARCH=amd64 go build -o /crossbuild /entrypoint.go \
&& rm -rf /go/* /root/.cache/* /entrypoint.go

COPY sdks/libpcap-1.8.1.tar.gz .
Expand Down
5 changes: 3 additions & 2 deletions go/base/rootfs/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ by mounting the project inside of a container equipped with cross-compilers.
The root of your project's repo should be mounted at the appropriate location
on the GOPATH which is set to /go.

While executing the build command the following variables with be added to the
environment: GOOS, GOARCH, GOARM, PLATFORM_ID, CC, and CXX.
While executing the build command the following variables will be added to the
environment: GOOS, GOARCH, GOARM, GOTOOLCHAIN=local, PLATFORM_ID, CC, and CXX.
`,
RunE: doBuild,
SilenceUsage: true,
Expand Down Expand Up @@ -104,6 +104,7 @@ func buildEnvironment(platform string) (map[string]string, error) {
"GOOS": goos,
"GOARCH": goarch,
"GOARM": goarm,
"GOTOOLCHAIN": "local", // Disable automatic downloads of toolchains for reproducible builds.
"PLATFORM_ID": platformID,
}

Expand Down