Skip to content

Commit 7728403

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 7728403

File tree

4 files changed

+165
-9
lines changed

4 files changed

+165
-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: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
# Stage 1: builder for bazelisk on s390x
36+
ARG BAZELISK_VERSION=v1.27.0
37+
FROM golang:1.24-bullseye AS bazelisk-builder
38+
ARG BAZELISK_VERSION
39+
WORKDIR /src
40+
RUN git clone --branch ${BAZELISK_VERSION} --depth 1 https://github.com/bazelbuild/bazelisk.git bazelisk
41+
WORKDIR /src/bazelisk
42+
RUN go build -o /bazelisk .
43+
44+
# Stage 2: main build image
45+
ARG UBUNTU_VERSION=24.04
46+
FROM ubuntu:${UBUNTU_VERSION} AS build
47+
48+
# Use bash for all RUN instructions
49+
SHELL ["/bin/bash", "-c"]
50+
51+
# Consolidated system update/upgrade and autoremove
52+
RUN apt-get update && \
53+
apt-get upgrade -y && \
54+
apt-get autoremove -y && \
55+
rm -rf /var/lib/apt/lists/*
56+
57+
## All build dependencies for Bazel and ProxyWasm are listed in DEPS for clarity and maintainability.
58+
ARG DEPS="\
59+
build-essential \
60+
clang \
61+
curl \
62+
git \
63+
libssl-dev \
64+
libstdc++6 \
65+
libz-dev \
66+
openjdk-21-jdk \
67+
python3 \
68+
unzip \
69+
zip\
70+
"
71+
# Install all build dependencies (no PPA needed on Ubuntu 24.04)
72+
RUN apt-get update && \
73+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $DEPS && \
74+
rm -rf /var/lib/apt/lists/*
75+
76+
# Copy bazelisk from builder
77+
COPY --from=bazelisk-builder /bazelisk /usr/local/bin/bazelisk
78+
RUN ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel
79+
80+
# Set a valid working directory
81+
WORKDIR /root

0 commit comments

Comments
 (0)