diff --git a/docker/Dockerfile b/docker/Dockerfile index 03e32af9..133af0c4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,6 +9,9 @@ FROM ubuntu:23.04 AS base-cross-compiler ARG BRANCH=master +# Set TARGETARCH e.g. amd64, arm64, riscv64. +ARG TARGETARCH + # Set locale for iconv, used by ndstool ENV LANG=C.UTF-8 ENV LC_ALL=C.UTF-8 @@ -19,9 +22,13 @@ RUN apt-get update && apt-get upgrade -y && \ RUN mkdir -p /opt/wonderful/ ADD https://wonderful.asie.pl/bootstrap/wf-bootstrap-x86_64.tar.gz /opt/wonderful/ +ADD https://wonderful.asie.pl/bootstrap/wf-bootstrap-aarch64.tar.gz /opt/wonderful/ +# Note that the downloads are cached; no impact if it's a multi-platform build. +# Needed because Docker's TARGETARCH doesn't match Linux's `uname -m` format. + RUN cd /opt/wonderful/ && \ - tar xzvf wf-bootstrap-x86_64.tar.gz && \ - rm wf-bootstrap-x86_64.tar.gz + tar xzvf wf-bootstrap-$(uname -m).tar.gz && \ + rm wf-bootstrap-*.tar.gz ENV PATH=/opt/wonderful/bin:$PATH @@ -49,7 +56,8 @@ RUN apt-get install -y --no-install-recommends \ build-essential # Install Teak toolchain only in the dev image -RUN wf-pacman -S --noconfirm toolchain-llvm-teak-llvm +RUN if [ $TARGETARCH = "amd64" ]; then \ + wf-pacman -S --noconfirm toolchain-llvm-teak-llvm; fi WORKDIR /opt/ RUN git clone --recurse-submodules https://github.com/blocksds/sdk.git \ diff --git a/docker/build-docker.sh b/docker/build-docker.sh old mode 100644 new mode 100755 index e28558d5..002e32f2 --- a/docker/build-docker.sh +++ b/docker/build-docker.sh @@ -25,16 +25,20 @@ if [ -z $BRANCH ]; then fi fi +if [ -z $PLATFORM ]; then + PLATFORM="linux/amd64,linux/arm64" +fi echo "VERSION = $VERSION" echo "BRANCH = $BRANCH" +echo "PLATFORM = $PLATFORM" docker build --target blocksds-dev --tag blocksds:dev \ - --build-arg BRANCH=$BRANCH . + --build-arg BRANCH=$BRANCH --platform $PLATFORM . docker tag blocksds:dev skylyrac/blocksds:dev-$VERSION docker build --target blocksds-slim --tag blocksds:slim \ - --build-arg BRANCH=$BRANCH . + --build-arg BRANCH=$BRANCH --platform $PLATFORM . docker tag blocksds:slim skylyrac/blocksds:slim-$VERSION docker push skylyrac/blocksds:dev-$VERSION