Реагировать | Узел приложения | Docker развертывание - PullRequest
0 голосов
/ 28 марта 2020

Я новичок в этом вопросе, мне пришлось создать приложение для внешнего интерфейса и внутреннего интерфейса Node, которое пытается развернуть в docker, но выдает следующую ошибку. Может кто-нибудь, пожалуйста, помогите мне, почему python ссылается, и почему установка couchbase имеет проблемы?

Пакет. json файл имеет

{
  "name": "XPress",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "antd": "^3.10.8",
    "axios": "^0.18.1",
    "body-parser": "^1.19.0",
    "cors": "2.8.5",
    "couchbase": "^2.6.11",
    "dva": "^2.4.1",
    "dva-loading": "^2.0.6",
    "express": "^4.17.1",
    "pg": "^7.18.2",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "react-scripts": "2.1.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app",
    "parser": "babel-eslint",
    "parserOptions": {
      "sourceType": "module",
      "allowImportExportEverywhere": true
    }
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

Ошибка

TestUser-8681:Utility TestUser$ docker build . -t xpressimg
Sending build context to Docker daemon  434.4MB
Step 1/7 : FROM  node:alpine
 ---> 483343d6c5f5
Step 2/7 : WORKDIR /xpress
 ---> Using cache
 ---> fc35b4f51420
Step 3/7 : COPY package*.json ./
 ---> Using cache
 ---> 5593b2fe0b05
Step 4/7 : RUN npm install
 ---> Running in f00b67e0b069
> couchbase@2.6.11 install /xpress/node_modules/couchbase
> prebuild-install || node-gyp rebuild
prebuild-install WARN install unable to get local issuer certificate
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 "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
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
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:307:47)
gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:136:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:179:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:271:16)
gyp ERR! stack     at exithandler (child_process.js:310:5)
gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:322:5)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
gyp ERR! stack     at onErrorNT (internal/child_process.js:467:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:84:21)
gyp ERR! System Linux 4.19.76-linuxkit
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /xpress/node_modules/couchbase
gyp ERR! node -v v13.12.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/react-scripts/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
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 ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! couchbase@2.6.11 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the couchbase@2.6.11 install 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-03-28T03_12_19_475Z-debug.log
The command '/bin/sh -c npm install' returned a non-zero code: 1

ценим вашу поддержку в этом отношении

После предоставленного предложения я вижу ошибку ниже При отправке контекста сборки в Docker демон 434,4 МБ [ПРЕДУПРЕЖДЕНИЕ]: в продолжение найдена пустая строка продолжения: RUN apk add --update-cache python python -dev py-pip build-base WORKDIR / xpress [ПРЕДУПРЕЖДЕНИЕ]: Пустые строки продолжения станут ошибками в следующем выпуске. Шаг 1/7: узел FROM: alpine ---> 483343d6c5f5 Шаг 2/7: RUN apk add --update-cache python python -dev py-pip build-base WORKDIR / xpress ---> Запуск в e587974d8218 выборка http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz выборка http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz ОШИБКА: неудовлетворительные ограничения: / xpress (отсутствует): требуется: world [/ xpress] WORKDIR (отсутствует): требуется: world [ WORKDIR] Команда '/ bin / sh - c apk add --update-cache python python -dev py-pip build-base WORKDIR / xpress' вернула ненулевой код: 2

1 Ответ

1 голос
/ 28 марта 2020

Очевидно, node-gyp зависит от Python интерпретатора в среде , а couchbase зависит от устанавливаемого node-gyp. Вы должны установить Python в свой контейнер Docker.

Учитывая, что вы используете alpine:node, вы можете установить его с помощью apk:

RUN apk add --update-cache \
    python \
    python-dev \
    py-pip \
    build-base

Добавить эту команду перед запуском npm install.

Этот образец взят отсюда: https://github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md#example

ОБНОВЛЕНИЕ

Извините, мой ответ был неполным. Вам нужно установить некоторые другие зависимости и удалить их после запуска npm install. Взгляните на эту проблему: https://github.com/mhart/alpine-node/issues/27#issuecomment -390187978

Обратите внимание, что установка npm выполняется между apk add и apk del, поэтому необходимо строить зависимости, такие как python, не входят в ваш образ

RUN apk add --no-cache --virtual .build-deps make gcc g++ python \
 && npm install --production --silent \
 && apk del .build-deps
...