Skip to content

Commit

Permalink
chore: Update Dockerfile to install cross and set up build environmen…
Browse files Browse the repository at this point in the history
…t for armv7l target
  • Loading branch information
vitorfdl committed Jun 20, 2024
1 parent 0bc2b70 commit 08efb34
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 14 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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; \
Expand All @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion dockerhub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 08efb34

Please sign in to comment.