0

I have one project. And when i try it with "docker-compose up" command on my Windows-PC all is good! Docker do it perfectly without error. But when i try this project on MacOS, i get error on "RUN npm i" step. Why? I get error on the end of error's message - failed to solve: executor failed running [/bin/sh -c npm i]: exit code: 1

Full error log:

> [111-backend builder 4/6] RUN npm i:
#0 4.159 npm WARN deprecated preview-email@3.0.5: Please upgrade to v3.0.7+ as we have added iOS Simulator support to previewing emails! See <https://github.com/forwardemail/preview-email/releases/tag/v3.0.6> and screenshots at <https://github.com/forwardemail/preview-email\#ios-simulator>.
#0 16.18 npm notice 
#0 16.18 npm notice New major version of npm available! 8.19.2 -> 9.2.0
#0 16.18 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.2.0>
#0 16.18 npm notice Run `npm install -g npm@9.2.0` to update!
#0 16.18 npm notice 
#0 16.18 npm ERR! code 1
#0 16.18 npm ERR! path /app/node_modules/bcrypt
#0 16.18 npm ERR! command failed
#0 16.18 npm ERR! command sh -c -- node-pre-gyp install --fallback-to-build
#0 16.18 npm ERR! Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/app/node_modules/bcrypt/lib/binding/napi-v3 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
#0 16.18 npm ERR! node-pre-gyp info it worked if it ends with ok
#0 16.18 npm ERR! node-pre-gyp info using node-pre-gyp@1.0.10
#0 16.18 npm ERR! node-pre-gyp info using node@16.18.1 | linux | arm64
#0 16.18 npm ERR! node-pre-gyp info check checked for "/app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" (not found)
#0 16.18 npm ERR! node-pre-gyp http GET https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-linux-arm64-musl.tar.gz
#0 16.18 npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-linux-arm64-musl.tar.gz 
#0 16.18 npm ERR! node-pre-gyp WARN Pre-built binaries not installable for bcrypt@5.0.1 and node@16.18.1 (node-v93 ABI, musl) (falling back to source compile with node-gyp) 
#0 16.18 npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-linux-arm64-musl.tar.gz 
#0 16.18 npm ERR! gyp info it worked if it ends with ok
#0 16.18 npm ERR! gyp info using node-gyp@9.1.0
#0 16.18 npm ERR! gyp info using node@16.18.1 | linux | arm64
#0 16.18 npm ERR! gyp info ok 
#0 16.18 npm ERR! gyp info it worked if it ends with ok
#0 16.18 npm ERR! gyp info using node-gyp@9.1.0
#0 16.18 npm ERR! gyp info using node@16.18.1 | linux | arm64
#0 16.18 npm ERR! gyp ERR! find Python 
#0 16.18 npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
#0 16.18 npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
#0 16.18 npm ERR! gyp ERR! find Python checking if "python3" can be used
#0 16.18 npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
#0 16.18 npm ERR! gyp ERR! find Python checking if "python" can be used
#0 16.18 npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
#0 16.18 npm ERR! gyp ERR! find Python 
#0 16.18 npm ERR! gyp ERR! find Python **********************************************************
#0 16.18 npm ERR! gyp ERR! find Python You need to install the latest version of Python.
#0 16.18 npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#0 16.18 npm ERR! gyp ERR! find Python you can try one of the following options:
#0 16.18 npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#0 16.18 npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
#0 16.18 npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
#0 16.18 npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
#0 16.18 npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
#0 16.18 npm ERR! gyp ERR! find Python For more information consult the documentation at:
#0 16.18 npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#0 16.18 npm ERR! gyp ERR! find Python **********************************************************
#0 16.18 npm ERR! gyp ERR! find Python 
#0 16.18 npm ERR! gyp ERR! configure error 
#0 16.18 npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
#0 16.18 npm ERR! gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
#0 16.18 npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
#0 16.18 npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16)
#0 16.18 npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16)
#0 16.18 npm ERR! gyp ERR! stack     at exithandler (node:child_process:410:5)
#0 16.18 npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:422:5)
#0 16.18 npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
#0 16.18 npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
#0 16.18 npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:485:16)
#0 16.18 npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
#0 16.18 npm ERR! gyp ERR! System Linux 5.15.49-linuxkit
#0 16.18 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/app/node_modules/bcrypt/lib/binding/napi-v3" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
#0 16.18 npm ERR! gyp ERR! cwd /app/node_modules/bcrypt
#0 16.18 npm ERR! gyp ERR! node -v v16.18.1
#0 16.18 npm ERR! gyp ERR! node-gyp -v v9.1.0
#0 16.18 npm ERR! gyp ERR! not ok 
#0 16.18 npm ERR! node-pre-gyp ERR! build error 
#0 16.18 npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/app/node_modules/bcrypt/lib/binding/napi-v3 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
#0 16.18 npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/app/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
#0 16.18 npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
#0 16.18 npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1100:16)
#0 16.18 npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
#0 16.18 npm ERR! node-pre-gyp ERR! System Linux 5.15.49-linuxkit
#0 16.18 npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/app/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
#0 16.18 npm ERR! node-pre-gyp ERR! cwd /app/node_modules/bcrypt
#0 16.18 npm ERR! node-pre-gyp ERR! node -v v16.18.1
#0 16.18 npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.10
#0 16.18 npm ERR! node-pre-gyp ERR! not ok
#0 16.19 
#0 16.19 npm ERR! A complete log of this run can be found in:
#0 16.19 npm ERR!     /root/.npm/_logs/2022-12-08T22_27_57_791Z-debug-0.log
------
failed to solve: executor failed running [/bin/sh -c npm i]: exit code: 1

Backend Dockerfile

FROM node:16-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm i
COPY . .
RUN npm run build

FROM node:16-alpine AS production
WORKDIR /app
COPY --from=builder /app/package*.json ./
RUN npm i --omit=dev
COPY --from=builder /app/ecosystem.config.js ./
COPY --from=builder /app/dist ./dist
RUN npm install pm2 -g
EXPOSE 3000
CMD ["pm2-runtime", "start", "ecosystem.config.js"]

docker-compose.yml

version: "3.2"
services:

  database:
    container_name: postgres
    image: "postgres:12"
    networks:
      - db 
    ports:
      - "5432:5432"
    volumes:
      - volume:/var/lib/postgresql/data
    env_file: .env
    restart: unless-stopped

  backend:
    container_name: backend
    build: ./backend
    env_file: .env
    restart: "unless-stopped"
    ports:
      - "4000:3000"
    networks:
      - network
      - db
    links:
      - database
    depends_on:
      - database

  frontend:
    container_name: frontend
    build: ./frontend
    ports:
      - "8081:80"
    networks:
      - network
    restart: "unless-stopped"

volumes:
  volume:
    driver: local

networks:
  db: 
    driver: bridge
    internal: true
  network:
    driver: bridge
kedO52
  • 7
  • 3
  • Please [edit] your question to include any relevant `docker-compose.yml` and `Dockerfile` files – Phil Dec 08 '22 at 22:53
  • The error looks pretty clear, you need to install Python – Phil Dec 08 '22 at 23:00
  • @Phil No. That's not a Python problem. It's installing on my mac. – kedO52 Dec 08 '22 at 23:08
  • _"That's not a Python problem"_... uh, the error message quite literally says `Error: Could not find any Python installation to use`. It needs to be installed in the image / container as detailed in the answers to the linked post – Phil Dec 08 '22 at 23:10
  • @Phil Oh... you a right... it's solve my problem A i just need add "RUN apk add g++ make py3-pip" from "FROM node:16-alpine AS builder" Thank you so much! You my hero! Have a nice day! But, WHY on windows-pc everything all right, but on mac i have this problem... – kedO52 Dec 08 '22 at 23:20
  • Could be stale image builds (try running `docker compose up --build`) or perhaps there's discrepancies between the Node images for your various architecture (eg if you've got an M1 / M2 Mac) – Phil Dec 08 '22 at 23:22
  • @Phil No. docker-compose up --build not works without ```RUN apk add g++ make py3-pip``` Yes, i have M2 chip – kedO52 Dec 08 '22 at 23:25
  • I meant on Windows. Without the Python change, you could try re-building the image. If it fails, it means you were using old images that may have had Python already installed somehow. Also, it's not unheard of for images to differ across architectures. It's up to the publishers to be consistent and nobody's perfect all the time – Phil Dec 08 '22 at 23:28

0 Answers0