Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Dockerfile: add packages necessary for yarn install of `canvas@2.11…
Browse files Browse the repository at this point in the history
….2` to succeed [+]

Added packages mentioned in [this comment](node-gfx/node-canvas-prebuilt#77 (comment)) of [linux\-musl build \ExLibrisGroup#77](node-gfx/node-canvas-prebuilt#77) to fix this problem in `docker compose` `web` build:

```shell
Command: node-pre-gyp install --fallback-to-build --update-binary
Arguments:
Directory: /tmp/node_modules/canvas
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@1.0.10
node-pre-gyp info using node@16.17.0 | linux | x64
node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v93-linux-musl-x64.tar.gz
node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v93-linux-musl-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@16.17.0 (node-v93 ABI, musl) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v93-linux-musl-x64.tar.gz
gyp info it worked if it ends with ok
gyp info using node-gyp@9.0.0
gyp info using node@16.17.0 | linux | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.0.0
gyp info using node@16.17.0 | linux | x64
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16)
gyp ERR! stack     at exithandler (node:child_process:408:5)
gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:420:5)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
gyp ERR! stack     at onErrorNT (node:internal/child_process:478:16)
gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
gyp ERR! System Linux 5.4.0-1025-aws
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--update-binary" "--module=/tmp/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/tmp/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
gyp ERR! cwd /tmp/node_modules/canvas
gyp ERR! node -v v16.17.0
gyp ERR! node-gyp -v v9.0.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/tmp/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/tmp/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/tmp/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1093:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
node-pre-gyp ERR! System Linux 5.4.0-1025-aws
node-pre-gyp ERR! command "/usr/local/bin/node" "/tmp/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
node-pre-gyp ERR! cwd /tmp/node_modules/canvas
node-pre-gyp ERR! node -v v16.17.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.10
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/tmp/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/tmp/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
ERROR: Service 'web' failed to build: The command '/bin/sh -c cd /tmp && yarn install --frozen-lockfile --ignore-optional   && mkdir -p $INSTALL_PATH   && cd $INSTALL_PATH   && cp -R /tmp/node_modules $INSTALL_PATH   && rm -r /tmp/* && yarn cache clean' returned a non-zero code: 1
```

For details, see `canvas` issue: [How to Troubleshoot Installation \#1511](Automattic/node-canvas#1511)
  • Loading branch information
da70 committed May 8, 2023
1 parent c7f068b commit 98e4930
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,24 @@ ENV INSTALL_PATH /app
ENV PATH $INSTALL_PATH/node_modules/.bin:${PATH}
ENV VIEW=CENTRAL_PACKAGE

# Install essentials
RUN apk update && apk add build-base git
# Install essentials and packages needed for `yarn install` to succeed.
# The last two `apk add` lines are needed to install `canvas@2.11.2` on alpine.
# `canvas` is a dependency of `devDependency` `protractor-image-comparison@3.1.0`.
#
# Source for the packages: https://github.com/node-gfx/node-canvas-prebuilt/issues/77#issuecomment-884365161
# NOTE: removed `ttf-ubuntu-font-family` to clear this error:
#
# ERROR: unable to select packages:
# ttf-ubuntu-font-family (no such package):
# required by: world[ttf-ubuntu-font-family]
# The command '/bin/sh -c apk update && apk add build-base git && apk add --no-cache g++ cairo-dev jpeg-dev pango-dev giflib-dev && apk add --update --repository http://dl-3.alpinelinux.org/alpine/edge/testing libmount ttf-dejavu ttf-droid ttf-freefont ttf-liberation ttf-ubuntu-font-family fontconfig' returned a non-zero code: 1
# ERROR: Service 'web' failed to build : Build failed
#
# For more details, see `canvas` GitHub issue:
# [How to Troubleshoot Installation \#1511](https://github.com/Automattic/node-canvas/issues/1511)
RUN apk update && apk add build-base git \
&& apk add --no-cache g++ cairo-dev jpeg-dev pango-dev giflib-dev \
&& apk add --update --repository http://dl-3.alpinelinux.org/alpine/edge/testing libmount ttf-dejavu ttf-droid ttf-freefont ttf-liberation fontconfig

# Install node_modules with yarn
ADD package.json yarn.lock /tmp/
Expand Down

0 comments on commit 98e4930

Please sign in to comment.