Skip to content

Commit be40d31

Browse files
committed
Consolidate system update and package installation in Dockerfile
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 11279bf commit be40d31

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

bazel/external/Dockerfile.bazel

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,42 +34,47 @@
3434
# -- //test/...
3535

3636
# Update base image
37-
ARG UBUNTU_VERSION=22.04
38-
FROM ubuntu:${UBUNTU_VERSION} as build
39-
RUN apt update && apt upgrade -y
40-
RUN apt autoremove -y
37+
ARG UBUNTU_VERSION=24.04
38+
FROM ubuntu:${UBUNTU_VERSION} AS build
4139

42-
# Install Bazel deps
43-
RUN apt install -y software-properties-common
44-
RUN add-apt-repository ppa:openjdk-r/ppa
45-
RUN apt install -y \
40+
# Consolidated system update/upgrade and autoremove
41+
RUN apt-get update && \
42+
apt-get upgrade -y && \
43+
apt-get autoremove -y && \
44+
rm -rf /var/lib/apt/lists/*
45+
46+
## All build dependencies for Bazel and ProxyWasm are listed in DEPS for clarity and maintainability.
47+
ARG DEPS="\
4648
build-essential \
49+
clang \
50+
curl \
51+
git \
52+
libssl-dev \
53+
libstdc++6 \
4754
openjdk-21-jdk \
4855
python3 \
49-
curl \
56+
python3-distutils \
57+
software-properties-common \
58+
unzip \
5059
zip \
51-
unzip
60+
libz-dev\
61+
"
62+
RUN apt-get update && \
63+
apt-get install -y --no-install-recommends $DEPS && \
64+
add-apt-repository ppa:openjdk-r/ppa && \
65+
rm -rf /var/lib/apt/lists/*
66+
67+
# Set working directory for Bazel build
68+
WORKDIR /root/bazel
5269

5370
# Download Bazel source
5471
ARG BAZEL_VERSION=7.7.1
55-
RUN cd ~ && mkdir bazel && cd bazel
56-
RUN curl -LO https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-dist.zip
57-
RUN unzip -q bazel-${BAZEL_VERSION}-dist.zip
72+
RUN curl -LO https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-dist.zip && \
73+
unzip -q bazel-${BAZEL_VERSION}-dist.zip
5874

59-
# Build Bazel
60-
# NOTE: This step is flaky and frequently hangs for multiarch / buildx.
61-
# If it takes more than 2 hours, restart the Docker build and try again.
75+
## Build Bazel and copy the binary
76+
# NOTE: This step is flaky and may hang for multiarch/buildx.
77+
# If it takes more than 2 hours, restart the Docker build.
6278
ENV EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk"
63-
RUN bash ./compile.sh
64-
65-
# Copy output to /usr/bin
66-
RUN cp /output/bazel /usr/bin/bazel
67-
68-
# Install ProxyWasm build deps
69-
RUN apt install -y \
70-
git \
71-
python3-distutils \
72-
clang \
73-
libstdc++6 \
74-
libssl-dev \
75-
libz-dev
79+
RUN bash ./compile.sh && \
80+
cp /output/bazel /usr/bin/bazel

0 commit comments

Comments
 (0)