1
votes

I am kind of new to this, have react frontend and Node backend end application created and trying to deploy in docker, but its throwing the below error. Can someone pls help me why python is being referred, and why couchbase installation is having issues?

Package.json file has

{
  "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"
  ]
}

Error

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

appreciate your support on this regard

After the provided suggestion, i see below error Sending build context to Docker daemon 434.4MB [WARNING]: Empty continuation line found in: RUN apk add --update-cache python python-dev py-pip build-base WORKDIR /xpress [WARNING]: Empty continuation lines will become errors in a future release. Step 1/7 : FROM node:alpine ---> 483343d6c5f5 Step 2/7 : RUN apk add --update-cache python python-dev py-pip build-base WORKDIR /xpress ---> Running in e587974d8218 fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz ERROR: unsatisfiable constraints: /xpress (missing): required by: world[/xpress] WORKDIR (missing): required by: world[WORKDIR] The command '/bin/sh -c apk add --update-cache python python-dev py-pip build-base WORKDIR /xpress' returned a non-zero code: 2

1

1 Answers

3
votes

Apparently, node-gyp depends on a Python interpreter in the environment and couchbase depends on node-gyp to be installed. You must install Python in your Docker container.

Considering you are using alpine:node, you can install it via apk:

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

Add this command before running npm install.

This sample is taken from here: https://github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md#example

UPDATE

I'm sorry, my response was incomplete. You need to install some other dependencies, and remove them after running npm install. Take a look at this issue: https://github.com/mhart/alpine-node/issues/27#issuecomment-390187978

Note that npm install is ran between apk add and apk del, so build dependencies, such as python, are not bundled in your image

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