Skip to content

Commit 14f0c0e

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

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

bazel/external/Dockerfile.bazel

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,46 @@
3636
# Update base image
3737
ARG UBUNTU_VERSION=22.04
3838
FROM ubuntu:${UBUNTU_VERSION} as build
39-
RUN apt update && apt upgrade -y
40-
RUN apt autoremove -y
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+
47+
# Install all build dependencies (Bazel + ProxyWasm)
48+
ARG DEPS="\
4649
build-essential \
50+
clang \
51+
curl \
52+
git \
53+
libssl-dev \
54+
libstdc++6 \
4755
openjdk-21-jdk \
4856
python3 \
49-
curl \
57+
python3-distutils \
58+
software-properties-common \
59+
unzip \
5060
zip \
51-
unzip
61+
libz-dev\
62+
"
63+
RUN apt-get update && \
64+
apt-get install -y --no-install-recommends $DEPS && \
65+
add-apt-repository ppa:openjdk-r/ppa && \
66+
rm -rf /var/lib/apt/lists/*
67+
68+
# Set working directory for Bazel build
69+
WORKDIR /root/bazel
5270

5371
# Download Bazel source
5472
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
73+
RUN curl -LO https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-dist.zip && \
74+
unzip -q bazel-${BAZEL_VERSION}-dist.zip
5875

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.
76+
## Build Bazel, copy the binary, then install ProxyWasm build deps
77+
# NOTE: This step is flaky and may hang for multiarch/buildx.
78+
# If it takes more than 2 hours, restart the Docker build.
6279
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
80+
RUN bash ./compile.sh && \
81+
cp /output/bazel /usr/bin/bazel

0 commit comments

Comments
 (0)