我有angular 6应用程序。它可以在本地构建和正常运行。
现在我要创建docker映像。我正在遵循本指南https://medium.com/@tiangolo/angular-in-docker-with-nginx-supporting-environments-built-with-multi-stage-docker-builds-bb9f1724e984
问题在于,在对应用程序进行Docker化时,应用程序无法找到某些模块(失败于7步)。当我从控制台的此步骤运行命令时,它会正常构建。我该如何处理?我现在在战斗这两天。
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
答案 0 :(得分:1)
解决了OP的问题,因为这是路径区分大小写的问题。
答案 1 :(得分:0)
一切都指出,在第7步之前缺少npm install命令。请在ng build命令之前在dockerfile上添加此步骤。