docker -составить не может собрать приложение Gatsby npm проблема - PullRequest
0 голосов
/ 09 февраля 2020

Я только начал использовать Docker. У меня очень простая структура проекта, основанная на гнезде js в качестве бэкэнда и Гэтсби в качестве внешнего интерфейса. Я использую docker -compose для запуска как бэкэнда, так и клиента. И бэкэнд, и клиент имеют Dockerfile. Где гнездо js работает без проблем и работает на порту :3000, но Гэтсби выдает некоторые ошибки при сборке.

Dockerfile для гнезда js:

FROM node:12-alpine

WORKDIR /usr/src/app/backend

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3000

CMD [ "npm", "start" ]

Dockerfile для Гэтсби:

FROM node:12-alpine

WORKDIR /usr/src/app/client

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8000

CMD [ "npm", "start" ]

мой docker-compose.yml файл:

version: "3"

services:
  backend:
    image: docker-nestjs-backend
    build: ./backend
    command: npm start
    volumes:
      - ./backend:/usr/src/app/backend
      - /usr/src/app/backend/node_modules
    ports:
      - 3002:3000

  client:
    image: docker-gatsby-client
    build: ./client
    command: npm start
    volumes:
      - ./client:/usr/src/app/client
      - /usr/src/app/client/node_modules
    ports:
      - 8000:8000
    depends_on:
      - backend


и вот что я получаю обратно в Терминале:

Creating network "cwr_default" with the default driver
Building backend
Step 1/7 : FROM node:12-alpine
12-alpine: Pulling from library/node
c9b1b535fdd9: Pull complete
750cdd924064: Pull complete
2078ab7cf9df: Pull complete
02f523899354: Pull complete
Digest: sha256:e280e51eaa6e626e4df58a5c1f141e453807c30596179330992c55a0bf4114ca
Status: Downloaded newer image for node:12-alpine
 ---> afd897e3184b
Step 2/7 : WORKDIR /usr/src/app/backend
 ---> Running in b07d7945e145
Removing intermediate container b07d7945e145
 ---> 2b9a35fe4b56
Step 3/7 : COPY package*.json ./
 ---> 9c20c9b6c88a
Step 4/7 : RUN npm install
 ---> Running in 4dac91dfce96

> @nestjs/core@6.11.6 postinstall /usr/src/app/backend/node_modules/@nestjs/core
> opencollective || exit 0

                           Thanks for installing nest 
                 Please consider donating to our open collective
                        to help us maintain this package.

                           Number of contributors: 406
                              Number of backers: 289
                              Annual budget: $56,036
                             Current balance: $1,623

             Become a partner: https://opencollective.com/nest/donate

npm WARN backend@0.0.1 No description
npm WARN backend@0.0.1 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 1093 packages from 696 contributors and audited 910291 packages in 29.688s

32 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Removing intermediate container 4dac91dfce96
 ---> 21f3869db087
Step 5/7 : COPY . .
 ---> c61ad09009c6
Step 6/7 : EXPOSE 3000
 ---> Running in b81c69060fc8
Removing intermediate container b81c69060fc8
 ---> 114c5ed9f29b
Step 7/7 : CMD [ "npm", "start" ]
 ---> Running in 8d84e41f0fe8
Removing intermediate container 8d84e41f0fe8
 ---> 7785df15b2c9
Successfully built 7785df15b2c9
Successfully tagged docker-nestjs-backend:latest
WARNING: Image for service backend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Building client
Step 1/7 : FROM node:12-alpine
 ---> afd897e3184b
Step 2/7 : WORKDIR /usr/src/app/client
 ---> Running in 5e2d91bc4031
Removing intermediate container 5e2d91bc4031
 ---> 64d6238fa83a
Step 3/7 : COPY package*.json ./
 ---> 1a7b60b8e0bd
Step 4/7 : RUN npm install
 ---> Running in a927c5229081

> sharp@0.23.4 install /usr/src/app/client/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.8.1/libvips-8.8.1-linuxmusl-x64.tar.gz

> core-js@2.6.11 postinstall /usr/src/app/client/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.4 postinstall /usr/src/app/client/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.1.47 postinstall /usr/src/app/client/node_modules/gatsby-telemetry
> node src/postinstall.js || true

╔════════════════════════════════════════════════════════════════════════╗
║                                                                        ║
║   Gatsby collects anonymous usage analytics                            ║
║   to help improve Gatsby for all users.                                ║
║                                                                        ║
║   If you'd like to opt-out, you can use `gatsby telemetry --disable`   ║
║   To learn more, checkout https://gatsby.dev/telemetry                 ║
║                                                                        ║
╚════════════════════════════════════════════════════════════════════════╝
^[[20;149R
> cwebp-bin@5.1.0 postinstall /usr/src/app/client/node_modules/cwebp-bin
> node lib/install.js

  ⚠ spawn /usr/src/app/client/node_modules/cwebp-bin/vendor/cwebp ENOENT
  ⚠ cwebp pre-build test failed
  ℹ compiling from source
  ✖ Error: Command failed: /bin/sh -c ./configure --disable-shared --prefix="/usr/src/app/client/node_modules/cwebp-bin/vendor" --bindir="/usr/src/app/client/node_modules/cwebp-bin/vendor"
configure: error: in `/usr/src/app/client/node_modules/cwebp-bin/480eb720-43ce-41c4-974d-409b7a015676':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking whether make supports nested variables... no
checking for style of include used by make... none
checking for gcc... no
checking for cc... no
checking for cl.exe... no

    at /usr/src/app/client/node_modules/bin-build/node_modules/execa/index.js:231:11
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async Promise.all (index 0)

> mozjpeg@6.0.1 postinstall /usr/src/app/client/node_modules/mozjpeg
> node lib/install.js

  ⚠ spawn /usr/src/app/client/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 /usr/src/app/client/node_modules/bin-build/node_modules/execa/index.js:231:11
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async Promise.all (index 0)

> pngquant-bin@5.0.2 postinstall /usr/src/app/client/node_modules/pngquant-bin
> node lib/install.js

  ✔ pngquant pre-build test passed successfully

> gatsby-cli@2.8.27 postinstall /usr/src/app/client/node_modules/gatsby/node_modules/gatsby-cli
> node scripts/postinstall.js


> gatsby@2.19.7 postinstall /usr/src/app/client/node_modules/gatsby
> node scripts/postinstall.js

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 1991 packages from 980 contributors and audited 23093 packages in 48.538s

40 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Removing intermediate container a927c5229081
 ---> 29563dd3fd59
Step 5/7 : COPY . .
 ---> 8d275e717a7f
Step 6/7 : EXPOSE 8000
 ---> Running in b1f9c944d0eb
Removing intermediate container b1f9c944d0eb
 ---> 77789e60189e
Step 7/7 : CMD [ "npm", "start" ]
 ---> Running in 4222ee128e48
Removing intermediate container 4222ee128e48
 ---> d64965213fff
Successfully built d64965213fff
Successfully tagged docker-gatsby-client:latest
WARNING: Image for service client was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating cwr_backend_1 ... done
Creating cwr_client_1  ... done
Attaching to cwr_backend_1, cwr_client_1
backend_1  | 
backend_1  | > backend@0.0.1 start /usr/src/app/backend
backend_1  | > nest start
backend_1  | 
client_1   | 
client_1   | > gatsby-starter-default@0.1.0 start /usr/src/app/client
client_1   | > npm run develop
client_1   | 
client_1   | 
client_1   | > gatsby-starter-default@0.1.0 develop /usr/src/app/client
client_1   | > gatsby develop
client_1   | 
client_1   | ╔════════════════════════════════════════════════════════════════════════╗
client_1   | ║                                                                        ║
client_1   | ║   Gatsby collects anonymous usage analytics                            ║
client_1   | ║   to help improve Gatsby for all users.                                ║
client_1   | ║                                                                        ║
client_1   | ║   If you'd like to opt-out, you can use `gatsby telemetry --disable`   ║
client_1   | ║   To learn more, checkout https://gatsby.dev/telemetry                 ║
client_1   | ║                                                                        ║
client_1   | ╚════════════════════════════════════════════════════════════════════════╝
^[[20;149Rclient_1   | success open and validate gatsby-configs - 0.023s
client_1   | 
client_1   |  ERROR
client_1   | 
client_1   | Error in "/usr/src/app/client/node_modules/gatsby-transformer-sharp/gatsby-node.js": 'linux-x64' binaries cannot be used on the 'linuxmusl-x64' platform. Please remove the 'node_modules/sharp/vendor' directory and run 'npm install'.
client_1   | 
client_1   | 
client_1   | 
client_1   |   Error: 'linux-x64' binaries cannot be used on the 'linuxmusl-x64' platform. Pl  ease remove the 'node_modules/sharp/vendor' directory and run 'npm install'.
client_1   |   
client_1   |   - libvips.js:67 Object.hasVendoredLibvips
client_1   |     [client]/[sharp]/lib/libvips.js:67:13
client_1   |   
client_1   |   - constructor.js:8 Object.<anonymous>
client_1   |     [client]/[sharp]/lib/constructor.js:8:22
client_1   |   
client_1   |   - v8-compile-cache.js:178 Module._compile
client_1   |     [client]/[v8-compile-cache]/v8-compile-cache.js:178:30
client_1   |   
client_1   |   - loader.js:991 Object.Module._extensions..js
client_1   |     internal/modules/cjs/loader.js:991:10
client_1   |   
client_1   |   - loader.js:811 Module.load
client_1   |     internal/modules/cjs/loader.js:811:32
client_1   |   
client_1   |   - loader.js:723 Function.Module._load
client_1   |     internal/modules/cjs/loader.js:723:14
client_1   |   
client_1   |   - loader.js:848 Module.require
client_1   |     internal/modules/cjs/loader.js:848:19
client_1   |   
client_1   |   - v8-compile-cache.js:159 require
client_1   |     [client]/[v8-compile-cache]/v8-compile-cache.js:159:20
client_1   |   
client_1   |   - index.js:3 Object.<anonymous>
client_1   |     [client]/[sharp]/lib/index.js:3:15
client_1   |   
client_1   |   - v8-compile-cache.js:178 Module._compile
client_1   |     [client]/[v8-compile-cache]/v8-compile-cache.js:178:30
client_1   |   
client_1   |   - loader.js:991 Object.Module._extensions..js
client_1   |     internal/modules/cjs/loader.js:991:10
client_1   |   
client_1   |   - loader.js:811 Module.load
client_1   |     internal/modules/cjs/loader.js:811:32
client_1   |   
client_1   |   - loader.js:723 Function.Module._load
client_1   |     internal/modules/cjs/loader.js:723:14
client_1   |   
client_1   |   - loader.js:848 Module.require
client_1   |     internal/modules/cjs/loader.js:848:19
client_1   |   
client_1   |   - v8-compile-cache.js:159 require
client_1   |     [client]/[v8-compile-cache]/v8-compile-cache.js:159:20
client_1   |   
client_1   |   - safe-sharp.js:127 Object.<anonymous>
client_1   |     [client]/[gatsby-plugin-sharp]/safe-sharp.js:127:11
client_1   |   
client_1   | 
client_1   | not finished load plugins - 0.192s
client_1   | npm ERR! code ELIFECYCLE
client_1   | npm ERR! errno 1
client_1   | npm ERR! gatsby-starter-default@0.1.0 develop: `gatsby develop`
client_1   | npm ERR! Exit status 1
client_1   | npm ERR! 
client_1   | npm ERR! Failed at the gatsby-starter-default@0.1.0 develop script.
client_1   | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
client_1   | 
client_1   | npm ERR! A complete log of this run can be found in:
client_1   | npm ERR!     /root/.npm/_logs/2020-02-08T23_01_53_782Z-debug.log
client_1   | npm ERR! code ELIFECYCLE
client_1   | npm ERR! errno 1
client_1   | npm ERR! gatsby-starter-default@0.1.0 start: `npm run develop`
client_1   | npm ERR! Exit status 1
client_1   | npm ERR! 
client_1   | npm ERR! Failed at the gatsby-starter-default@0.1.0 start script.
client_1   | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
client_1   | 
client_1   | npm ERR! A complete log of this run can be found in:
client_1   | npm ERR!     /root/.npm/_logs/2020-02-08T23_01_53_807Z-debug.log
cwr_client_1 exited with code 1
backend_1  | [Nest] 28   - 02/08/2020, 11:01:56 PM   [NestFactory] Starting Nest application...
backend_1  | [Nest] 28   - 02/08/2020, 11:01:56 PM   [InstanceLoader] AppModule dependencies initialized +15ms
backend_1  | [Nest] 28   - 02/08/2020, 11:01:56 PM   [RoutesResolver] AppController {/}: +4ms
backend_1  | [Nest] 28   - 02/08/2020, 11:01:56 PM   [RouterExplorer] Mapped {/, GET} route +2ms
backend_1  | [Nest] 28   - 02/08/2020, 11:01:56 PM   [NestApplication] Nest application successfully started +2ms

Я удалил весь каталог node_module и повторно выполнил команду npm install в каталоге, чтобы переустановить весь пакет, а также перестроил docker изображение, но я все еще получаю сообщение об ошибке.

Любые рекомендации по устранению этой проблемы приветствуются.

...