Node.js Docker配置角项目

Node.js Docker配置角项目,node.js,angular,docker,Node.js,Angular,Docker,对不起我的英语。我是一个新码头工人,现在对我来说并不容易。我要配置此项目: 然后我添加了两个文件 我的码头工人 web: build: . ports: - '49153:49153' volumes: - .:/usr/src/app/ environment: - NODE_ENV=dev command: bash -c "npm start" Dockerfile FROM node:8.6 as

对不起我的英语。我是一个新码头工人,现在对我来说并不容易。我要配置此项目:

然后我添加了两个文件

我的码头工人

web:
    build: .
    ports:
        - '49153:49153'
    volumes:
        - .:/usr/src/app/
    environment:
        - NODE_ENV=dev
    command: bash -c "npm start"
Dockerfile

FROM node:8.6 as node

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN npm install
RUN npm install -g angular-cli
COPY . /usr/src/app

EXPOSE 49153

CMD [ "npm", "start" ]
然后我像这样跑:

docker-compose build

我的问题:我该如何更正Docker的写入设置?在控制台中,当我执行
docker编写构建时
消息

gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '8.6.0' ]
gyp verb install input version string "8.6.0"
gyp verb install installing version: 8.6.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.6.0
gyp verb ensuring nodedir is created /usr/local/lib/node_modules/angular-cli/node_modules/node-sass/.node-gyp/8.6.0
gyp WARN EACCES user "nobody" does not have permission to access the dev dir "/usr/local/lib/node_modules/angular-cli/node_modules/node-sass/.node-gyp/8.6.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/angular-cli/node_modules/node-sass/.node-gyp"

在开始回答您的问题之前:

  • 运行应用程序包不需要“angular cli”依赖项。因此,您应该将其从Dockerfile中删除
  • 添加一个.dockrignore文件并在其中添加下面的行-

    节点单元

    npm-debug.log

    这将防止本地模块和调试日志被复制到Docker映像上,并可能覆盖映像中安装的模块

  • 我看到您试图在Dockerfile中仅使用一个阶段。下面是示例Dockerfile的屏幕截图

    gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
    gyp verb command install [ '8.6.0' ]
    gyp verb install input version string "8.6.0"
    gyp verb install installing version: 8.6.0
    gyp verb install --ensure was passed, so won't reinstall if already installed
    gyp verb install version not already installed, continuing with install 8.6.0
    gyp verb ensuring nodedir is created /usr/local/lib/node_modules/angular-cli/node_modules/node-sass/.node-gyp/8.6.0
    gyp WARN EACCES user "nobody" does not have permission to access the dev dir "/usr/local/lib/node_modules/angular-cli/node_modules/node-sass/.node-gyp/8.6.0"
    gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/angular-cli/node_modules/node-sass/.node-gyp"