From 9700dc83838479ed9453c9e10e6f1cec3ad4cdd6 Mon Sep 17 00:00:00 2001 From: Mikhail Cheshkov Date: Thu, 16 Jan 2025 18:56:58 +0300 Subject: [PATCH] fix: Install python3 executable for node-gyp (#8998) By default node-gyp looks only for `python` and `python3` executables, and python3.11 package installs only `python3.11`. That leads to failure during installation optional dependency `java` from npm even in `-jdk` image Without `python3` executable `java` fails during installation, and because it is marked optional, installation is successful. But later, at runtime any JDBC driver would fail with `Cannot find module 'java'`, even in image with JDK installed. This commit installs `python3` executable, as expected by node-gyp, but there are alternative approaches: * Use `PYTHON` environment variable * Use `npm/yarn config set python`, but that is not supported in npm 9 and newer (See https://github.com/nodejs/node-gyp/issues/2798) `local.Dockerfile` and `testing-drivers.Dockerfile` were not affected because they both had `python3` package installed before running `yarn install`. --- packages/cubejs-docker/dev.Dockerfile | 3 ++- packages/cubejs-docker/latest-debian-jdk.Dockerfile | 3 ++- packages/cubejs-docker/latest.Dockerfile | 3 ++- packages/cubejs-docker/local.Dockerfile | 5 +++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/cubejs-docker/dev.Dockerfile b/packages/cubejs-docker/dev.Dockerfile index faf0f6f9df532..ce234c0969df6 100644 --- a/packages/cubejs-docker/dev.Dockerfile +++ b/packages/cubejs-docker/dev.Dockerfile @@ -8,8 +8,9 @@ ENV CI=0 RUN DEBIAN_FRONTEND=noninteractive \ && apt-get update \ + # python3 package is necessary to install `python3` executable for node-gyp && apt-get install -y --no-install-recommends libssl3 curl \ - cmake python3.11 libpython3.11-dev gcc g++ make cmake openjdk-17-jdk-headless \ + cmake python3 python3.11 libpython3.11-dev gcc g++ make cmake openjdk-17-jdk-headless \ && rm -rf /var/lib/apt/lists/* ENV RUSTUP_HOME=/usr/local/rustup diff --git a/packages/cubejs-docker/latest-debian-jdk.Dockerfile b/packages/cubejs-docker/latest-debian-jdk.Dockerfile index 67bf6b607cf10..4197ddbe2c1e4 100644 --- a/packages/cubejs-docker/latest-debian-jdk.Dockerfile +++ b/packages/cubejs-docker/latest-debian-jdk.Dockerfile @@ -10,8 +10,9 @@ RUN yarn config set network-timeout 120000 -g # Required for node-oracledb to buld on ARM64 RUN apt-get update \ + # python3 package is necessary to install `python3` executable for node-gyp # libpython3-dev is needed to trigger post-installer to download native with python - && apt-get install -y python3.11 libpython3.11-dev gcc g++ make cmake openjdk-17-jdk-headless \ + && apt-get install -y python3 python3.11 libpython3.11-dev gcc g++ make cmake openjdk-17-jdk-headless \ && rm -rf /var/lib/apt/lists/* # We are copying root yarn.lock file to the context folder during the Publish GH diff --git a/packages/cubejs-docker/latest.Dockerfile b/packages/cubejs-docker/latest.Dockerfile index 81dda462810a1..f8029d96b74ba 100644 --- a/packages/cubejs-docker/latest.Dockerfile +++ b/packages/cubejs-docker/latest.Dockerfile @@ -9,8 +9,9 @@ RUN yarn config set network-timeout 120000 -g # Required for node-oracledb to buld on ARM64 RUN apt-get update \ + # python3 package is necessary to install `python3` executable for node-gyp # libpython3-dev is needed to trigger post-installer to download native with python - && apt-get install -y python3.11 libpython3.11-dev gcc g++ make cmake \ + && apt-get install -y python3 python3.11 libpython3.11-dev gcc g++ make cmake \ && rm -rf /var/lib/apt/lists/* # We are copying root yarn.lock file to the context folder during the Publish GH diff --git a/packages/cubejs-docker/local.Dockerfile b/packages/cubejs-docker/local.Dockerfile index 49f4e755d273c..64d9bd5a8773e 100644 --- a/packages/cubejs-docker/local.Dockerfile +++ b/packages/cubejs-docker/local.Dockerfile @@ -10,7 +10,8 @@ ENV CUBEJS_DOCKER_IMAGE_TAG=latest RUN DEBIAN_FRONTEND=noninteractive \ && apt-get update \ - && apt-get install -y --no-install-recommends libssl3 python3.11 libpython3.11-dev \ + # python3 package is necessary to install `python3` executable for node-gyp + && apt-get install -y --no-install-recommends libssl3 python3 python3.11 libpython3.11-dev \ && rm -rf /var/lib/apt/lists/* ENV NODE_ENV=production @@ -30,7 +31,7 @@ RUN yarn config set network-timeout 120000 -g # Required for node-oracledb to buld on ARM64 RUN apt-get update \ - && apt-get install -y python3 gcc g++ make cmake \ + && apt-get install -y gcc g++ make cmake \ && rm -rf /var/lib/apt/lists/* # We are copying root yarn.lock file to the context folder during the Publish GH