我正在尝试设置一个Wordpress+盖茨比Docker配置。整个Wordpress和数据库部分不是问题,运行良好。
但盖茨比的角色更多的是一个问题。其想法是构建一个映像,在该映像中安装了Gatsby CLI和节点模块,同时将整个应用程序共享到一个本地文件夹。下面是我对dockerfile
的理解
FROM node:14.11.0-alpine
RUN npm install -g gatsby-cli
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8000
CMD ["gatsby", "develop"]
下面是图像构建的输出
Building gatsby
Step 1/8 : FROM node:14.11.0-alpine
---> b85fc218c00b
Step 2/8 : RUN npm install -g gatsby-cli
---> Using cache
---> 54a997657e0d
Step 3/8 : WORKDIR /app
---> Using cache
---> a6251cad45bb
Step 4/8 : COPY package*.json ./
---> Using cache
---> 5676ab72e198
Step 5/8 : RUN npm install
---> Running in d5d0bf47093a
> sharp@0.25.4 install /app/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-linuxmusl-x64.tar.gz
> core-js@2.6.11 postinstall /app/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> core-js@3.6.5 postinstall /app/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> core-js-pure@3.6.5 postinstall /app/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> gatsby-telemetry@1.3.35 postinstall /app/node_modules/gatsby-telemetry
> node src/postinstall.js || true
> mozjpeg@7.0.0 postinstall /app/node_modules/mozjpeg
> node lib/install.js
⚠ spawn /app/node_modules/mozjpeg/vendor/cjpeg ENOENT
⚠ mozjpeg pre-build test failed
ℹ compiling from source
✖ Error: Command failed: /bin/sh -c autoreconf -fiv
/bin/sh: autoreconf: not found
at /app/node_modules/bin-build/node_modules/execa/index.js:231:11
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Promise.all (index 0)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mozjpeg@7.0.0 postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mozjpeg@7.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-09-20T14_11_52_309Z-debug.log
ERROR: Service 'gatsby' failed to build : The command '/bin/sh -c npm install' returned a non-zero code: 1
从我所得到的信息来看,node_modules
文件夹在某个地方丢失了。主要是因为我在本地文件夹里看不到。这里有一个与整个项目的回购。知道我错过了什么吗?
失败的命令是/bin/sh-c autoreconf-fiv
。您可以检查基本映像并看到它缺少autoconf
。您需要首先使用以下方法安装它:
RUN apk update && apk add autoconf
既然您提到了node_modules
:请确保在。docker中有它的条目,否则忽略命令copy。。
将覆盖映像中已经安装的任何纱线安装
。