Skip to content

Commit

Permalink
fix: Install python3 executable for node-gyp (#8998)
Browse files Browse the repository at this point in the history
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 nodejs/node-gyp#2798)

`local.Dockerfile` and `testing-drivers.Dockerfile` were not affected because they both had `python3` package installed before running `yarn install`.
  • Loading branch information
mcheshkov authored Jan 16, 2025
1 parent d9bc147 commit 9700dc8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/cubejs-docker/dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/cubejs-docker/latest-debian-jdk.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/cubejs-docker/latest.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions packages/cubejs-docker/local.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9700dc8

Please sign in to comment.