Skip to content

Commit

Permalink
Fix Dockerfile for arm64 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
eos175 committed Dec 16, 2024
1 parent b2e4149 commit 6825c56
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
7 changes: 6 additions & 1 deletion rpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG DISTRO
ARG VER
ARG ARCH

FROM ${DISTRO}:${VER} as builder
LABEL stage=innernet-rpm
Expand All @@ -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/
17 changes: 15 additions & 2 deletions rpm/build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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//:/ })
Expand All @@ -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

0 comments on commit 6825c56

Please sign in to comment.