From 8f987813f5a6542d97eebd676ca489b19b07daa2 Mon Sep 17 00:00:00 2001 From: muXxer Date: Tue, 31 Dec 2024 14:18:29 +0100 Subject: [PATCH] feat(docker): Add support for arm64 and amd64 builds for jemalloc (#4585) * feat(docker): Add support for arm64 and amd64 builds for jemalloc * feat(release): add arm64 plattform for docker containers --- .github/workflows/release_docker.yml | 8 ++++---- docker/iota-bridge-indexer/Dockerfile | 16 +++++++++++++--- docker/iota-indexer-tidb/Dockerfile | 16 +++++++++++++--- docker/iota-indexer/Dockerfile | 16 +++++++++++++--- docker/iota-node/Dockerfile | 16 +++++++++++++--- 5 files changed, 56 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml index 9acbe8dcc40..5f8ef7568de 100644 --- a/.github/workflows/release_docker.yml +++ b/.github/workflows/release_docker.yml @@ -87,7 +87,7 @@ jobs: with: context: . file: docker/iota-node/Dockerfile - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta-node.outputs.tags }} push: true pull: true @@ -156,7 +156,7 @@ jobs: with: context: . file: docker/iota-indexer/Dockerfile - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta-indexer.outputs.tags }} push: true pull: true @@ -225,7 +225,7 @@ jobs: with: context: . file: docker/iota-tools/Dockerfile - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta-tools.outputs.tags }} push: true pull: true @@ -294,7 +294,7 @@ jobs: with: context: . file: docker/iota-graphql-rpc/Dockerfile - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta-tools.outputs.tags }} push: true pull: true diff --git a/docker/iota-bridge-indexer/Dockerfile b/docker/iota-bridge-indexer/Dockerfile index 9dd2957ed93..893e366a264 100644 --- a/docker/iota-bridge-indexer/Dockerfile +++ b/docker/iota-bridge-indexer/Dockerfile @@ -51,9 +51,19 @@ WORKDIR "$WORKDIR" # Install runtime dependencies and tools RUN apt update && apt install -y libpq5 ca-certificates curl -# Install jemalloc as the default allocator -RUN apt install -y libjemalloc-dev -ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so +# Install jemalloc as the default allocator used for memory profiling on supported +# architectures and create a symlink for the correct version based on the architecture +RUN ARCH=$(dpkg --print-architecture) && \ + if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "arm64" ]; then \ + apt update && apt install -y libjemalloc-dev; \ + ln -sf $(ldconfig -p | grep jemalloc | awk '{print $4}' | sort -u | head -n 1) /usr/lib/libjemalloc.so; \ + else \ + echo "Unsupported architecture: $ARCH. Only amd64 and arm64 are supported."; \ + exit 1; \ +fi + +# Set LD_PRELOAD to the symlinked path +ENV LD_PRELOAD=/usr/lib/libjemalloc.so COPY --from=builder /iota/bridge-indexer /usr/local/bin diff --git a/docker/iota-indexer-tidb/Dockerfile b/docker/iota-indexer-tidb/Dockerfile index 269f4a439f8..c748376262a 100644 --- a/docker/iota-indexer-tidb/Dockerfile +++ b/docker/iota-indexer-tidb/Dockerfile @@ -51,9 +51,19 @@ WORKDIR "$WORKDIR" # Install runtime dependencies and tools RUN apt update && apt install -y libpq5 ca-certificates curl -# Install jemalloc as the default allocator -RUN apt install -y libjemalloc-dev -ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so +# Install jemalloc as the default allocator used for memory profiling on supported +# architectures and create a symlink for the correct version based on the architecture +RUN ARCH=$(dpkg --print-architecture) && \ + if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "arm64" ]; then \ + apt update && apt install -y libjemalloc-dev; \ + ln -sf $(ldconfig -p | grep jemalloc | awk '{print $4}' | sort -u | head -n 1) /usr/lib/libjemalloc.so; \ + else \ + echo "Unsupported architecture: $ARCH. Only amd64 and arm64 are supported."; \ + exit 1; \ +fi + +# Set LD_PRELOAD to the symlinked path +ENV LD_PRELOAD=/usr/lib/libjemalloc.so COPY --from=builder /iota/iota-indexer /usr/local/bin diff --git a/docker/iota-indexer/Dockerfile b/docker/iota-indexer/Dockerfile index 528be6a7aed..8f352977a4b 100644 --- a/docker/iota-indexer/Dockerfile +++ b/docker/iota-indexer/Dockerfile @@ -51,9 +51,19 @@ WORKDIR "$WORKDIR" # Install runtime dependencies and tools RUN apt update && apt install -y libpq5 ca-certificates curl -# Install jemalloc as the default allocator -RUN apt install -y libjemalloc-dev -ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so +# Install jemalloc as the default allocator used for memory profiling on supported +# architectures and create a symlink for the correct version based on the architecture +RUN ARCH=$(dpkg --print-architecture) && \ + if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "arm64" ]; then \ + apt update && apt install -y libjemalloc-dev; \ + ln -sf $(ldconfig -p | grep jemalloc | awk '{print $4}' | sort -u | head -n 1) /usr/lib/libjemalloc.so; \ + else \ + echo "Unsupported architecture: $ARCH. Only amd64 and arm64 are supported."; \ + exit 1; \ +fi + +# Set LD_PRELOAD to the symlinked path +ENV LD_PRELOAD=/usr/lib/libjemalloc.so COPY --from=builder /iota/iota-indexer /usr/local/bin diff --git a/docker/iota-node/Dockerfile b/docker/iota-node/Dockerfile index cb935142d89..2c9e133c928 100644 --- a/docker/iota-node/Dockerfile +++ b/docker/iota-node/Dockerfile @@ -51,9 +51,19 @@ WORKDIR "$WORKDIR" # Install runtime dependencies and tools RUN apt update && apt install -y libpq5 ca-certificates curl -# Install jemalloc as the default allocator -RUN apt install -y libjemalloc-dev -ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so +# Install jemalloc as the default allocator used for memory profiling on supported +# architectures and create a symlink for the correct version based on the architecture +RUN ARCH=$(dpkg --print-architecture) && \ + if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "arm64" ]; then \ + apt update && apt install -y libjemalloc-dev; \ + ln -sf $(ldconfig -p | grep jemalloc | awk '{print $4}' | sort -u | head -n 1) /usr/lib/libjemalloc.so; \ + else \ + echo "Unsupported architecture: $ARCH. Only amd64 and arm64 are supported."; \ + exit 1; \ +fi + +# Set LD_PRELOAD to the symlinked path +ENV LD_PRELOAD=/usr/lib/libjemalloc.so COPY --from=builder /iota/iota-node /usr/local/bin