From ea9e710c4e8d01b124e07ec084b0ac47469fc922 Mon Sep 17 00:00:00 2001 From: vijay kumar katuri Date: Wed, 25 Mar 2026 13:50:44 -0400 Subject: [PATCH] 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. --- docker/build_and_push.Dockerfile | 3 ++- docker/build_and_push_backend.Dockerfile | 3 ++- docker/build_and_push_base.Dockerfile | 3 ++- docker/build_and_push_ep.Dockerfile | 3 ++- docker/build_and_push_with_extras.Dockerfile | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docker/build_and_push.Dockerfile b/docker/build_and_push.Dockerfile index 2c4c55040f2c..e4b6e99a0542 100644 --- a/docker/build_and_push.Dockerfile +++ b/docker/build_and_push.Dockerfile @@ -88,8 +88,9 @@ 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 RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data diff --git a/docker/build_and_push_backend.Dockerfile b/docker/build_and_push_backend.Dockerfile index 64ca06703afa..b233c76aaac2 100644 --- a/docker/build_and_push_backend.Dockerfile +++ b/docker/build_and_push_backend.Dockerfile @@ -63,8 +63,9 @@ 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 diff --git a/docker/build_and_push_base.Dockerfile b/docker/build_and_push_base.Dockerfile index 1f6db5e3e34e..fea5694a1262 100644 --- a/docker/build_and_push_base.Dockerfile +++ b/docker/build_and_push_base.Dockerfile @@ -89,8 +89,9 @@ 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 RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data diff --git a/docker/build_and_push_ep.Dockerfile b/docker/build_and_push_ep.Dockerfile index 2b3d179e9056..183f80cd51eb 100644 --- a/docker/build_and_push_ep.Dockerfile +++ b/docker/build_and_push_ep.Dockerfile @@ -84,8 +84,9 @@ 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 RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data diff --git a/docker/build_and_push_with_extras.Dockerfile b/docker/build_and_push_with_extras.Dockerfile index fd54f02c4584..042c480580e2 100644 --- a/docker/build_and_push_with_extras.Dockerfile +++ b/docker/build_and_push_with_extras.Dockerfile @@ -85,8 +85,9 @@ 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 RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data