Skip to content
Merged
Changes from 1 commit
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
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ LABEL maintainer="[email protected]" \
org.opencontainers.image.documentation="https://github.com/beevelop/docker-android-nodejs/blob/latest/README.md" \
org.opencontainers.image.source="https://github.com/beevelop/docker-android-nodejs.git"

# Install Node.js using NodeSource repository
RUN apt-get update && apt-get install -y curl ca-certificates && \
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs && \
# Install Node.js 22 with compatible npm using official Node.js binaries
ENV NODE_VERSION=22.18.0
RUN apt-get update && apt-get install -y curl ca-certificates xz-utils && \
curl -fsSL https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz | tar -xJ -C /usr/local --strip-components=1 && \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Hardcoded linux-x64 will break non-amd64 (e.g., arm64) builds — derive arch via TARGETARCH/uname and use it in the URL.

This Dockerfile will fail or produce the wrong binary on arm64 or other platforms. Make it multi-arch friendly by mapping the docker buildx-provided TARGETARCH (or uname -m fallback) to Node’s archive naming.

Apply this diff:

-    curl -fsSL https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz | tar -xJ -C /usr/local --strip-components=1 && \
+    arch="${TARGETARCH:-$(uname -m)}"; \
+    case "$arch" in \
+      x86_64|amd64) node_arch=x64 ;; \
+      aarch64|arm64) node_arch=arm64 ;; \
+      armv7l|armv7|armhf) node_arch=armv7l ;; \
+      *) echo "Unsupported architecture: $arch" >&2; exit 1 ;; \
+    esac; \
+    curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${node_arch}.tar.xz" \
+      | tar -xJ -C /usr/local --strip-components=1 && \
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
curl -fsSL https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz | tar -xJ -C /usr/local --strip-components=1 && \
arch="${TARGETARCH:-$(uname -m)}"; \
case "$arch" in \
x86_64|amd64) node_arch=x64 ;; \
aarch64|arm64) node_arch=arm64 ;; \
armv7l|armv7|armhf) node_arch=armv7l ;; \
*) echo "Unsupported architecture: $arch" >&2; exit 1 ;; \
esac; \
curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${node_arch}.tar.xz" \
| tar -xJ -C /usr/local --strip-components=1 && \
🤖 Prompt for AI Agents
In Dockerfile around line 24, the curl URL hardcodes "linux-x64" which breaks
non-amd64 builds; change to derive arch from build ARG TARGETARCH (fallback to
uname -m), map common values (amd64 -> x64, arm64 -> arm64, arm -> armv7l, etc.)
into a NODE_ARCH variable, export NODE_ARCH and use it in the download URL
instead of linux-x64 so the correct Node archive is fetched for the target
architecture.

npm install -g npm@latest && \
npm install -g yarn && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
Expand Down