From 0bc2b70b0bb888def9555534c16cbb1458d977ac Mon Sep 17 00:00:00 2001 From: Vitor Lima Date: Wed, 19 Jun 2024 18:44:13 -0300 Subject: [PATCH] chore: Update Dockerfile to determine the target based on the platform and build with the specified target --- Dockerfile | 16 ++++++++++++++-- dockerhub.sh | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2fee603..7aeebbb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,8 +29,20 @@ ADD . ${TAGOIO_SOURCE_FOLDER} RUN touch .env -# Build the project -RUN cargo build --release +# Determine the target based on the platform +RUN set -e; \ + TARGET=$(uname -m); \ + if [ "$TARGET" = "x86_64" ]; then \ + TARGET="x86_64-unknown-linux-gnu"; \ + elif [ "$TARGET" = "aarch64" ]; then \ + TARGET="aarch64-unknown-linux-gnu"; \ + elif [ "$TARGET" = "armv7l" ]; then \ + TARGET="armv7-unknown-linux-gnueabihf"; \ + else \ + echo "Unsupported architecture: $TARGET"; exit 1; \ + fi; \ + rustup target add $TARGET && \ + cargo build --release --target $TARGET # Unset the SSL environment variables RUN unset CARGO_SERVER_SSL_CA CARGO_SERVER_SSL_CERT CARGO_SERVER_SSL_KEY diff --git a/dockerhub.sh b/dockerhub.sh index b25dfc2..41a2131 100644 --- a/dockerhub.sh +++ b/dockerhub.sh @@ -53,7 +53,7 @@ docker buildx build --push --build-arg TAGORELAY_VERSION=${FULL_VERSION} \ --build-arg CARGO_SERVER_SSL_CA=${CARGO_SERVER_SSL_CA_BASE64} \ --build-arg CARGO_SERVER_SSL_CERT=${CARGO_SERVER_SSL_CERT_BASE64} \ --build-arg CARGO_SERVER_SSL_KEY=${CARGO_SERVER_SSL_KEY_BASE64} \ - --platform linux/arm/v7,linux/amd64 \ + --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \ --tag tagoio/relay \ --tag tagoio/relay:debian \ --tag tagoio/relay:bullseye \