【问题标题】:Docker image builing is failing for angular projectAngular 项目的 Docker 映像构建失败
【发布时间】:2019-12-13 13:56:15
【问题描述】:

我正在尝试为我的 Angular 项目构建一个 docker 映像。但是,它失败并出现以下错误。我已经阅读了很多文章来构建 Angular 项目 docker 映像,但没有一篇文章对我有帮助。最后它以/bin/sh -c 非零错误失败。

命令'/bin/sh -c npm run ng build -- --prod --output-path=dist' 返回一个非零代码:1。

我的笔记本电脑装有 Windows 10,安装了 docker。下面是我的码头文件。您能否建议,如果这里有什么遗漏?

Dockerfile

### STAGE 1: Build ###

COPY package.json package-lock.json ./

RUN npm ci && mkdir /ng-app && mv ./node_modules ./ng-app

WORKDIR /ng-app

COPY . .

RUN npm run ng build -- --prod --output-path=dist


### STAGE 2: Setup ###

FROM nginx:1.14.1-alpine

## Copy the default nginx config
COPY nginx/default.conf /etc/nginx/conf.d/

## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*

## From ‘builder’ stage copy over the artifacts in dist folder to default nginx public folder
COPY --from=builder /ng-app/dist /usr/share/nginx/html

CMD ["nginx", "-g", "daemon off;"]

【问题讨论】:

    标签: angular dockerfile alpine docker-image


    【解决方案1】:

    该错误通常发生在Docker内存不足时,但如果磁盘空间不足也可能出现。

    你也可以加集

    ENV NODE_OPTIONS=--max-old-space-size=8192
    

    【讨论】:

      猜你喜欢
      • 2020-06-09
      • 2019-12-02
      • 2022-11-22
      • 2018-06-02
      • 2022-09-28
      • 1970-01-01
      • 2022-01-02
      • 1970-01-01
      • 2021-12-29
      相关资源
      最近更新 更多