From 08efb34268b388e582a87411a0c2c17a01ecb2cb Mon Sep 17 00:00:00 2001 From: Vitor Lima Date: Wed, 19 Jun 2024 21:44:10 -0300 Subject: [PATCH] chore: Update Dockerfile to install cross and set up build environment for armv7l target --- Dockerfile | 27 ++++++++++++++------------- dockerhub.sh | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7aeebbb..bc75fc3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,22 +5,19 @@ ARG CARGO_SERVER_SSL_CA ARG CARGO_SERVER_SSL_CERT ARG CARGO_SERVER_SSL_KEY -# Decode the base64 encoded environment variables -RUN export CARGO_SERVER_SSL_CA=$(echo "${CARGO_SERVER_SSL_CA}" | base64 -d) -RUN export CARGO_SERVER_SSL_CERT=$(echo "${CARGO_SERVER_SSL_CERT}" | base64 -d) -RUN export CARGO_SERVER_SSL_KEY=$(echo "${CARGO_SERVER_SSL_KEY}" | base64 -d) - -# Validate that the SSL environment variables are set -RUN /bin/bash -c 'if [ -z "$CARGO_SERVER_SSL_CA" ]; then echo "Error: CARGO_SERVER_SSL_CA is not set"; exit 1; fi && \ +# Decode the base64 encoded environment variables and validate that they are set +RUN export CARGO_SERVER_SSL_CA=$(echo "${CARGO_SERVER_SSL_CA}" | base64 -d) && \ + export CARGO_SERVER_SSL_CERT=$(echo "${CARGO_SERVER_SSL_CERT}" | base64 -d) && \ + export CARGO_SERVER_SSL_KEY=$(echo "${CARGO_SERVER_SSL_KEY}" | base64 -d) && \ + /bin/bash -c 'if [ -z "$CARGO_SERVER_SSL_CA" ]; then echo "Error: CARGO_SERVER_SSL_CA is not set"; exit 1; fi && \ if [ -z "$CARGO_SERVER_SSL_CERT" ]; then echo "Error: CARGO_SERVER_SSL_CERT is not set"; exit 1; fi && \ if [ -z "$CARGO_SERVER_SSL_KEY" ]; then echo "Error: CARGO_SERVER_SSL_KEY is not set"; exit 1; fi' # Install dependencies RUN apt update -RUN apt install -y protobuf-compiler libssl-dev gcc pkg-config build-essential g++-aarch64-linux-gnu libc6-dev-arm64-cross - -# Install cross -RUN rustup target add aarch64-unknown-linux-gnu +RUN apt install -y protobuf-compiler libssl-dev gcc musl-dev pkg-config build-essential libc6-dev-arm64-cross cmake +# TODO: For armv7l, need to use custom version for openssl. We may need to make a separated Dockerfile for armv7l +# RUN apt install -y protobuf-compiler libssl-dev gcc musl-dev pkg-config build-essential libc6-dev-arm64-cross cmake clang llvm-dev # Set up the build environment RUN mkdir -p ${TAGOIO_SOURCE_FOLDER} @@ -37,7 +34,8 @@ RUN set -e; \ elif [ "$TARGET" = "aarch64" ]; then \ TARGET="aarch64-unknown-linux-gnu"; \ elif [ "$TARGET" = "armv7l" ]; then \ - TARGET="armv7-unknown-linux-gnueabihf"; \ + TARGET="armv7-unknown-linux-gnueabihf" \ + export LIBCLANG_PATH=$(llvm-config --libdir); \ else \ echo "Unsupported architecture: $TARGET"; exit 1; \ fi; \ @@ -57,8 +55,11 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* RUN mkdir -p ${TAGOIO_SOURCE_FOLDER} WORKDIR ${TAGOIO_SOURCE_FOLDER} -COPY --from=build ${TAGOIO_SOURCE_FOLDER}/target/release/tagoio-relay . +# Copy the target directory from the build stage +COPY --from=build ${TAGOIO_SOURCE_FOLDER}/target/*/release/tagoio-relay . + +RUN ls -la . RUN /tago-io/tagoio-relay init ENTRYPOINT ["/tago-io/tagoio-relay"] diff --git a/dockerhub.sh b/dockerhub.sh index 41a2131..9a763fb 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/arm64/v8,linux/amd64 \ + --platform linux/arm64/v8,linux/amd64 \ --tag tagoio/relay \ --tag tagoio/relay:debian \ --tag tagoio/relay:bullseye \