我有 Angular 6 应用程序。它在本地构建和工作没有问题。
现在我想创建 docker 镜像。我正在关注本指南 https://medium.com/@tiangolo/angular-in-docker-with-nginx-supporting-environments-built-with-multi-stage-docker-builds-bb9f1724e984
问题是应用程序在对其进行 docker 化时找不到某些模块(第 7 步失败)。当我在控制台中从这一步运行命令时,它会正常构建。我该如何处理?我现在正在为此奋斗2天。
Dockerfile:
# Stage 0, "build-stage", based on Node.js, to build and compile the frontend
FROM tiangolo/node-frontend:10 as build-stage
WORKDIR /app
COPY package*.json /app/
RUN npm install
COPY ./ /app/
ARG configuration=production
RUN npm run build -- --output-path=./dist/out --configuration $configuration
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.15
COPY --from=build-stage /app/dist/out/ /usr/share/nginx/html
# Copy the default nginx.conf provided by tiangolo/node-frontend
COPY --from=build-stage /nginx.conf /etc/nginx/conf.d/default.conf
最佳答案
解决了 OP 的问题,因为它是路径区分大小写的问题。
关于docker镜像中的 Angular 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52857975/