Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Dockerfile for arm64 compatibility #330

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading