1717# Stage 1: build k9db from source.
1818##############################################################################
1919FROM ubuntu:24.04 AS build
20+ ARG TARGETARCH
2021
2122ENV DEBIAN_FRONTEND=noninteractive
2223ENV LANG=C.UTF-8
@@ -31,7 +32,7 @@ RUN apt-get update && apt-get install -y \
3132 apt-utils libssl-dev lsb-release openssl git \
3233 build-essential zlib1g-dev libbz2-dev liblzma-dev libffi-dev \
3334 wget gcc-11 g++-11 unzip zip pkg-config \
34- openjdk-11-jdk curl libclang-dev libevent-dev \
35+ openjdk-11-jdk curl libclang-dev clang libevent-dev \
3536 libsnappy-dev python3 python3-dev
3637
3738RUN ln -sf /usr/bin/python3 /usr/bin/python
@@ -43,12 +44,19 @@ RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 90 \
4344 --slave /usr/bin/g++ g++ /usr/bin/g++-11 \
4445 && update-alternatives --set gcc /usr/bin/gcc-11
4546
46- # Install bazel 4.0.
47- RUN cd /tmp \
48- && wget https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-installer-linux-x86_64.sh \
49- && chmod +x bazel-4.0.0-installer-linux-x86_64.sh \
50- && ./bazel-4.0.0-installer-linux-x86_64.sh \
51- && rm bazel-4.0.0-installer-linux-x86_64.sh
47+ # Install bazel 4.0. No installer script is published for linux-arm64, so
48+ # download the standalone binary directly on arm64.
49+ RUN if [ "$TARGETARCH" = "arm64" ]; then \
50+ wget -O /usr/local/bin/bazel \
51+ https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-linux-arm64 \
52+ && chmod +x /usr/local/bin/bazel; \
53+ else \
54+ cd /tmp \
55+ && wget https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-installer-linux-x86_64.sh \
56+ && chmod +x bazel-4.0.0-installer-linux-x86_64.sh \
57+ && ./bazel-4.0.0-installer-linux-x86_64.sh \
58+ && rm bazel-4.0.0-installer-linux-x86_64.sh; \
59+ fi
5260
5361# Copy sources (see .dockerignore for exclusions). The bazel rules for the
5462# proxy's rust dependencies (k9db/proxy/cargo/) are vendored in the repo, so
@@ -75,6 +83,7 @@ RUN BIN="$(bazel info bazel-bin --config opt)" \
7583# Stage 2: minimal runtime image.
7684##############################################################################
7785FROM ubuntu:24.04 AS runtime
86+ ARG TARGETARCH
7887
7988ENV DEBIAN_FRONTEND=noninteractive
8089ENV LANG=C.UTF-8
@@ -91,7 +100,8 @@ COPY --from=build /opt/k9db /opt/k9db
91100# the working directory, so this must be /opt/k9db.
92101WORKDIR /opt/k9db
93102
94- ENV LD_LIBRARY_PATH=/opt/k9db/lib:/usr/lib/jvm/java-11-openjdk-amd64/lib/server:/usr/lib/jvm/java-11-openjdk-amd64/lib
103+ # The jvm directory suffix matches docker's TARGETARCH (amd64/arm64).
104+ ENV LD_LIBRARY_PATH=/opt/k9db/lib:/usr/lib/jvm/java-11-openjdk-${TARGETARCH}/lib/server:/usr/lib/jvm/java-11-openjdk-${TARGETARCH}/lib
95105# Send glog output to the container log instead of files in /tmp.
96106ENV GLOG_logtostderr=1
97107
0 commit comments