@@ -29,29 +29,67 @@ RUN set -ex && \
2929
3030# Install Node.js
3131ARG TARGETARCH
32+
33+ # Step 1: Detect and set architecture
34+ RUN set -ex && \
35+ if [ -n "$TARGETARCH" ]; then \
36+ ARCH="$TARGETARCH" ; \
37+ else \
38+ ARCH=$(dpkg --print-architecture 2>/dev/null || echo "amd64" ); \
39+ fi && \
40+ case "$ARCH" in \
41+ amd64) ARCH="x64" ;; \
42+ arm64) ARCH="arm64" ;; \
43+ *) echo "Unsupported architecture: $ARCH" && exit 1 ;; \
44+ esac && \
45+ echo "Building for architecture: $ARCH" && \
46+ echo "$ARCH" > /tmp/node_arch.txt
47+
48+ # Step 2: Download Node.js binary
3249RUN set -ex && \
33- # Detect architecture
34- ARCH="${TARGETARCH:-$(dpkg --print-architecture 2>/dev/null || echo " x64")}" && \
35- if [ "$ARCH" = "amd64" ]; then ARCH="x64" ; fi && \
36- if [ "$ARCH" = "arm64" ]; then ARCH="arm64" ; fi && \
37- echo "Detected architecture: $ARCH" && \
38- # Download Node.js binary and checksum
50+ ARCH=$(cat /tmp/node_arch.txt) && \
51+ echo "Downloading Node.js v${NODE_VERSION} for ${ARCH}..." && \
3952 curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" && \
53+ ls -lh node-v${NODE_VERSION}-linux-${ARCH}.tar.xz
54+
55+ # Step 3: Download checksum file
56+ RUN set -ex && \
57+ echo "Downloading SHASUMS256.txt..." && \
4058 curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt" && \
41- # Verify checksum
42- grep "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz\$ " SHASUMS256.txt > SHASUMS256.txt.verify && \
43- sha256sum -c SHASUMS256.txt.verify && \
44- # Extract and install
59+ echo "Contents of SHASUMS256.txt:" && \
60+ head -n 5 SHASUMS256.txt
61+
62+ # Step 4: Verify checksum
63+ RUN set -ex && \
64+ ARCH=$(cat /tmp/node_arch.txt) && \
65+ echo "Verifying checksum for node-v${NODE_VERSION}-linux-${ARCH}.tar.xz..." && \
66+ cat SHASUMS256.txt | grep "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" | head -n1 > checksum.txt && \
67+ echo "Checksum line:" && \
68+ cat checksum.txt && \
69+ sha256sum -c checksum.txt
70+
71+ # Step 5: Extract and install Node.js
72+ RUN set -ex && \
73+ ARCH=$(cat /tmp/node_arch.txt) && \
74+ echo "Extracting Node.js..." && \
4575 mkdir -p /usr/local/node && \
4676 tar -xJf "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" --strip-components=1 -C /usr/local/node && \
47- # Create symlinks
77+ ls -la /usr/local/node/bin/
78+
79+ # Step 6: Create symlinks
80+ RUN set -ex && \
81+ echo "Creating symlinks..." && \
4882 ln -sf /usr/local/node/bin/node /usr/local/bin/node && \
4983 ln -sf /usr/local/node/bin/npm /usr/local/bin/npm && \
5084 ln -sf /usr/local/node/bin/npx /usr/local/bin/npx && \
51- # Verify installation
85+ ls -la /usr/local/bin/ | grep -E "node|npm|npx"
86+
87+ # Step 7: Verify installation and cleanup
88+ RUN set -ex && \
89+ echo "Verifying Node.js installation..." && \
5290 node --version && \
5391 npm --version && \
54- # Cleanup
92+ echo "Cleaning up..." && \
5593 rm -rf /tmp/*
5694
5795# Remove xz-utils as it's no longer needed
0 commit comments