Skip to content

Commit

Permalink
Use bazelisk as a bazel launcher in Dockerfile
Browse files Browse the repository at this point in the history
bazelisk [1] is a wrapper around bazel that allows you to use different
versions of bazel without having to install them all. This is useful
for testing different versions of bazel or for using a specific version
of bazel that is not available in the default repository.

Let's update Dockerfile to use bazelisk instead of bazel. This will
allow us to avoid a tricky question on which version of bazel should be
installed in the Docker container by checking in '.bazeliskrc' into the
repository.

Note that switching to recent versions of bazel is also necessary due to
our migration to bzlmod (#1002). Probably bazel 7.3 or later is
currently required to build Mozc with bazel.

 [1]: https://github.com/bazelbuild/bazelisk

#codehealth

PiperOrigin-RevId: 680750168
  • Loading branch information
yukawa authored and hiroyuki-komatsu committed Sep 30, 2024
1 parent ade798c commit 032535d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions docker/ubuntu22.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,22 @@ RUN apt-get update && apt-get install -y \
curl gnupg libncurses5 \
&& rm -rf /var/lib/apt/lists/*

## For Bazel
## https://bazel.build/install/ubuntu#install-on-ubuntu
RUN curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > /usr/share/keyrings/bazel-archive-keyring.gpg
RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
RUN apt-get update && apt-get install -y bazel && rm -rf /var/lib/apt/lists/*

# Working environemnt
ENV HOME /home/mozc_builder
RUN useradd --create-home --shell /bin/bash --base-dir /home mozc_builder
USER mozc_builder
RUN mkdir -p /home/mozc_builder/bin
ENV PATH "${PATH}:/home/mozc_builder/bin"
RUN mkdir -p /home/mozc_builder/work
WORKDIR /home/mozc_builder/work
## Work around https://bugreports.qt.io/browse/QTBUG-86080 for Ubuntu 22.04
ENV PKG_CONFIG_PATH="/home/mozc_builder/work/mozc/docker/ubuntu22.04/qt6-core-pkgconfig:${PKG_CONFIG_PATH}"

## Set up bazelisk as bazel
RUN curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.22.0/bazelisk-linux-amd64 \
&& mv bazelisk-linux-amd64 /home/mozc_builder/bin/bazel \
&& chmod u+x /home/mozc_builder/bin/bazel

## Set up Android SDK and NDK
ENV ANDROID_HOME /home/mozc_builder/Android/Sdk
RUN mkdir -p ${ANDROID_HOME}
Expand Down
8 changes: 4 additions & 4 deletions docker/ubuntu24.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ ENV PATH "${PATH}:/home/mozc_builder/bin"
RUN mkdir -p /home/mozc_builder/work
WORKDIR /home/mozc_builder/work

## Set up Bazel
RUN curl -LO https://github.com/bazelbuild/bazel/releases/download/7.1.1/bazel-7.1.1-installer-linux-x86_64.sh \
&& bash bazel-7.1.1-installer-linux-x86_64.sh --user \
&& rm bazel-7.1.1-installer-linux-x86_64.sh
## Set up bazelisk as bazel
RUN curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.22.0/bazelisk-linux-amd64 \
&& mv bazelisk-linux-amd64 /home/mozc_builder/bin/bazel \
&& chmod u+x /home/mozc_builder/bin/bazel

## Set up Android SDK and NDK
ENV ANDROID_HOME /home/mozc_builder/Android/Sdk
Expand Down

0 comments on commit 032535d

Please sign in to comment.