From 6825c56844a626d30976783715d7d04897e305e0 Mon Sep 17 00:00:00 2001 From: Emmanuel Ortiz Date: Sun, 15 Dec 2024 21:25:39 -0600 Subject: [PATCH] Fix Dockerfile for arm64 compatibility --- rpm/Dockerfile | 7 ++++++- rpm/build-package.sh | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/rpm/Dockerfile b/rpm/Dockerfile index 47c63fa7..52bede56 100644 --- a/rpm/Dockerfile +++ b/rpm/Dockerfile @@ -1,5 +1,6 @@ ARG DISTRO ARG VER +ARG ARCH FROM ${DISTRO}:${VER} as builder LABEL stage=innernet-rpm @@ -20,8 +21,12 @@ RUN source $HOME/.cargo/env && \ cd server && cargo rpm build && \ cd ../client && cargo rpm build +# Copy RPMs to a temporary directory for better compatibility +RUN mkdir -p /target/rpm && \ + cp -r /workdir/target/release/rpmbuild/RPMS/${ARCH}/* /target/rpm/ + FROM ${DISTRO}:${VER} LABEL stage=innernet-rpm RUN mkdir -p /target/rpm -COPY --from=builder /workdir/target/release/rpmbuild/RPMS/x86_64/innernet-*.rpm /target/rpm/ +COPY --from=builder /target/rpm/ /target/rpm/ diff --git a/rpm/build-package.sh b/rpm/build-package.sh index 352d90de..7002bc77 100755 --- a/rpm/build-package.sh +++ b/rpm/build-package.sh @@ -11,6 +11,7 @@ if [ $# -lt 1 ]; then echo "Usage: $0 distro version (from docker hub), e.g:" echo echo "$0 fedora:33" + echo "$0 almalinux:9 aarch64" exit 1 else SPLIT_ARG=(${1//:/ }) @@ -21,16 +22,28 @@ else echo "bad arg" exit 1 fi + + # Detect architecture, default to x86_64 + ARCH=${2:-x86_64} + if [[ "$ARCH" != "x86_64" && "$ARCH" != "aarch64" ]]; then + echo "Unsupported architecture: $ARCH" + exit 1 + fi fi SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" cd $SCRIPT_DIR/.. -cmd docker build --tag "innernet-rpm-$DISTRO$VER" --file rpm/Dockerfile --build-arg DISTRO=$DISTRO --build-arg VER=$VER . +cmd docker build \ + --tag "innernet-rpm-$DISTRO$VER-$ARCH" \ + --file rpm/Dockerfile \ + --build-arg DISTRO=$DISTRO \ + --build-arg VER=$VER \ + --build-arg ARCH=$ARCH . echo "exporting built rpm's from docker image" -cmd docker run --rm innernet-rpm-$DISTRO$VER sh -c "tar cf - target/rpm/*" | tar xv +cmd docker run --rm "innernet-rpm-$DISTRO$VER-$ARCH" sh -c "tar cf - target/rpm/*" | tar xv echo "cleaning up" cmd docker image prune --force --filter label=stage=innernet-rpm