docker从package.json中提取文件

时间:2018-06-06 09:08:43

标签: docker github npm

我有一个简单的node.app,带有这个package.json:

{
  "name": "docker_web_app",
  "version": "1.0.0",
  "description": "Node.js on Docker",
  "author": "xxxxx",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.16.1",
    "myuser-deploy": "git+ssh://git@github.com:myuser/deploy.git"
  }
}

通常当我运行“ npm i ”时,它会安装所有依赖项,并且还会安装github。我之前使用github设置了SSH。到目前为止一切正常。

现在我为我的应用程序添加了Docker支持,就像这个

Dockerfile:

FROM node:carbon

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm install --only=production

# Bundle app source
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]

搬运工-compose.yml:

version: "3"
services:
  test-service:
    build: .
    image: test-service
    container_name: test-service
    working_dir: /usr/src/app
    user: node
    restart: always
    ports:
      - '3001:3000'

当我运行docker-compose时,它给了我这个错误:

> npm ERR! Error while executing: npm ERR! /usr/bin/git ls-remote -h -t
> ssh://git@github.com/myuser/deploy.git npm ERR!  npm ERR! Host key
> verification failed. npm ERR! fatal: Could not read from remote
> repository. npm ERR!  npm ERR! Please make sure you have the correct
> access rights npm ERR! and the repository exists. npm ERR!  npm ERR!
> exited with error code: 128
> 
> npm ERR! A complete log of this run can be found in:

我可以用docker做什么,所以它使用我的SSH密钥?

0 个答案:

没有答案