Skip to content

Commit 5c5ba6a

Browse files
committed
Add Dockerfiles for amd64, arm64, and s390x architectures; update build process
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent da61281 commit 5c5ba6a

File tree

4 files changed

+188
-9
lines changed

4 files changed

+188
-9
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ jobs:
301301
302302
- name: Build local Docker image
303303
if: ${{ startsWith(matrix.run_under, 'docker') }}
304-
run: docker build --platform ${{ matrix.platform }} -f bazel/external/Dockerfile.bazel -t proxy-wasm/build-tools:local-ci .
304+
run: docker build --platform ${{ matrix.platform }} -f bazel/external/Dockerfile.s390x -t proxy-wasm/build-tools:local-ci .
305305

306306
- name: Bazel build/test
307307
shell: bash
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,26 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
1716
# Prep:
1817
# docker run --rm --privileged tonistiigi/binfmt --install all
1918
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
2019
# Need to see "F" flag: cat /proc/sys/fs/binfmt_misc/qemu-*
2120
#
2221
# Build:
23-
# docker buildx build --platform linux/s390x -t $IMAGE -f Dockerfile.bazel
22+
# docker buildx build --platform linux/amd64 -t $IMAGE -f Dockerfile.amd64
2423
#
2524
# Push:
2625
# docker image tag $IMAGE ghcr.io/proxy-wasm/$IMAGE
2726
# docker push ghcr.io/proxy-wasm/$IMAGE
2827
#
2928
# Test:
3029
# docker run --rm --volume $(pwd):/mnt --workdir /mnt \
31-
# --platform linux/s390x $IMAGE \
30+
# --platform linux/amd64 $IMAGE \
3231
# bazel test --verbose_failures --test_output=errors \
3332
# --define engine=null --config=clang --test_timeout=1800 \
3433
# -- //test/...
3534

36-
# Update base image
35+
# Stage 1: main build image
3736
ARG UBUNTU_VERSION=24.04
3837
FROM ubuntu:${UBUNTU_VERSION} AS build
3938

@@ -65,11 +64,12 @@ RUN apt-get update && \
6564
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $DEPS && \
6665
rm -rf /var/lib/apt/lists/*
6766

68-
# Install bazelisk and set Bazel version
67+
# Install bazelisk: use binary for amd64
6968
ARG BAZELISK_VERSION=v1.27.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
69+
RUN ARCH=$(uname -m) && \
70+
curl -L -o /usr/local/bin/bazelisk "https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-linux-$ARCH" && \
71+
chmod +x /usr/local/bin/bazelisk && \
72+
ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel
7373

7474
# Set a valid working directory
7575
WORKDIR /root

bazel/external/Dockerfile.arm64

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# syntax=docker/dockerfile:1
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Prep:
17+
# docker run --rm --privileged tonistiigi/binfmt --install all
18+
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
19+
# Need to see "F" flag: cat /proc/sys/fs/binfmt_misc/qemu-*
20+
#
21+
# Build:
22+
# docker buildx build --platform linux/arm64 -t $IMAGE -f Dockerfile.arm64
23+
#
24+
# Push:
25+
# docker image tag $IMAGE ghcr.io/proxy-wasm/$IMAGE
26+
# docker push ghcr.io/proxy-wasm/$IMAGE
27+
#
28+
# Test:
29+
# docker run --rm --volume $(pwd):/mnt --workdir /mnt \
30+
# --platform linux/arm64 $IMAGE \
31+
# bazel test --verbose_failures --test_output=errors \
32+
# --define engine=null --config=clang --test_timeout=1800 \
33+
# -- //test/...
34+
35+
# Stage 1: main build image
36+
ARG UBUNTU_VERSION=24.04
37+
FROM ubuntu:${UBUNTU_VERSION} AS build
38+
39+
# Use bash for all RUN instructions
40+
SHELL ["/bin/bash", "-c"]
41+
42+
# Consolidated system update/upgrade and autoremove
43+
RUN apt-get update && \
44+
apt-get upgrade -y && \
45+
apt-get autoremove -y && \
46+
rm -rf /var/lib/apt/lists/*
47+
48+
## All build dependencies for Bazel and ProxyWasm are listed in DEPS for clarity and maintainability.
49+
ARG DEPS="\
50+
build-essential \
51+
clang \
52+
curl \
53+
git \
54+
libssl-dev \
55+
libstdc++6 \
56+
libz-dev \
57+
openjdk-21-jdk \
58+
python3 \
59+
unzip \
60+
zip\
61+
"
62+
# Install all build dependencies (no PPA needed on Ubuntu 24.04)
63+
RUN apt-get update && \
64+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $DEPS && \
65+
rm -rf /var/lib/apt/lists/*
66+
67+
# Install bazelisk: use binary for arm64
68+
ARG BAZELISK_VERSION=v1.27.0
69+
RUN ARCH=$(uname -m) && \
70+
curl -L -o /usr/local/bin/bazelisk "https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-linux-$ARCH" && \
71+
chmod +x /usr/local/bin/bazelisk && \
72+
ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel
73+
74+
# Set a valid working directory
75+
WORKDIR /root

bazel/external/Dockerfile.s390x

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# syntax=docker/dockerfile:1
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Prep:
17+
# docker run --rm --privileged tonistiigi/binfmt --install all
18+
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
19+
# Need to see "F" flag: cat /proc/sys/fs/binfmt_misc/qemu-*
20+
#
21+
# Build:
22+
# docker buildx build --platform linux/s390x -t $IMAGE -f Dockerfile.s390x
23+
#
24+
# Push:
25+
# docker image tag $IMAGE ghcr.io/proxy-wasm/$IMAGE
26+
# docker push ghcr.io/proxy-wasm/$IMAGE
27+
#
28+
# Test:
29+
# docker run --rm --volume $(pwd):/mnt --workdir /mnt \
30+
# --platform linux/s390x $IMAGE \
31+
# bazel test --verbose_failures --test_output=errors \
32+
# --define engine=null --config=clang --test_timeout=1800 \
33+
# -- //test/...
34+
35+
ARG BAZELISK_VERSION=v1.27.0
36+
ARG UBUNTU_VERSION=24.04
37+
# Stage 1: builder for bazelisk on s390x
38+
FROM ubuntu:${UBUNTU_VERSION} AS bazelisk-builder
39+
SHELL ["/bin/bash", "-c"]
40+
WORKDIR /src
41+
ARG BAZELISK_VERSION
42+
ENV PATH="/usr/local/go/bin:$PATH"
43+
# Dépendances pour builder bazelisk
44+
ARG DEPS_BUILDER="\
45+
build-essential \
46+
ca-certificates \
47+
git \
48+
libc6-dev \
49+
pkg-config \
50+
tar \
51+
wget\
52+
"
53+
RUN apt-get update && \
54+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $DEPS_BUILDER && \
55+
wget --progress=dot:giga https://go.dev/dl/go1.24.0.linux-s390x.tar.gz && \
56+
tar -C /usr/local -xzf go1.24.0.linux-s390x.tar.gz && \
57+
rm go1.24.0.linux-s390x.tar.gz && \
58+
git clone --branch "$BAZELISK_VERSION" --single-branch --depth 1 https://github.com/bazelbuild/bazelisk.git bazelisk
59+
WORKDIR /src/bazelisk
60+
RUN go build -o /bazelisk .
61+
WORKDIR /src
62+
RUN rm -rf /src/bazelisk /src/.git /usr/local/go/pkg /usr/local/go/doc /usr/local/go/api /usr/local/go/test /usr/local/go/misc /usr/local/go/obj /usr/local/go/src && \
63+
apt-get remove --purge -y build-essential git wget && \
64+
apt-get autoremove -y && \
65+
apt-get clean && \
66+
rm -rf /var/lib/apt/lists/*
67+
68+
# Stage 2: main build image
69+
FROM ubuntu:${UBUNTU_VERSION} AS build
70+
71+
# Use bash for all RUN instructions
72+
SHELL ["/bin/bash", "-c"]
73+
74+
# Consolidated system update/upgrade and autoremove
75+
RUN apt-get update && \
76+
apt-get upgrade -y && \
77+
apt-get autoremove -y && \
78+
rm -rf /var/lib/apt/lists/*
79+
80+
## All build dependencies for Bazel and ProxyWasm are listed in DEPS for clarity and maintainability.
81+
ARG DEPS="\
82+
build-essential \
83+
clang \
84+
curl \
85+
git \
86+
libssl-dev \
87+
libstdc++6 \
88+
libz-dev \
89+
openjdk-21-jdk \
90+
python3 \
91+
unzip \
92+
zip\
93+
"
94+
# Install all build dependencies (no PPA needed on Ubuntu 24.04)
95+
RUN apt-get update && \
96+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $DEPS && \
97+
rm -rf /var/lib/apt/lists/*
98+
99+
# Copy bazelisk from builder
100+
COPY --from=bazelisk-builder /bazelisk /usr/local/bin/bazelisk
101+
RUN ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel
102+
103+
# Set a valid working directory
104+
WORKDIR /root

0 commit comments

Comments
 (0)