From dd8d47f1a08fd81972fc9bb35a6f8ea24c5d076f Mon Sep 17 00:00:00 2001 From: vjgit96 Date: Wed, 25 Mar 2026 15:17:41 -0400 Subject: [PATCH] fix: replace grep -oP with sed for Node.js version extraction in Docker images (#12330) * fix: replace grep -oP with sed for Node.js version extraction in Docker builds The grep -oP (PCRE regex) command fails in the python:3.12.12-slim-trixie Docker base image because PCRE support is not available in the slim variant. This replaces grep -oP with portable sed -nE in all 5 Dockerfiles and adds an empty version guard to fail fast with a clear error message instead of producing a broken download URL. Fixes the Docker base build failure in the v1.8.2 release workflow. * fix(docker): remove broken npm self-upgrade from Docker images Node.js 22.x now bundles npm 11.x which fails when trying to self-upgrade via 'npm install -g npm@latest' in the slim Docker image. The bundled npm version is sufficient. This is the same fix as PR #12309 on release-1.9.0. --- docker/build_and_push.Dockerfile | 7 +++---- docker/build_and_push_backend.Dockerfile | 7 +++---- docker/build_and_push_base.Dockerfile | 7 +++---- docker/build_and_push_ep.Dockerfile | 7 +++---- docker/build_and_push_with_extras.Dockerfile | 7 +++---- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/docker/build_and_push.Dockerfile b/docker/build_and_push.Dockerfile index eb4e07d722..e4b6e99a05 100644 --- a/docker/build_and_push.Dockerfile +++ b/docker/build_and_push.Dockerfile @@ -88,12 +88,11 @@ RUN ARCH=$(dpkg --print-architecture) \ elif [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; \ else NODE_ARCH="$ARCH"; fi \ && NODE_VERSION=$(curl -fsSL https://nodejs.org/dist/latest-v22.x/ \ - | grep -oP "node-v\K[0-9]+\.[0-9]+\.[0-9]+(?=-linux-${NODE_ARCH}\.tar\.xz)" \ + | sed -nE "s/.*node-v([0-9]+\.[0-9]+\.[0-9]+)-linux-${NODE_ARCH}\.tar\.xz.*/\1/p" \ | head -1) \ + && if [ -z "$NODE_VERSION" ]; then echo "ERROR: Could not determine Node.js version" && exit 1; fi \ && 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 \ - && npm install -g npm@latest \ - && npm cache clean --force + | tar -xJ -C /usr/local --strip-components=1 RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data COPY --from=builder --chown=1000 /app/.venv /app/.venv diff --git a/docker/build_and_push_backend.Dockerfile b/docker/build_and_push_backend.Dockerfile index cab0585456..b233c76aaa 100644 --- a/docker/build_and_push_backend.Dockerfile +++ b/docker/build_and_push_backend.Dockerfile @@ -63,12 +63,11 @@ RUN ARCH=$(dpkg --print-architecture) \ elif [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; \ else NODE_ARCH="$ARCH"; fi \ && NODE_VERSION=$(curl -fsSL https://nodejs.org/dist/latest-v22.x/ \ - | grep -oP "node-v\K[0-9]+\.[0-9]+\.[0-9]+(?=-linux-${NODE_ARCH}\.tar\.xz)" \ + | sed -nE "s/.*node-v([0-9]+\.[0-9]+\.[0-9]+)-linux-${NODE_ARCH}\.tar\.xz.*/\1/p" \ | head -1) \ + && if [ -z "$NODE_VERSION" ]; then echo "ERROR: Could not determine Node.js version" && exit 1; fi \ && 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 \ - && npm install -g npm@latest \ - && npm cache clean --force + | tar -xJ -C /usr/local --strip-components=1 # Create non-root user RUN useradd --uid 1000 --gid 0 --no-create-home --home-dir /app/data user diff --git a/docker/build_and_push_base.Dockerfile b/docker/build_and_push_base.Dockerfile index 36dd50c0b7..fea5694a12 100644 --- a/docker/build_and_push_base.Dockerfile +++ b/docker/build_and_push_base.Dockerfile @@ -89,12 +89,11 @@ RUN ARCH=$(dpkg --print-architecture) \ elif [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; \ else NODE_ARCH="$ARCH"; fi \ && NODE_VERSION=$(curl -fsSL https://nodejs.org/dist/latest-v22.x/ \ - | grep -oP "node-v\K[0-9]+\.[0-9]+\.[0-9]+(?=-linux-${NODE_ARCH}\.tar\.xz)" \ + | sed -nE "s/.*node-v([0-9]+\.[0-9]+\.[0-9]+)-linux-${NODE_ARCH}\.tar\.xz.*/\1/p" \ | head -1) \ + && if [ -z "$NODE_VERSION" ]; then echo "ERROR: Could not determine Node.js version" && exit 1; fi \ && 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 \ - && npm install -g npm@latest \ - && npm cache clean --force + | tar -xJ -C /usr/local --strip-components=1 RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data COPY --from=builder --chown=1000 /app/.venv /app/.venv diff --git a/docker/build_and_push_ep.Dockerfile b/docker/build_and_push_ep.Dockerfile index 346fded713..183f80cd51 100644 --- a/docker/build_and_push_ep.Dockerfile +++ b/docker/build_and_push_ep.Dockerfile @@ -84,12 +84,11 @@ RUN ARCH=$(dpkg --print-architecture) \ elif [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; \ else NODE_ARCH="$ARCH"; fi \ && NODE_VERSION=$(curl -fsSL https://nodejs.org/dist/latest-v22.x/ \ - | grep -oP "node-v\K[0-9]+\.[0-9]+\.[0-9]+(?=-linux-${NODE_ARCH}\.tar\.xz)" \ + | sed -nE "s/.*node-v([0-9]+\.[0-9]+\.[0-9]+)-linux-${NODE_ARCH}\.tar\.xz.*/\1/p" \ | head -1) \ + && if [ -z "$NODE_VERSION" ]; then echo "ERROR: Could not determine Node.js version" && exit 1; fi \ && 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 \ - && npm install -g npm@latest \ - && npm cache clean --force + | tar -xJ -C /usr/local --strip-components=1 RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data COPY --from=builder --chown=1000 /app/.venv /app/.venv diff --git a/docker/build_and_push_with_extras.Dockerfile b/docker/build_and_push_with_extras.Dockerfile index dae3fbd6e4..042c480580 100644 --- a/docker/build_and_push_with_extras.Dockerfile +++ b/docker/build_and_push_with_extras.Dockerfile @@ -85,12 +85,11 @@ RUN ARCH=$(dpkg --print-architecture) \ elif [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; \ else NODE_ARCH="$ARCH"; fi \ && NODE_VERSION=$(curl -fsSL https://nodejs.org/dist/latest-v22.x/ \ - | grep -oP "node-v\K[0-9]+\.[0-9]+\.[0-9]+(?=-linux-${NODE_ARCH}\.tar\.xz)" \ + | sed -nE "s/.*node-v([0-9]+\.[0-9]+\.[0-9]+)-linux-${NODE_ARCH}\.tar\.xz.*/\1/p" \ | head -1) \ + && if [ -z "$NODE_VERSION" ]; then echo "ERROR: Could not determine Node.js version" && exit 1; fi \ && 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 \ - && npm install -g npm@latest \ - && npm cache clean --force + | tar -xJ -C /usr/local --strip-components=1 RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data COPY --from=builder --chown=1000 /app/.venv /app/.venv