【发布时间】: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