Trouble deploying Directus to an existing app, missing Python via node-gyp / Dockerfile

Trying to re-deploy an instance of https://directus.io/ that I had deployed successfully 3 months ago, but now am getting errors about Python be missing from path even though I’m installing in the Dockerfile :thinking: . I’m assuming the latest version of Directus has added (somehow) a dep on node-gyp which requires Python, but not entirely sure why Python is not being installed.

Dockerfile

FROM node:18.18.2-bullseye-slim as base

ENV PORT=6055
ENV NODE_ENV=production

RUN apt-get update && apt-get install -y openssl sqlite3 python3.5

FROM base as deps

WORKDIR /app

ADD package.json .npmrc ./

RUN npm install --production=false

FROM base as production-deps

WORKDIR /app

COPY --from=deps /app/node_modules /app/node_modules

ADD package.json .npmrc ./

RUN npm prune --production

FROM base

WORKDIR /app

COPY --from=production-deps /app/node_modules /app/node_modules

ADD . .

CMD ["bash", "cms/start.sh"]

Deploy log

❯ fly deploy
==> Verifying app config
Validating /Users/nsergeant/Code/flxwebsites/cms/fly.toml
Platform: machines
✓ Configuration is valid
--> Verified app config
==> Building image
Remote builder fly-builder-patient-pine-144 ready
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
[+] Building 0.8s (3/14)
 => [internal] load build definition from Dockerfile                                                                                                                                     0.2s
 => => transferring dockerfile: 603B                                                                                                                                                     0.2s
 => [internal] load .dockerignore                                                                                                                                                        0.1s
 => => transferring context: 72B                                                                                                                                                         0.1s
 => [internal] load metadata for docker.io/library/node:18.18.2-bullseye-slim                                                                                                            0.4s
[+] Building 82.8s (9/14)
 => [internal] load build definition from Dockerfile                                                                                                                                     0.2s
 => => transferring dockerfile: 603B                                                                                                                                                     0.2s
 => [internal] load .dockerignore                                                                                                                                                        0.1s
 => => transferring context: 72B                                                                                                                                                         0.1s
 => [internal] load metadata for docker.io/library/node:18.18.2-bullseye-slim                                                                                                            0.4s
 => [internal] load build context                                                                                                                                                        0.3s= => => transferring context: 1.97kB                                                                                                                                                      0.3s
 => [base 1/2] FROM docker.io/library/node:18.18.2-bullseye-slim@sha256:bb6a85fd0f3b0f333ae2b66b81d8d8c6bd4a8668ebedf61834f53fd66bbb8956                                                 2.9s= => => resolve docker.io/library/node:18.18.2-bullseye-slim@sha256:bb6a85fd0f3b0f333ae2b66b81d8d8c6bd4a8668ebedf61834f53fd66bbb8956                                                      0.0s
 => => sha256:69c43e7d9dbb4a7096f058b7c8d97413464719035eea68eabfc509094eacebe6 1.37kB / 1.37kB                                                                                           0.0s= => => sha256:9f4b17d4d2adf061471d35ae9b97b4eadfac277767c09f18f9f9e9d2c25ae83f 7.31kB / 7.31kB                                                                                           0.0s
 => => sha256:0bc8ff246cb8ff91066742f8f7ded40397e7aaaa925200b7bec5382d1ffcd6a0 31.42MB / 31.42MB                                                                                         0.4s= => => sha256:4b26be57672eaeb4b66e259baccb0943e72af86a55c33692545d10b9b7656b5e 4.18kB / 4.18kB                                                                                           0.1s
 => => sha256:9981e75f151eeae9eb292b88ecb331f4d7f90a055e826256e52a2c3bf4b98a96 46.38MB / 46.38MB                                                                                         0.8s= => => sha256:d9dac052b5bdfd0f0dd48a08f0ee305e3c4d92caace4d901803ae190b07cae02 2.70MB / 2.70MB                                                                                           0.3s
 => => sha256:2ddd168b64688951f766504051cdd9ff267666f7bca85848865a575af24ca21a 449B / 449B                                                                                               0.2s= => => sha256:bb6a85fd0f3b0f333ae2b66b81d8d8c6bd4a8668ebedf61834f53fd66bbb8956 1.21kB / 1.21kB                                                                                           0.0s
 => => extracting sha256:0bc8ff246cb8ff91066742f8f7ded40397e7aaaa925200b7bec5382d1ffcd6a0                                                                                                0.8s
 => => extracting sha256:4b26be57672eaeb4b66e259baccb0943e72af86a55c33692545d10b9b7656b5e                                                                                                0.0s
 => => extracting sha256:9981e75f151eeae9eb292b88ecb331f4d7f90a055e826256e52a2c3bf4b98a96                                                                                                1.3s
 => => extracting sha256:d9dac052b5bdfd0f0dd48a08f0ee305e3c4d92caace4d901803ae190b07cae02                                                                                                0.1s
 => => extracting sha256:2ddd168b64688951f766504051cdd9ff267666f7bca85848865a575af24ca21a                                                                                                0.0s
 => [base 2/2] RUN apt-get update && apt-get install -y openssl sqlite3 python3.5                                                                                                        6.2s
 => [deps 1/3] WORKDIR /app                                                                                                                                                              0.0s
 => [deps 2/3] ADD package.json .npmrc ./                                                                                                                                                0.0s
 => ERROR [deps 3/3] RUN npm install --production=false                                                                                                                                 73.1s
------
 > [deps 3/3] RUN npm install --production=false:
#0 0.538 npm WARN config production Use `--omit=dev` instead.
#0 55.59 npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
#0 55.96 npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
#0 56.81 npm WARN deprecated har-validator@5.1.5: this library is no longer supported
#0 57.00 npm WARN deprecated @types/cssnano@5.1.0: This is a stub types definition. cssnano provides its own type definitions, so you do not need this installed.
#0 57.18 npm WARN deprecated consolidate@0.15.1: Please upgrade to consolidate v1.0.0+ as it has been modernized with several long-awaited fixes implemented. Maintenance is supported by Forward Email at https://forwardemail.net ; follow/watch https://github.com/ladjs/consolidate for updates and release changelog
#0 58.18 npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
#0 58.95 npm WARN deprecated @azure/msal-node@1.18.4: A newer major version of this library is available. Please upgrade to the latest available version.
#0 60.00 npm WARN deprecated @azure/msal-browser@2.38.3: A newer major version of this library is available. Please upgrade to the latest available version.
#0 62.39 npm WARN deprecated json2csv@5.0.7: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
#0 63.82 npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
#0 72.93 npm notice
#0 72.93 npm notice New major version of npm available! 9.8.1 -> 10.2.3
#0 72.93 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.2.3>
#0 72.93 npm notice Run `npm install -g npm@10.2.3` to update!
#0 72.93 npm notice
#0 72.94 npm ERR! code 1
#0 72.94 npm ERR! path /app/node_modules/isolated-vm
#0 72.94 npm ERR! command failed
#0 72.94 npm ERR! command sh -c prebuild-install || (node-gyp rebuild --release -j 4 && node-gyp clean)
#0 72.94 npm ERR! prebuild-install warn install /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /app/node_modules/isolated-vm/out/isolated_vm.node)
#0 72.94 npm ERR! gyp info it worked if it ends with ok
#0 72.94 npm ERR! gyp info using node-gyp@8.4.1
#0 72.94 npm ERR! gyp info using node@18.18.2 | linux | x64
#0 72.94 npm ERR! gyp ERR! find Python
#0 72.94 npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
#0 72.94 npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
#0 72.94 npm ERR! gyp ERR! find Python checking if "python3" can be used
#0 72.94 npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
#0 72.94 npm ERR! gyp ERR! find Python checking if "python" can be used
#0 72.94 npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
#0 72.94 npm ERR! gyp ERR! find Python
#0 72.94 npm ERR! gyp ERR! find Python **********************************************************
#0 72.94 npm ERR! gyp ERR! find Python You need to install the latest version of Python.
#0 72.94 npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#0 72.94 npm ERR! gyp ERR! find Python you can try one of the following options:
#0 72.94 npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#0 72.94 npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
#0 72.94 npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
#0 72.94 npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
#0 72.94 npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
#0 72.94 npm ERR! gyp ERR! find Python For more information consult the documentation at:
#0 72.94 npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#0 72.94 npm ERR! gyp ERR! find Python **********************************************************
#0 72.94 npm ERR! gyp ERR! find Python
#0 72.94 npm ERR! gyp ERR! configure error
#0 72.94 npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
#0 72.94 npm ERR! gyp ERR! stack     at PythonFinder.fail (/app/node_modules/node-gyp/lib/find-python.js:330:47)
#0 72.94 npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/app/node_modules/node-gyp/lib/find-python.js:159:21)
#0 72.94 npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/app/node_modules/node-gyp/lib/find-python.js:202:16)
#0 72.94 npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/app/node_modules/node-gyp/lib/find-python.js:294:16)
#0 72.94 npm ERR! gyp ERR! stack     at exithandler (node:child_process:430:5)
#0 72.94 npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:442:5)
#0 72.94 npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
#0 72.94 npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:290:12)
#0 72.94 npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:477:16)
#0 72.94 npm ERR! gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
#0 72.94 npm ERR! gyp ERR! System Linux 5.15.98-fly
#0 72.94 npm ERR! gyp ERR! command "/usr/local/bin/node" "/app/node_modules/.bin/node-gyp" "rebuild" "--release" "-j" "4"
#0 72.94 npm ERR! gyp ERR! cwd /app/node_modules/isolated-vm
#0 72.94 npm ERR! gyp ERR! node -v v18.18.2
#0 72.94 npm ERR! gyp ERR! node-gyp -v v8.4.1
#0 72.94 npm ERR! gyp ERR! not ok

:man_facepalming: I needed to install both python3 and python3-pip.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.