【问题标题】:Docker config angular projectDocker 配置角度项目
【发布时间】:2018-08-26 13:15:09
【问题描述】:

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

然后我添加了两个文件

我的 docker-compose

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-compose up

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

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"

【问题讨论】:

    标签: node.js angular docker


    【解决方案1】:

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

    1. 您的应用程序包中不需要“angular-cli”依赖项即可运行。所以你应该从 Dockerfile 中删除它。
    2. 添加一个 .dockerignore 文件并在其中添加以下行 -

      节点模块

      npm-debug.log

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

    我看到你试图在你的 Dockerfile 中使用multi-stage build,其中只有一个阶段。下面是我的angular quickstart 示例的 Dockerfile 的屏幕截图

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多