From b36bfba6112e827ba4f8bd960dccd536d08dae3d Mon Sep 17 00:00:00 2001 From: vladimir Date: Fri, 12 Dec 2025 10:47:16 -0500 Subject: [PATCH 1/2] fixing multi-architecture build errors --- Dockerfile | 64 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index b17d133..ce6409b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,29 +29,67 @@ RUN set -ex && \ # Install Node.js ARG TARGETARCH + +# Step 1: Detect and set architecture +RUN set -ex && \ + if [ -n "$TARGETARCH" ]; then \ + ARCH="$TARGETARCH"; \ + else \ + ARCH=$(dpkg --print-architecture 2>/dev/null || echo "amd64"); \ + fi && \ + case "$ARCH" in \ + amd64) ARCH="x64" ;; \ + arm64) ARCH="arm64" ;; \ + *) echo "Unsupported architecture: $ARCH" && exit 1 ;; \ + esac && \ + echo "Building for architecture: $ARCH" && \ + echo "$ARCH" > /tmp/node_arch.txt + +# Step 2: Download Node.js binary RUN set -ex && \ - # Detect architecture - ARCH="${TARGETARCH:-$(dpkg --print-architecture 2>/dev/null || echo "x64")}" && \ - if [ "$ARCH" = "amd64" ]; then ARCH="x64"; fi && \ - if [ "$ARCH" = "arm64" ]; then ARCH="arm64"; fi && \ - echo "Detected architecture: $ARCH" && \ - # Download Node.js binary and checksum + ARCH=$(cat /tmp/node_arch.txt) && \ + echo "Downloading Node.js v${NODE_VERSION} for ${ARCH}..." && \ curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" && \ + ls -lh node-v${NODE_VERSION}-linux-${ARCH}.tar.xz + +# Step 3: Download checksum file +RUN set -ex && \ + echo "Downloading SHASUMS256.txt..." && \ curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt" && \ - # Verify checksum - grep "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz\$" SHASUMS256.txt > SHASUMS256.txt.verify && \ - sha256sum -c SHASUMS256.txt.verify && \ - # Extract and install + echo "Contents of SHASUMS256.txt:" && \ + head -n 5 SHASUMS256.txt + +# Step 4: Verify checksum +RUN set -ex && \ + ARCH=$(cat /tmp/node_arch.txt) && \ + echo "Verifying checksum for node-v${NODE_VERSION}-linux-${ARCH}.tar.xz..." && \ + cat SHASUMS256.txt | grep "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" | head -n1 > checksum.txt && \ + echo "Checksum line:" && \ + cat checksum.txt && \ + sha256sum -c checksum.txt + +# Step 5: Extract and install Node.js +RUN set -ex && \ + ARCH=$(cat /tmp/node_arch.txt) && \ + echo "Extracting Node.js..." && \ mkdir -p /usr/local/node && \ tar -xJf "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" --strip-components=1 -C /usr/local/node && \ - # Create symlinks + ls -la /usr/local/node/bin/ + +# Step 6: Create symlinks +RUN set -ex && \ + echo "Creating symlinks..." && \ ln -sf /usr/local/node/bin/node /usr/local/bin/node && \ ln -sf /usr/local/node/bin/npm /usr/local/bin/npm && \ ln -sf /usr/local/node/bin/npx /usr/local/bin/npx && \ - # Verify installation + ls -la /usr/local/bin/ | grep -E "node|npm|npx" + +# Step 7: Verify installation and cleanup +RUN set -ex && \ + echo "Verifying Node.js installation..." && \ node --version && \ npm --version && \ - # Cleanup + echo "Cleaning up..." && \ rm -rf /tmp/* # Remove xz-utils as it's no longer needed From 22e42585245271d48b574f004e7fa2c04b40dc80 Mon Sep 17 00:00:00 2001 From: vladimir Date: Fri, 12 Dec 2025 11:03:39 -0500 Subject: [PATCH 2/2] fixing multi-architecture build errors --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ce6409b..c2c7bad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,7 +50,7 @@ RUN set -ex && \ ARCH=$(cat /tmp/node_arch.txt) && \ echo "Downloading Node.js v${NODE_VERSION} for ${ARCH}..." && \ curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" && \ - ls -lh node-v${NODE_VERSION}-linux-${ARCH}.tar.xz + ls -lh "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" # Step 3: Download checksum file RUN set -ex && \ @@ -63,7 +63,7 @@ RUN set -ex && \ RUN set -ex && \ ARCH=$(cat /tmp/node_arch.txt) && \ echo "Verifying checksum for node-v${NODE_VERSION}-linux-${ARCH}.tar.xz..." && \ - cat SHASUMS256.txt | grep "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" | head -n1 > checksum.txt && \ + grep "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" SHASUMS256.txt | head -n1 > checksum.txt && \ echo "Checksum line:" && \ cat checksum.txt && \ sha256sum -c checksum.txt @@ -82,7 +82,7 @@ RUN set -ex && \ ln -sf /usr/local/node/bin/node /usr/local/bin/node && \ ln -sf /usr/local/node/bin/npm /usr/local/bin/npm && \ ln -sf /usr/local/node/bin/npx /usr/local/bin/npx && \ - ls -la /usr/local/bin/ | grep -E "node|npm|npx" + ls -la /usr/local/bin/node /usr/local/bin/npm /usr/local/bin/npx # Step 7: Verify installation and cleanup RUN set -ex && \