From 0f6a5dd383b4715be3f054eae1a72b2d4d773b2a Mon Sep 17 00:00:00 2001 From: David Michael Barr Date: Fri, 1 Dec 2023 01:13:55 +0900 Subject: [PATCH] devcontainer: Build with multi-architecture manifest --- .../{Dockerfile => Dockerfile.amd64} | 0 .devcontainer/Dockerfile.arm64 | 27 +++++++++++++++++++ .../{build.json => build-amd64.json} | 2 +- .devcontainer/build-arm64.json | 6 +++++ .github/workflows/devcontainer.yml | 12 +++++++-- 5 files changed, 44 insertions(+), 3 deletions(-) rename .devcontainer/{Dockerfile => Dockerfile.amd64} (100%) create mode 100644 .devcontainer/Dockerfile.arm64 rename .devcontainer/{build.json => build-amd64.json} (58%) create mode 100644 .devcontainer/build-arm64.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile.amd64 similarity index 100% rename from .devcontainer/Dockerfile rename to .devcontainer/Dockerfile.amd64 diff --git a/.devcontainer/Dockerfile.arm64 b/.devcontainer/Dockerfile.arm64 new file mode 100644 index 0000000000..2666138ee0 --- /dev/null +++ b/.devcontainer/Dockerfile.arm64 @@ -0,0 +1,27 @@ +FROM mcr.microsoft.com/devcontainers/rust:dev-1-bookworm +RUN dpkg --add-architecture amd64 \ + && sed -i 's/bookworm/trixie/g' /etc/apt/sources.list.d/* \ + && apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get install -y --no-install-recommends \ + libaom-dev libdav1d-dev libaom-dev:amd64 libdav1d-dev:amd64 \ + libclang-dev libgit2-dev libcurl4-openssl-dev libfuzzer-14-dev \ + gcc-x86-64-linux-gnu libc6-dev-amd64-cross nasm dav1d qemu-user \ + meson ninja-build \ + && rm -rf /var/lib/apt/lists/* \ + && sed -i '304s/union/& aom_codec_cfg/' /usr/include/aom/aom_codec.h \ + && sed -i '122s/union/& aom_pkt_union/' /usr/include/aom/aom_encoder.h \ + && sed -i '122s/struct/& aom_frame_pkt/' /usr/include/aom/aom_encoder.h +RUN rustup target add x86_64-unknown-linux-gnu +RUN export CARGO_PROFILE_RELEASE_STRIP=true \ + && cargo install -q cargo-c --version "0.9.27+cargo-0.74.0" \ + && cargo install -q cargo-criterion --version "1.1.0" \ + && cargo install -q cargo-fuzz --version "0.11.2" \ + && rm -rf /usr/local/cargo/registry +ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER=qemu-x86_64 +ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS=-Clinker=x86_64-linux-gnu-gcc +ENV PKG_CONFIG_ALLOW_CROSS_x86_64_unknown_linux_gnu=1 +ENV PKG_CONFIG_PATH_x86_64_unknown_linux_gnu=/usr/lib/x64_64-linux-gnu/pkgconfig +ENV PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu=/ +ENV CUSTOM_LIBFUZZER_PATH=/usr/lib/llvm-14/lib/libFuzzer.a +LABEL dev.containers.source=https://github.com/xiph/rav1e +LABEL dev.containers.id=rav1e \ No newline at end of file diff --git a/.devcontainer/build.json b/.devcontainer/build-amd64.json similarity index 58% rename from .devcontainer/build.json rename to .devcontainer/build-amd64.json index 5875b1e3dc..28c69077f8 100644 --- a/.devcontainer/build.json +++ b/.devcontainer/build-amd64.json @@ -1,6 +1,6 @@ { "name": "rav1e-devcontainer", "build": { - "dockerfile": "Dockerfile" + "dockerfile": "Dockerfile.amd64" } } \ No newline at end of file diff --git a/.devcontainer/build-arm64.json b/.devcontainer/build-arm64.json new file mode 100644 index 0000000000..25f4517f15 --- /dev/null +++ b/.devcontainer/build-arm64.json @@ -0,0 +1,6 @@ +{ + "name": "rav1e-devcontainer", + "build": { + "dockerfile": "Dockerfile.arm64" + } +} \ No newline at end of file diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index f5f47b1e61..ffbc62925c 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -20,6 +20,8 @@ jobs: - uses: actions/checkout@v4 - name: Install devcontainer-cli run: npm install -g @devcontainers/cli + - name: Register qemu binfmt-misc entries for Docker + run: docker run --privileged --rm tonistiigi/binfmt --install all - name: Authenticate with ghcr.io run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - name: Build devcontainer image @@ -28,5 +30,11 @@ jobs: IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME VERSION=latest IMAGE_TAG=${IMAGE_ID,,}:$VERSION - devcontainer build --image-name $IMAGE_TAG --push \ - --workspace-folder $PWD --config .devcontainer/build.json \ No newline at end of file + devcontainer build --image-name $IMAGE_TAG-amd64 --platform linux/amd64 --push \ + --workspace-folder $PWD --config .devcontainer/build-amd64.json + devcontainer build --image-name $IMAGE_TAG-arm64 --platform linux/arm64 --push \ + --workspace-folder $PWD --config .devcontainer/build-arm64.json + docker manifest create $IMAGE_TAG \ + --amend $IMAGE_TAG-amd64 \ + --amend $IMAGE_TAG-arm64 + docker manifest push $IMAGE_TAG \ No newline at end of file