Skip to content

Commit 2b91d8b

Browse files
committed
Refactor Dockerfile to install bazelisk and remove Bazel source download steps
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 78526e8 commit 2b91d8b

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

bazel/external/Dockerfile.bazel

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,14 @@ RUN apt-get update && \
6565
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $DEPS && \
6666
rm -rf /var/lib/apt/lists/*
6767

68-
# Set working directory for Bazel build
69-
WORKDIR /root/bazel
68+
# Install bazelisk and set Bazel version
69+
ARG BAZELISK_VERSION=v1.20.0
70+
RUN curl -L -o /usr/local/bin/bazelisk "https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-linux-$(uname -m)" \
71+
&& chmod +x /usr/local/bin/bazelisk \
72+
&& ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel
7073

74+
# Set Bazel version for bazelisk
75+
ENV USE_BAZEL_VERSION=7.7.1
7176

72-
# Download Bazel source and remove zip immediately after extraction
73-
ARG BAZEL_VERSION=7.7.1
74-
RUN curl -LO https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-dist.zip && \
75-
unzip -q bazel-${BAZEL_VERSION}-dist.zip && \
76-
rm -f bazel-${BAZEL_VERSION}-dist.zip
77-
78-
## Build Bazel and copy the binary
79-
# NOTE: This step is flaky and may hang for multiarch/buildx.
80-
# If it takes more than 2 hours, restart the Docker build.
81-
ENV EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk"
82-
RUN ./compile.sh && \
83-
mv /output/bazel /usr/bin/bazel && \
84-
rm -rf /root/bazel
85-
86-
# Ensure a valid working directory after build
77+
# Set a valid working directory
8778
WORKDIR /root

0 commit comments

Comments
 (0)