Docker compose无法构建

时间:2019-04-30 12:20:38

标签: node.js linux docker npm docker-compose

我正在一个团队项目中,该项目具有集成的dockerfile,每个进行docker-compose构建的人都可以在Mac和mint上正常工作。但是在我使用ubuntu 18.10进行操作的计算机中,抛出以下错误:

bcrypt_lib.target.mk:109: recipe for target 'Release/obj.target/bcrypt_lib/src/bcrypt_node.o' failed
make: Leaving directory '/tmp/cocoa/node_modules/bcrypt/build'
make: *** [Release/obj.target/bcrypt_lib/src/bcrypt_node.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:196:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:256:12)
gyp ERR! System Linux 4.18.0-17-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/tmp/cocoa/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/tmp/cocoa/node_modules/bcrypt/lib/binding" "--napi_version=4" "--node_abi_napi=napi"
gyp ERR! cwd /tmp/cocoa/node_modules/bcrypt
gyp ERR! node -v v12.0.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
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 build --fallback-to-build --module=/tmp/cocoa/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/tmp/cocoa/node_modules/bcrypt/lib/binding --napi_version=4 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/tmp/cocoa/node_modules/bcrypt/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:196:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1000:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:267:5)
node-pre-gyp ERR! System Linux 4.18.0-17-generic
node-pre-gyp ERR! command "/usr/local/bin/node" "/tmp/cocoa/node_modules/bcrypt/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /tmp/cocoa/node_modules/bcrypt
node-pre-gyp ERR! node -v v12.0.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.2
node-pre-gyp ERR! not ok

我的npm版本为:6.4.1,但在另一台计算机(ubuntu)上,ubuntu上的NPM版本为:5.8.0

Docker文件:

FROM node:latest

ENV TERM=xterm-256color ENV PROJECT_NAME cocoa ENV PROJECT_ROOT
/opt/api

RUN mkdir -p /tmp/$PROJECT_NAME ADD package.json
/tmp/$PROJECT_NAME/package.json RUN cd /tmp/$PROJECT_NAME/ && npm
install RUN mkdir -p $PROJECT_ROOT RUN cp -a
/tmp/$PROJECT_NAME/node_modules $PROJECT_ROOT

WORKDIR $PROJECT_ROOT

COPY . $PROJECT_ROOT ARG environment COPY ./.env.${environment:-local}
$PROJECT_ROOT/.env COPY ./constants.js.${environment:-local}
$PROJECT_ROOT/src/config/constants.js

EXPOSE 8080

RUN ["chmod", "+x", "./bin/start.sh"]

CMD ["./bin/start.sh"]

Docker-Compose文件:

version: "2.1"

services:   # BUSINESS API   api:

    build: ./api

    ports:
      - "8080:8080"
    environment:
      - API_PORT=8080
      - DB_HOST=api-db
    volumes:
      - ./api/src:/opt/api/src
    links:
      - api-db
    external_links:
      - potatoes_api_1
    networks:
      - potatoes_default
    depends_on:
      api-db:
        condition: service_healthy

  # API DB   api-db:

    image: mysql:5.7.22
    ports:
      - "3306:3306"
    volumes:
      - api-db-volume:/var/lib/mysql
    environment:
      MYSQL_USER: shadow
      MYSQL_PASSWORD: abc789
      MYSQL_ROOT_PASSWORD: abc789
      MYSQL_DATABASE: shadow_express
    healthcheck:
      test: "/usr/bin/mysql --user=root --password=abc789 --execute \"SHOW DATABASES;\""
      interval: 3s
      timeout: 1s
      retries: 5 volumes:   api-db-volume:   # queue-db-volume: networks:   potatoes_default:
      external: true

0 个答案:

没有答案