簡體   English   中英

Docker配置角度項目

[英]Docker config angular project

對不起我的英語不好。 我是新的碼頭工人,對我來說現在不容易。 我要配置這個項目:

然后我添加了兩個文件

在此處輸入圖片說明

我的碼頭工人組成

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"

在繼續回答您的問題之前:

  1. 您不需要在應用程序包中運行“ angular-cli”依賴項即可運行它。 因此,您應該將其從Dockerfile中刪除。
  2. 添加.dockerignore文件,並在其中添加以下行-

    node_modules

    NPM-的debug.log

    這樣可以防止將本地模塊和調試日志復制到Docker映像中,並可能覆蓋映像中安裝的模塊。

我看到您嘗試在Dockerfile中使用僅包含一個階段的多階段構建 以下是我的Dockerfile的角度快速入門示例的屏幕截圖 在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM