我正在尝试构建docker映像,我在终端输出中得到以下错误:
[+] Building 82.8s (10/11)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 37B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:12.10 1.0s
=> [auth] library/node:pull token for registry-1.docker.io 0.0s
=> [internal] load build context 3.8s
=> => transferring context: 139.71MB 3.8s
=> [1/6] FROM docker.io/library/node:12.10@sha256:cda22332e2dd46807a14d3268ee3fb298651386ad1f03cfd58772a7dc65f89c7 0.0s
=> CACHED [2/6] WORKDIR /src 0.0s
=> CACHED [3/6] COPY package.json package.json 0.0s
=> CACHED [4/6] COPY yarn.lock yarn.lock 0.0s
=> ERROR [5/6] RUN yarn 77.9s
------
> [5/6] RUN yarn:
#10 0.336 yarn install v1.17.3
#10 0.378 [1/5] Validating package.json...
#10 0.379 [2/5] Resolving packages...
#10 0.535 [3/5] Fetching packages...
#10 24.99 info fsevents@1.2.13: The platform "linux" is incompatible with this module.
#10 24.99 info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
#10 24.99 [4/5] Linking dependencies...
#10 24.99 warning " > @date-io/date-fns@1.3.11" has incorrect peer dependency "date-fns@2.1.0".
#10 24.99 warning " > @material-ui/pickers@3.3.10" has unmet peer dependency "@date-io/core@^1.3.6".
#10 24.99 warning " > @material-ui/pickers@3.3.10" has unmet peer dependency "prop-types@^15.6.0".
#10 24.99 warning " > bootstrap@4.1.3" has unmet peer dependency "popper.js@^1.14.3".
#10 24.99 warning " > react-moment@0.8.4" has unmet peer dependency "prop-types@^15.6.0".
#10 24.99 warning " > uglifyjs-webpack-plugin@2.2.0" has incorrect peer dependency "webpack@^4.0.0".
#10 24.99 warning " > awesome-typescript-loader@3.5.0" has incorrect peer dependency "typescript@^2".
#10 24.99 warning " > babel-loader@7.1.5" has incorrect peer dependency "webpack@2 || 3 || 4".
#10 24.99 warning " > extract-text-webpack-plugin@3.0.2" has incorrect peer dependency "webpack@^3.1.0".
#10 24.99 warning " > file-loader@1.1.11" has incorrect peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
#10 24.99 warning " > html-webpack-plugin@2.30.1" has incorrect peer dependency "webpack@1 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3".
#10 24.99 warning " > sass-loader@6.0.7" has incorrect peer dependency "node-sass@^4.0.0".
#10 24.99 warning " > sass-loader@6.0.7" has incorrect peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
#10 28.32 [5/5] Building fresh packages...
#10 28.69 warning Error running install script for optional dependency: "/src/node_modules/phantomjs-prebuilt: Command failed.
#10 28.69 Exit code: 1
#10 28.69 Command: node install.js
#10 28.69 Arguments:
#10 28.69 Directory: /src/node_modules/phantomjs-prebuilt
#10 28.69 Output:
#10 28.69 PhantomJS not found on PATH
#10 28.69 Unexpected platform or architecture: linux/arm64
#10 28.69 It seems there is no binary available for your platform/architecture
#10 28.69 Try to install PhantomJS globally"
#10 28.69 info This module is OPTIONAL, you can safely ignore this error
#10 30.05 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
#10 30.05 error /src/node_modules/canvas: Command failed.
#10 30.05 Exit code: 1
#10 30.05 Command: node-pre-gyp install --fallback-to-build
#10 30.05 Arguments:
#10 30.05 Directory: /src/node_modules/canvas
#10 30.05 Output:
#10 30.05 node-pre-gyp info it worked if it ends with ok
#10 30.05 node-pre-gyp info using node-pre-gyp@1.0.5
#10 30.05 node-pre-gyp info using node@12.10.0 | linux | arm64
#10 30.05 node-pre-gyp info check checked for "/src/node_modules/canvas/build/Release/canvas.node" (not found)
#10 30.05 node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v72-linux-glibc-arm64.tar.gz
#10 30.05 node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v72-linux-glibc-arm64.tar.gz
#10 30.05 node-pre-gyp WARN Pre-built binaries not installable for canvas@2.8.0 and node@12.10.0 (node-v72 ABI, glibc) (falling back to source compile with node-gyp)
#10 30.05 node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v72-linux-glibc-arm64.tar.gz
#10 30.05 gyp info it worked if it ends with ok
#10 30.05 gyp info using node-gyp@7.1.2
#10 30.05 gyp info using node@12.10.0 | linux | arm64
#10 30.05 gyp info ok
#10 30.05 gyp info it worked if it ends with ok
#10 30.05 gyp info using node-gyp@7.1.2
#10 30.05 gyp info using node@12.10.0 | linux | arm64
#10 30.05 gyp info find Python using Python version 3.5.3 found at "/usr/bin/python3"
#10 30.05 gyp http GET https://nodejs.org/download/release/v12.10.0/node-v12.10.0-headers.tar.gz
#10 30.05 gyp http 200 https://nodejs.org/download/release/v12.10.0/node-v12.10.0-headers.tar.gz
#10 30.05 gyp http GET https://nodejs.org/download/release/v12.10.0/SHASUMS256.txt
#10 30.05 gyp http 200 https://nodejs.org/download/release/v12.10.0/SHASUMS256.txt
#10 30.05 gyp info spawn /usr/bin/python3
#10 30.05 gyp info spawn args [
#10 30.05 gyp info spawn args '/src/node_modules/node-gyp/gyp/gyp_main.py',
#10 30.05 gyp info spawn args 'binding.gyp',
#10 30.05 gyp info spawn args '-f',
#10 30.05 gyp info spawn args 'make',
#10 30.05 gyp info spawn args '-I',
#10 30.05 gyp info spawn args '/src/node_modules/canvas/build/config.gypi',
#10 30.05 gyp info spawn args '-I',
#10 30.05 gyp info spawn args '/src/node_modules/node-gyp/addon.gypi',
#10 30.05 gyp info spawn args '-I',
#10 30.05 gyp info spawn args '/root/.cache/node-gyp/12.10.0/include/node/common.gypi',
#10 30.05 gyp info spawn args '-Dlibrary=shared_library',
#10 30.05 gyp info spawn args '-Dvisibility=default',
#10 30.05 gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/12.10.0',
#10 30.05 gyp info spawn args '-Dnode_gyp_dir=/src/node_modules/node-gyp',
#10 30.05 gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/12.10.0/<(target_arch)/node.lib',
#10 30.05 gyp info spawn args '-Dmodule_root_dir=/src/node_modules/canvas',
#10 30.05 gyp info spawn args '-Dnode_engine=v8',
#10 30.05 gyp info spawn args '--depth=.',
#10 30.05 gyp info spawn args '--no-parallel',
#10 30.05 gyp info spawn args '--generator-output',
#10 30.05 gyp info spawn args 'build',
#10 30.05 gyp info spawn args '-Goutput_dir=.'
#10 30.05 gyp info spawn args ]
#10 30.05 Package pangocairo was not found in the pkg-config search path.
#10 30.05 Perhaps you should add the directory containing `pangocairo.pc'
#10 30.05 to the PKG_CONFIG_PATH environment variable
#10 30.05 No package 'pangocairo' found
#10 30.05 gyp: Call to 'pkg-config pangocairo --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
#10 30.05 gyp ERR! configure error
#10 30.05 gyp ERR! stack Error: `gyp` failed with exit code: 1
#10 30.05 gyp ERR! stack at ChildProcess.onCpExit (/src/node_modules/node-gyp/lib/configure.js:351:16)
#10 30.05 gyp ERR! stack at ChildProcess.emit (events.js:209:13)
#10 30.05 gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
#10 30.05 gyp ERR! System Linux 5.10.47-linuxkit
#10 30.05 gyp ERR! command "/usr/local/bin/node" "/src/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/src/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/src/node_modules/canvas/build/Release" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
#10 30.05 gyp ERR! cwd /src/node_modules/canvas
#10 30.05 gyp ERR! node -v v12.10.0
#10 30.05 gyp ERR! node-gyp -v v7.1.2
#10 30.05 gyp ERR! not ok
#10 30.05 node-pre-gyp ERR! build error
#10 30.05 node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /src/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/src/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/src/node_modules/canvas/build/Release --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
#10 30.05 node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/src/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
#10 30.05 node-pre-gyp ERR! stack at ChildProcess.emit (events.js:209:13)
#10 30.05 node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
#10 30.05 node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
#10 30.05 node-pre-gyp ERR! System Linux 5.10.47-linuxkit
#10 30.05 node-pre-gyp ERR! command "/usr/local/bin/node" "/src/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
#10 30.05 node-pre-gyp ERR! cwd /src/node_modules/canvas
#10 30.05 node-pre-gyp ERR! node -v v12.10.0
#10 30.05 node-pre-gyp ERR! node-pre-gyp -v v1.0.5
#10 30.05 node-pre-gyp ERR! not ok
#10 30.05 Failed to execute '/usr/local/bin/node /src/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/src/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/src/node_modules/canvas/build/Release --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
------
这是我的Dockerfile:
FROM node:12.10
WORKDIR /src
COPY package.json package.json
COPY yarn.lock yarn.lock
RUN yarn
COPY . .
CMD ["yarn", "run", "start"]
我已经尝试了brew install pkg-config cairo pango libpng jpeg giflib librsvg
(x86_64安装与Rosetta 2)每个https://github.com/Automattic/node-canvas/issues/1684。
- 我需要尝试卸载和重新安装node-gyp吗?
任何见解都非常感谢,提前感谢。
我添加必要的依赖到我的Dockerfile,但现在得到以下错误:
[+] Building 5.7s (6/11)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 347B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:12.10 0.3s
=> [internal] load build context 0.6s
=> => transferring context: 2.42MB 0.6s
=> CACHED [1/7] FROM docker.io/library/node:12.10@sha256:cda22332e2dd46807a14d3268ee3fb298651386ad1f03cfd58772a7dc65f89c7 0.0s
=> ERROR [2/7] RUN apt-get update && apt-get -y install libcairo-dev pk-config cairo pango libpng jpeg giflib librsvg * 5.3s
------
> [2/7] RUN apt-get update && apt-get -y install libcairo-dev pk-config cairo pango libpng jpeg giflib librsvg *:
#5 0.257 Get:1 http://security.debian.org/debian-security stretch/updates InRelease [53.0 kB]
#5 0.421 Ign:2 http://deb.debian.org/debian stretch InRelease
#5 0.455 Get:3 http://security.debian.org/debian-security stretch/updates/main arm64 Packages [698 kB]
#5 0.455 Get:4 http://deb.debian.org/debian stretch-updates InRelease [93.6 kB]
#5 0.590 Get:5 http://deb.debian.org/debian stretch Release [118 kB]
#5 0.737 Get:6 http://deb.debian.org/debian stretch Release.gpg [3177 B]
#5 0.822 Get:7 http://deb.debian.org/debian stretch/main arm64 Packages [6921 kB]
#5 4.597 Fetched 7886 kB in 4s (1791 kB/s)
#5 4.597 Reading package lists...
#5 4.926 Reading package lists...
#5 5.243 Building dependency tree...
#5 5.301 Reading state information...
#5 5.311 E: Unable to locate package pk-config
#5 5.311 E: Unable to locate package cairo
#5 5.311 E: Unable to locate package pango
#5 5.311 E: Unable to locate package libpng
#5 5.311 E: Unable to locate package jpeg
#5 5.311 E: Unable to locate package giflib
#5 5.311 E: Unable to locate package librsvg
#5 5.311 E: Unable to locate package bin
#5 5.311 E: Unable to locate package boot
#5 5.311 E: Unable to locate package dev
#5 5.311 E: Unable to locate package etc
#5 5.311 E: Unable to locate package home
#5 5.311 E: Unable to locate package lib
#5 5.311 E: Unable to locate package media
#5 5.311 E: Unable to locate package mnt
#5 5.311 E: Unable to locate package proc
#5 5.311 E: Unable to locate package root
#5 5.311 E: Unable to locate package run
#5 5.311 E: Unable to locate package sbin
#5 5.311 E: Unable to locate package srv
#5 5.311 E: Unable to locate package sys
#5 5.311 E: Unable to locate package tmp
#5 5.311 E: Unable to locate package usr
#5 5.311 E: Unable to locate package var
------
executor failed running [/bin/sh -c apt-get update && apt-get -y install libcairo-dev pk-config cairo pango libpng jpeg giflib librsvg *]: exit code: 100
更新Dockerfile:
RUN apt-get update
&& apt-get -y install libcairo-dev
pk-config
cairo
pango
libpng
jpeg
giflib
librsvg *
WORKDIR /src
COPY package.json package.json
COPY yarn.lock yarn.lock
RUN yarn install
COPY . .
CMD ["yarn", "run", "start"]
你必须将这些依赖项安装在docker构建中,而不是在你的机器上。
基于您的Dockerfile的示例将是:
FROM node:12.10
# Note the dependency install
RUN apt-get update && apt-get install libcairo-dev -y
WORKDIR /src
COPY package.json package.json
COPY yarn.lock yarn.lock
RUN yarn
COPY . .
CMD ["yarn", "run", "start"]
当然,这只是一个开始,你必须添加所有必需的依赖项。