反应|节点应用| Docker部署

问题描述 投票:0回答:1

我对此很陌生,已经创建了前端和Node后端应用程序并试图在docker中进行部署,但是它抛出以下错误。有人可以帮我解释为什么为什么要引用python以及为什么bedbedbase安装出现问题吗?

Package.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
> [email protected] 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: [email protected] (node_modules/react-scripts/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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

感谢您对此的支持

node.js reactjs docker couchbase
1个回答
0
投票

显然,node-gyp depends on a Python interpreter in the environment和沙发床取决于要安装的node-gyp。您必须在Docker容器中安装Python。

考虑到您正在使用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

© www.soinside.com 2019 - 2024. All rights reserved.