Skip to content

Commit

Permalink
Docker images for loongarch64, ppc64, ppc64le, and riscv64 (#1168)
Browse files Browse the repository at this point in the history
Add docker images to improve support for other architectures: ppc64, ppc64le, and riscv64
  • Loading branch information
justsmth authored Nov 28, 2023
1 parent 7e6aef8 commit 52deb61
Show file tree
Hide file tree
Showing 27 changed files with 694 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/docker_images/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.tar.xz
41 changes: 41 additions & 0 deletions tests/docker_images/linux-armv6/build_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

# Note:
# After host reboot, qemu registration may need to be performed.
# `docker run --rm --privileged multiarch/qemu-user-static --reset -p yes`

# On Linux, you can see which architectures that qemu is registered for by looking
# under `/proc/sys/fs/binfmt_misc`.

# If needed, you can clear these entries using the following command:
# `sudo find /proc/sys/fs/binfmt_misc -type f -name 'qemu-*' -exec sh -c 'echo -1 > {}' \;`

# Log Docker hub limit https://docs.docker.com/docker-hub/download-rate-limit/#how-can-i-check-my-current-rate
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

SCRIPT_DIR=$(dirname "$(readlink -f "${0}")")

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

ARCH_NAME=armv6

X_TOOLS_FILE=${ARCH_NAME}-x-tools
if [ ! -f "./ubuntu-x-tools/${X_TOOLS_FILE}.tar.xz" ]; then
wget "https://aws-libcrypto.s3.us-west-2.amazonaws.com/cross-compile-toolchains/host-x86_64-pc-linux-gnu/${X_TOOLS_FILE}.tar.xz"
mv ${X_TOOLS_FILE}.tar.xz ./ubuntu-x-tools/
fi

BUILDER_NAME=${ARCH_NAME}-builder
if ! docker buildx inspect ${BUILDER_NAME}; then
docker buildx create --name ${BUILDER_NAME} --use
fi

docker buildx build -t ubuntu-${ARCH_NAME}:test "${SCRIPT_DIR}"/ubuntu-test --load
docker buildx build -t ubuntu-${ARCH_NAME}:x-tools "${SCRIPT_DIR}"/ubuntu-x-tools --load

docker buildx rm ${BUILDER_NAME}
23 changes: 23 additions & 0 deletions tests/docker_images/linux-armv6/ubuntu-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM --platform=$BUILDPLATFORM arm32v7/ubuntu

SHELL ["/bin/bash", "-c"]

# Note: valgind was not available on this platform
RUN apt-get update && apt-get install -y \
git gcc g++ cmake golang gdb gdbserver \
libclang-dev clang \
build-essential \
ssh \
rsync \
tar \
python3 \
&& apt-get clean

EXPOSE 7777

ENV GOCACHE=/tmp

CMD ["/bin/bash"]
40 changes: 40 additions & 0 deletions tests/docker_images/linux-armv6/ubuntu-x-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM ubuntu:22.04

RUN apt-get update && apt-get install -y \
git cmake golang gdb gdbserver valgrind \
libclang1 \
build-essential \
ssh \
rsync \
tar \
python3 \
xz-utils \
ninja-build

RUN apt-get install -y \
qemu-system-arm \
qemu-user \
qemu-user-binfmt

RUN apt-get clean

COPY armv6-x-tools.tar.xz /
RUN tar Jxvf armv6-x-tools.tar.xz -C / && rm /armv6-x-tools.tar.xz
COPY armv6.cmake /

EXPOSE 1234

ENV GOCACHE=/tmp \
CMAKE_TOOLCHAIN_FILE=/armv6.cmake \
CMAKE_SYSTEM_NAME=Linux \
CMAKE_SYSTEM_PROCESSOR=armv6l \
PATH="${PATH}:/armv6-unknown-linux-gnueabi/bin/" \
CMAKE_C_COMPILER=/armv6-unknown-linux-gnueabi/bin/armv6-unknown-linux-gnueabi-gcc \
CMAKE_CXX_COMPILER=/armv6-unknown-linux-gnueabi/bin/armv6-unknown-linux-gnueabi-g++ \
CMAKE_SYSROOT=/armv6-unknown-linux-gnueabi/armv6-unknown-linux-gnueabi/sysroot \
CMAKE_GENERATOR=Ninja

CMD ["/bin/bash"]
11 changes: 11 additions & 0 deletions tests/docker_images/linux-armv6/ubuntu-x-tools/armv6.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Specify the target system
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv6l)

# Specify the cross-compiler
set(CMAKE_C_COMPILER /armv6-unknown-linux-gnueabi/bin/armv6-unknown-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /armv6-unknown-linux-gnueabi/bin/armv6-unknown-linux-gnueabi-g++)

# Specify the sysroot for the target system
set(CMAKE_SYSROOT /armv6-unknown-linux-gnueabi/armv6-unknown-linux-gnueabi/sysroot)
set(CMAKE_GENERATOR Ninja)
40 changes: 40 additions & 0 deletions tests/docker_images/linux-loongarch64/build_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

# Note:
# After host reboot, qemu registration may need to be performed.
# `docker run --rm --privileged multiarch/qemu-user-static --reset -p yes`

# On Linux, you can see which architectures that qemu is registered for by looking
# under `/proc/sys/fs/binfmt_misc`.

# If needed, you can clear these entries using the following command:
# `sudo find /proc/sys/fs/binfmt_misc -type f -name 'qemu-*' -exec sh -c 'echo -1 > {}' \;`

# Log Docker hub limit https://docs.docker.com/docker-hub/download-rate-limit/#how-can-i-check-my-current-rate
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

SCRIPT_DIR=$(dirname "$(readlink -f "${0}")")

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

ARCH_NAME=loongarch64

X_TOOLS_FILE=${ARCH_NAME}-x-tools
if [ ! -f "./ubuntu-x-tools/${X_TOOLS_FILE}.tar.xz" ]; then
wget "https://aws-libcrypto.s3.us-west-2.amazonaws.com/cross-compile-toolchains/host-x86_64-pc-linux-gnu/${X_TOOLS_FILE}.tar.xz"
mv ${X_TOOLS_FILE}.tar.xz ./ubuntu-x-tools/
fi

BUILDER_NAME=${ARCH_NAME}-builder
if ! docker buildx inspect ${BUILDER_NAME}; then
docker buildx create --name ${BUILDER_NAME} --use
fi

docker buildx build -t ubuntu-${ARCH_NAME}:x-tools "${SCRIPT_DIR}"/ubuntu-x-tools --load

docker buildx rm ${BUILDER_NAME}
42 changes: 42 additions & 0 deletions tests/docker_images/linux-loongarch64/ubuntu-x-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM ubuntu:22.04

RUN apt-get update && apt-get install -y \
git cmake golang gdb gdbserver valgrind \
libclang1 \
build-essential \
ssh \
rsync \
tar \
python3 \
xz-utils \
ninja-build

RUN apt-get install -y \
qemu-user \
qemu-user-binfmt \
qemu-user-status
# Not yet available
# qemu-system-loongarch64

RUN apt-get clean

COPY loongarch64-x-tools.tar.xz /
RUN tar Jxvf loongarch64-x-tools.tar.xz -C / && rm /loongarch64-x-tools.tar.xz
COPY loongarch64.cmake /

EXPOSE 1234

ENV GOCACHE=/tmp \
CMAKE_TOOLCHAIN_FILE=/loongarch64.cmake \
CMAKE_SYSTEM_NAME=Linux \
CMAKE_SYSTEM_PROCESSOR=loongarch64 \
PATH="${PATH}:/loongarch64-unknown-linux-gnu/bin/" \
CMAKE_C_COMPILER=/loongarch64-unknown-linux-gnu/bin/loongarch64-unknown-linux-gnu-gcc \
CMAKE_CXX_COMPILER=/loongarch64-unknown-linux-gnu/bin/loongarch64-unknown-linux-gnu-g++ \
CMAKE_SYSROOT=/loongarch64-unknown-linux-gnu/loongarch64-unknown-linux-gnu/sysroot \
CMAKE_GENERATOR=Ninja

CMD ["/bin/bash"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Specify the target system
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR loongarch64)

# Specify the cross-compiler
set(CMAKE_C_COMPILER /loongarch64-unknown-linux-gnu/bin/loongarch64-unknown-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /loongarch64-unknown-linux-gnu/bin/loongarch64-unknown-linux-gnu-g++)

# Specify the sysroot for the target system
set(CMAKE_SYSROOT /loongarch64-unknown-linux-gnu/loongarch64-unknown-linux-gnu/sysroot)
set(CMAKE_GENERATOR Ninja)
40 changes: 40 additions & 0 deletions tests/docker_images/linux-ppc/build_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

# Note:
# After host reboot, qemu registration may need to be performed.
# `docker run --rm --privileged multiarch/qemu-user-static --reset -p yes`

# On Linux, you can see which architectures that qemu is registered for by looking
# under `/proc/sys/fs/binfmt_misc`.

# If needed, you can clear these entries using the following command:
# `sudo find /proc/sys/fs/binfmt_misc -type f -name 'qemu-*' -exec sh -c 'echo -1 > {}' \;`

# Log Docker hub limit https://docs.docker.com/docker-hub/download-rate-limit/#how-can-i-check-my-current-rate
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

SCRIPT_DIR=$(dirname "$(readlink -f "${0}")")

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

ARCH_NAME=ppc

X_TOOLS_FILE=${ARCH_NAME}-x-tools
if [ ! -f "./ubuntu-x-tools/${X_TOOLS_FILE}.tar.xz" ]; then
wget "https://aws-libcrypto.s3.us-west-2.amazonaws.com/cross-compile-toolchains/host-x86_64-pc-linux-gnu/${X_TOOLS_FILE}.tar.xz"
mv ${X_TOOLS_FILE}.tar.xz ./ubuntu-x-tools/
fi

BUILDER_NAME=${ARCH_NAME}-builder
if ! docker buildx inspect ${BUILDER_NAME}; then
docker buildx create --name ${BUILDER_NAME} --use
fi

docker buildx build -t ubuntu-${ARCH_NAME}:x-tools "${SCRIPT_DIR}"/ubuntu-x-tools --load

docker buildx rm ${BUILDER_NAME}
40 changes: 40 additions & 0 deletions tests/docker_images/linux-ppc/ubuntu-x-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM ubuntu:22.04

RUN apt-get update && apt-get install -y \
git cmake golang gdb gdbserver valgrind \
libclang1 \
build-essential \
ssh \
rsync \
tar \
python3 \
xz-utils \
ninja-build

RUN apt-get install -y \
qemu-system-ppc \
qemu-user \
qemu-user-binfmt

RUN apt-get clean

COPY ppc-x-tools.tar.xz /
RUN tar Jxvf ppc-x-tools.tar.xz -C / && rm /ppc-x-tools.tar.xz
COPY ppc.cmake /

EXPOSE 1234

ENV GOCACHE=/tmp \
CMAKE_TOOLCHAIN_FILE=/ppc.cmake \
CMAKE_SYSTEM_NAME=Linux \
CMAKE_SYSTEM_PROCESSOR=ppc \
PATH="${PATH}:/powerpc-unknown-linux-gnu/bin/" \
CMAKE_C_COMPILER=/powerpc-unknown-linux-gnu/bin/powerpc-unknown-linux-gnu-gcc \
CMAKE_CXX_COMPILER=/powerpc-unknown-linux-gnu/bin/powerpc-unknown-linux-gnu-g++ \
CMAKE_SYSROOT=/powerpc-unknown-linux-gnu/powerpc-unknown-linux-gnu/sysroot \
CMAKE_GENERATOR=Ninja

CMD ["/bin/bash"]
11 changes: 11 additions & 0 deletions tests/docker_images/linux-ppc/ubuntu-x-tools/ppc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Specify the target system
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ppc)

# Specify the cross-compiler
set(CMAKE_C_COMPILER /powerpc-unknown-linux-gnu/bin/powerpc-unknown-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /powerpc-unknown-linux-gnu/bin/powerpc-unknown-linux-gnu-g++)

# Specify the sysroot for the target system
set(CMAKE_SYSROOT /powerpc-unknown-linux-gnu/powerpc-unknown-linux-gnu/sysroot)
set(CMAKE_GENERATOR Ninja)
44 changes: 44 additions & 0 deletions tests/docker_images/linux-ppc64/build_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

# Note:
# After host reboot, qemu registration may need to be performed.
# `docker run --rm --privileged multiarch/qemu-user-static --reset -p yes`

# On Linux, you can see which architectures that qemu is registered for by looking
# under `/proc/sys/fs/binfmt_misc`.

# If needed, you can clear these entries using the following command:
# `sudo find /proc/sys/fs/binfmt_misc -type f -name 'qemu-*' -exec sh -c 'echo -1 > {}' \;`

# Log Docker hub limit https://docs.docker.com/docker-hub/download-rate-limit/#how-can-i-check-my-current-rate
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

SCRIPT_DIR=$(dirname "$(readlink -f "${0}")")

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

ARCH_NAME=ppc64

X_TOOLS_FILE=${ARCH_NAME}-x-tools
if [ ! -f "./ubuntu-x-tools/${X_TOOLS_FILE}.tar.xz" ]; then
wget "https://aws-libcrypto.s3.us-west-2.amazonaws.com/cross-compile-toolchains/host-x86_64-pc-linux-gnu/${X_TOOLS_FILE}.tar.xz"
mv ${X_TOOLS_FILE}.tar.xz ./ubuntu-x-tools/
fi

BUILDER_NAME=${ARCH_NAME}-builder
if ! docker buildx inspect ${BUILDER_NAME}; then
docker buildx create --name ${BUILDER_NAME} --use
fi

docker buildx build -t debian-${ARCH_NAME}:test "${SCRIPT_DIR}"/debian-test --load
docker buildx build -t ubuntu-${ARCH_NAME}:x-tools "${SCRIPT_DIR}"/ubuntu-x-tools --load
#docker context use default
#docker buildx build -t debian-${ARCH_NAME}:e6500 "${SCRIPT_DIR}"/debian-e6500 --load
#docker buildx build -t debian-${ARCH_NAME}:POWER8 "${SCRIPT_DIR}"/debian-POWER8 --load

docker buildx rm ${BUILDER_NAME}
12 changes: 12 additions & 0 deletions tests/docker_images/linux-ppc64/debian-POWER8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM debian-ppc64:test

SHELL ["/bin/bash", "-c"]

COPY qemu-wrapper.sh /usr/bin/qemu-wrapper

CMD ["/bin/bash"]

ENTRYPOINT ["/usr/bin/qemu-wrapper"]
5 changes: 5 additions & 0 deletions tests/docker_images/linux-ppc64/debian-POWER8/qemu-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

exec /usr/bin/qemu-ppc64-static -cpu power8e "$@"
12 changes: 12 additions & 0 deletions tests/docker_images/linux-ppc64/debian-e6500/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM debian-ppc64:test

SHELL ["/bin/bash", "-c"]

COPY qemu-wrapper.sh /usr/bin/qemu-wrapper

CMD ["/bin/bash"]

ENTRYPOINT ["/usr/bin/qemu-wrapper"]
5 changes: 5 additions & 0 deletions tests/docker_images/linux-ppc64/debian-e6500/qemu-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

exec /usr/bin/qemu-ppc64-static -cpu e6500 "$@"
Loading

0 comments on commit 52deb61

Please sign in to comment.