Docker Sqlite3: пожалуйста, установите пакет sqlite3 вручную - PullRequest
0 голосов
/ 08 июля 2019

Я пытаюсь использовать докер с моим проектом, но у меня возникла проблема;sqlite3 не установлен правильно, независимо от того, что я делаю, он включен в package.json, я тоже пытался удалить и переустановить его, но он не работает.У меня та же проблема, когда я клонирую проект и запускаю npm i в Windows, но его повторная установка с использованием npm i -S sqlite3 работает в Windows, а не в контейнере Docker.Кто-нибудь сталкивался с такой же проблемой?

Docker-compose

version: '3'
services:
  backend:
    container_name: vacation_backend
    build: "./backend"
    image: backend:backend
    volumes:
      - ./:/app
    ports:
      - 3000:3000
    network_mode: "bridge"
    env_file: "backend/.env"

Dockerfile

FROM node:10-stretch

# COPY fix-proxy-apt /etc/apt/apt.conf.d/99fixbadproxy
RUN apt update && apt install -y apt-transport-https ca-certificates
RUN npm config set unsafe-perm
RUN npm i -g npm forever

WORKDIR /app/backend
COPY ./ /app/backend

RUN npm install 
RUN npm uninstall --save sqlite3 
RUN npm install --save sqlite3
RUN npm run build

EXPOSE 3000
WORKDIR /app/backend
COPY backend.sh /backend.sh
RUN chmod +x /backend.sh

ENTRYPOINT ["/backend.sh"]

package.json

{
  "name": "project",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "cross-env NODE_ENV=\"development\" nodemon --exec babel-node src/index.js",
    "build": "babel src --out-dir dist",
    "serve": "forever dist/index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@babel/polyfill": "^7.4.4",
    "@koa/cors": "^2.2.3",
    "@types/sequelize": "^4.28.1",
    "cron": "^1.7.1",
    "googleapis": "^40.0.0",
    "graphql": "^14.3.1",
    "graphql-relay": "^0.6.0",
    "graphql-sequelize": "^9.3.6",
    "jsonwebtoken": "^8.5.1",
    "koa": "^2.7.0",
    "koa-bodyparser": "^4.2.1",
    "koa-graphql": "^0.8.0",
    "koa-router": "^7.4.0",
    "ldapjs": "^1.0.2",
    "moment": "^2.24.0",
    "node-cron": "^2.0.3",
    "nodemailer": "^6.2.1",
    "sequelize": "^5.8.6",
    "sqlite3": "^4.0.9"
  },
  "devDependencies": {
    "@babel/cli": "^7.5.0",
    "@babel/core": "^7.4.5",
    "@babel/node": "^7.4.5",
    "@babel/preset-env": "^7.4.5",
    "babel-plugin-module-resolver": "^3.2.0",
    "cross-env": "^5.2.0",
    "forever": "^1.0.0",
    "nodemon": "^1.19.0"
  }
}

docker-compose build

Step 9/15 : RUN npm install --save sqlite3
 ---> Running in a72a4cbda37c

> sqlite3@4.0.9 install /app/backend/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
[sqlite3] Success: "/app/backend/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node" is installed via remote
npm WARN project@1.0.0 No description
npm WARN project@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) 

+ sqlite3@4.0.9
added 70 packages from 65 contributors, updated 1 package and audited 7673 packages in 8.868s
found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details
Removing intermediate container a72a4cbda37c

хэш докера логов

Error: Please install sqlite3 package manually
    at ConnectionManager._loadDialectModule (/app/backend/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:81:15)
    at new ConnectionManager (/app/backend/node_modules/sequelize/lib/dialects/sqlite/connection-manager.js:22:21)
    at new SqliteDialect (/app/backend/node_modules/sequelize/lib/dialects/sqlite/index.js:14:30)
    at new Sequelize (/app/backend/node_modules/sequelize/lib/sequelize.js:320:20)
    at Object.<anonymous> (/app/backend/dist/models/db.js:15:17)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/app/backend/dist/models/user.js:8:34)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/app/backend/dist/models/index.js:25:36)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
error: Forever detected script exited with code: 1
error: Script restart attempt #X
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...