Skip to content

Commit bc61efa

Browse files
authored
Merge pull request #60 from udx/dependency-upgrade
fixing multi-architecture build errors
2 parents 18ec5ad + 076829b commit bc61efa

File tree

1 file changed

+14
-69
lines changed

1 file changed

+14
-69
lines changed

Dockerfile

Lines changed: 14 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -28,82 +28,27 @@ RUN set -ex && \
2828
rm -rf /var/lib/apt/lists/*
2929

3030
# Install Node.js
31-
ARG 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
4931
RUN set -ex && \
50-
ARCH=$(cat /tmp/node_arch.txt) && \
51-
echo "Downloading Node.js v${NODE_VERSION} for ${ARCH}..." && \
32+
# Detect architecture
33+
ARCH=$(dpkg --print-architecture 2>/dev/null || echo "x64") && \
34+
if [ "$ARCH" = "amd64" ]; then ARCH="x64"; fi && \
35+
if [ "$ARCH" = "arm64" ]; then ARCH="arm64"; fi && \
36+
# Download Node.js binary and checksum
5237
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..." && \
5838
curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt" && \
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-
grep "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" SHASUMS256.txt | 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..." && \
39+
# Verify checksum
40+
grep " node-v${NODE_VERSION}-linux-${ARCH}.tar.xz\$" SHASUMS256.txt | sha256sum -c - && \
41+
# Extract and install
7542
mkdir -p /usr/local/node && \
7643
tar -xJf "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" --strip-components=1 -C /usr/local/node && \
77-
ls -la /usr/local/node/bin/
78-
79-
# Step 6: Create symlinks and set permissions
80-
RUN set -ex && \
81-
echo "Creating symlinks..." && \
82-
chmod +x /usr/local/node/bin/node /usr/local/node/bin/npm /usr/local/node/bin/npx && \
44+
# Create symlinks
8345
ln -sf /usr/local/node/bin/node /usr/local/bin/node && \
8446
ln -sf /usr/local/node/bin/npm /usr/local/bin/npm && \
8547
ln -sf /usr/local/node/bin/npx /usr/local/bin/npx && \
86-
ls -la /usr/local/bin/node /usr/local/bin/npm /usr/local/bin/npx
87-
88-
# Step 7a: Check binary info
89-
RUN set -ex && \
90-
echo "Checking Node.js binary info..." && \
91-
file /usr/local/node/bin/node && \
92-
ldd /usr/local/node/bin/node || echo "ldd not available or static binary"
93-
94-
# Step 7b: Test node binary
95-
RUN set -ex && \
96-
echo "Testing node binary..." && \
97-
/usr/local/node/bin/node --version
98-
99-
# Step 7c: Test npm binary
100-
RUN set -ex && \
101-
echo "Testing npm binary..." && \
102-
/usr/local/node/bin/npm --version
103-
104-
# Step 7d: Cleanup temporary files
105-
RUN set -ex && \
106-
echo "Cleaning up temporary files..." && \
48+
# Verify installation
49+
node --version && \
50+
node /usr/local/node/lib/node_modules/npm/bin/npm-cli.js --version && \
51+
# Cleanup
10752
rm -rf /tmp/*
10853

10954
# Remove xz-utils as it's no longer needed
@@ -130,4 +75,4 @@ WORKDIR "${APP_HOME}"
13075
ENTRYPOINT ["/usr/local/worker/bin/entrypoint.sh"]
13176

13277
# Use the default command from parent image
133-
CMD ["tail", "-f", "/dev/null"]
78+
CMD ["tail", "-f", "/dev/null"]

0 commit comments

Comments
 (0)