Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 51 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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..." && \
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

# 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/node /usr/local/bin/npm /usr/local/bin/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
Expand Down
Loading