我们将 Angular 从 7 升级到 8。
但是在构建 docker 映像时,这一步失败了:
ng "build" "--prod" "--configuration" "development" "--output-path=docs" "--serviceWorker=true" "--verbose" "--progress=true"
被这个堆栈跟踪卡在 11%:
[webpack.Progress] 11% building 11/12 modules 1 active /app-ui/node_modules/mini-css-extract-plugin/dist/loader.js!/app-ui/node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!/app-ui/node_modules/postcss-loader/src/index.js??extracted!/app-ui/node_modules/sass-loader/lib/loader.js??ref--15-3!/app-ui/src/styles.scss
Removing intermediate container e45e8a69a2aa
然后在docker中复制目录失败:
Step 14/16 : COPY --from=0 /app-ui/docs /usr/share/nginx/html
COPY failed: stat /var/lib/docker/overlay2/***/merged/app-ui/docs: no such file or directory
这是我的 Dockerfile:
FROM node:12.10.0-alpine
ENV LC_ALL C
ARG env=production
RUN apk update && apk upgrade && apk add --no-cache make git && rm -rf /var/cache/apk/* /tmp/*
ADD . /app-ui
WORKDIR /app-ui
RUN npm install
RUN npm run ng build -- --prod --configuration $env --output-path=docs --serviceWorker=true --verbose --progress=true
FROM nginx:alpine
RUN apk update && apk upgrade && rm -rf /var/cache/apk/* /tmp/*
RUN rm -rf /usr/share/nginx/html/*
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=0 /app-ui/docs /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]