Fix Dockerfile for arm64 compatibility

pull/330/head
Emmanuel Ortiz 2024-12-15 21:25:39 -06:00
parent b2e414984e
commit 6825c56844
2 changed files with 21 additions and 3 deletions

View File

@ -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/

View File

@ -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