diff --git a/docker/images/n8n-base/Dockerfile b/docker/images/n8n-base/Dockerfile index fbf20988bdc..f3e6abd094c 100644 --- a/docker/images/n8n-base/Dockerfile +++ b/docker/images/n8n-base/Dockerfile @@ -1,11 +1,7 @@ -ARG NODE_VERSION=24.16.0 - -# Pinned to multi-arch index digest (linux/amd64 + linux/arm64) for reproducible builds. -# Bump the digest together with the tag when updating the base image. -# Digest pins to dhi.io/node:24.16.0-alpine3.22-dev (Node 24.16.0, Alpine 3.22, DHI dev variant). -FROM dhi.io/node:24.16.0-alpine3.22-dev@sha256:67906dda1e458153488aecb9a7a5a926cb03cf1e8890eb8602a86a78162b2556 - -ARG NODE_VERSION +# Pinned to a multi-arch index digest (linux/amd64 + linux/arm64) for reproducible builds. +# The tag is the human-readable version; Docker resolves by the digest. Bump the tag and +# digest together when updating the base image. +FROM dhi.io/node:24.16.0-alpine3.24-dev@sha256:0fda302d7d6f2436b27edc9392bd6a4f8ae9ce86e9837c2b8676abdf26a4a7fb # Install all dependencies in a single layer to minimize image size RUN apk add --no-cache busybox-binsh && \ @@ -22,7 +18,7 @@ RUN apk add --no-cache busybox-binsh && \ # libs Node uses (the openssl CLI binary isn't needed at runtime). apk add --no-cache \ openssh \ - graphicsmagick=1.3.45-r0 `# pinned to avoid ghostscript-fonts (GPL-2.0); see SEC-398 + NODE-4184` \ + graphicsmagick \ tini \ tzdata \ ca-certificates \ @@ -31,8 +27,12 @@ RUN apk add --no-cache busybox-binsh && \ rm -rf /tmp/* /root/.npm /root/.cache/node /opt/yarn* && \ apk del apk-tools +# Alpine 3.24 ships node at /usr/bin; symlink it to /usr/local/bin so the path +# matches what the cloud launch and AppArmor profile expect. +RUN mkdir -p /usr/local/bin && ln -sf /usr/bin/node /usr/local/bin/node + WORKDIR /home/node -# DHI images use a non-standard global npm path, so we need to set NODE_PATH -# to allow externally installed npm packages to be found by require() -ENV NODE_PATH=/opt/nodejs/node-v${NODE_VERSION}/lib/node_modules +# This base image installs global npm modules under /usr/local; set NODE_PATH +# so packages added via `npm install -g` are require()-able at runtime. +ENV NODE_PATH=/usr/local/lib/node_modules EXPOSE 5678/tcp diff --git a/docker/images/n8n/Dockerfile b/docker/images/n8n/Dockerfile index 55c7a45a166..cbfe3d4ce7c 100644 --- a/docker/images/n8n/Dockerfile +++ b/docker/images/n8n/Dockerfile @@ -4,8 +4,8 @@ ARG N8N_VERSION=snapshot # Builder stage exists because the runtime base image has no toolchain. # Pinned to multi-arch index digest (linux/amd64 + linux/arm64) for reproducible builds. # Bump the digest together with the tag when updating the base image. -# Digest pins to node:24.16.0-alpine3.22 (Node 24.16.0, Alpine 3.22). -FROM node:24.16.0-alpine3.22@sha256:191c9f0080fcbbc6547a85dc0ff7988072214a355aabdc1d2ec55a7dae5eea8a AS builder +# Digest pins to node:24.16.0-alpine3.24 (Node 24.16.0, Alpine 3.24). +FROM node:24.16.0-alpine3.24@sha256:21f403ab171f2dc89bad4dd69d7721bfd15f084ccb46cdd225f31f2bc59b5c9a AS builder COPY ./compiled /usr/local/lib/node_modules/n8n RUN apk add --no-cache python3 make g++ && \ cd /usr/local/lib/node_modules/n8n && \ @@ -28,8 +28,8 @@ RUN apk add --no-cache python3 make g++ && \ # base change, so a base rebuild does not reach this image until the digest is # manually re-pinned here. Bump the digest together with the tag whenever the base # image is intentionally updated. -# Digest pins to n8nio/base:24.16.0 (Node 24.16.0, Alpine 3.22). -FROM n8nio/base:24.16.0@sha256:a1aa4005e4faebd6da3ba51ec28180a3fb421243d921fa0efbba2d21395012f0 +# Digest pins to n8nio/base:24.16.0 (Node 24.16.0, Alpine 3.24). +FROM n8nio/base:24.16.0@sha256:25e5671a1b3e11cd576bc9a4409ebf962baea993a4bc7414168dfd357e85a7e8 ARG N8N_VERSION ARG N8N_RELEASE_TYPE=dev @@ -42,7 +42,9 @@ WORKDIR /home/node COPY --from=builder /usr/local/lib/node_modules/n8n /usr/local/lib/node_modules/n8n COPY docker/images/n8n/docker-entrypoint.sh / -RUN ln -s /usr/local/lib/node_modules/n8n/bin/n8n /usr/local/bin/n8n && \ +# The Alpine 3.24 base has no /usr/local/bin (node lives in /usr/bin); create it for the symlink. +RUN mkdir -p /usr/local/bin && \ + ln -s /usr/local/lib/node_modules/n8n/bin/n8n /usr/local/bin/n8n && \ mkdir -p /home/node/.n8n && \ chown -R node:node /home/node && \ rm -rf /root/.npm /tmp/*