Skip to content

Commit c4372eb

Browse files
authored
fix(googleapis): build bazelisk using rolling Go version (#564)
1 parent e8b0242 commit c4372eb

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

infrastructure/googleapis/Dockerfile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,21 @@ RUN apt-get update && \
2727

2828
RUN mkdir -p /tools
2929

30-
# Download and install Bazelisk, a wrapper around Bazel.
31-
ADD https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VERSION}/bazelisk-linux-amd64 /tools/bazelisk
30+
# Bootstrap modern version of Go. The bookwork tag is associated with debian,
31+
# our base image, and the 1.26 tag is the Go minor version to capture rolling
32+
# patch updates for.
33+
COPY --from=golang:1.26-bookworm /usr/local/go /usr/local/go
34+
35+
# Build Bazelisk from source with modern version of Go to avoid using out of
36+
# date Go in the binary.
37+
# Removes the Go binary we installed previously so as to not leak it into
38+
# dependent jobs that may want to install their own version of Go.
39+
RUN export PATH="/usr/local/go/bin:${PATH}" && \
40+
git clone https://github.com/bazelbuild/bazelisk.git /tmp/bazelisk && \
41+
cd /tmp/bazelisk && \
42+
git checkout v${BAZELISK_VERSION} && \
43+
go build -o /tools/bazelisk && \
44+
rm -rf /tmp/bazelisk /usr/local/go
3245

3346
ADD https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-linux-x86_64 /tools/bazel
3447
# Make the tools executable. These operations are performed in separate

0 commit comments

Comments
 (0)