【发布时间】:2021-12-11 18:38:28
【问题描述】:
我正在尝试将 angular-9 应用程序容器化。
码头文件
FROM node:14.17.0-alpine as build-step
RUN mkdir -p /app
WORKDIR /app
COPY package.json /app
COPY . /app
# Install & build packages
RUN npm install
# Listing 1
RUN ls -la
RUN npm run build:docker
# Listing 2
Run ls -la
# Setup nginx
FROM nginx:alpine
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build-step /app/dist/ /usr/share/nginx/html/
# Expose port 80
EXPOSE 80
包.json
script: {
"build:docker": "node --max-old-space-size=10240 ./node_modules/@angular/cli/bin/ng build --prod --output-path=dist"
}
#Listing 1(in dokerfile) 显示 node-modules 文件夹,但 Listing 2(in dokerfile) 不显示。
最后还是报错
COPY failed: stat app/dist/: file does not exist
我无法理解为什么它没有获取在 docker 中构建的文件。
【问题讨论】:
-
能否也显示
npm run build:docker的输出? -
刚刚编译成功
-
我在问题中添加了日志截图。
-
您可以添加实际的日志,而不是屏幕截图吗?以后阅读和搜索会容易得多。
-
我注意到一件事,如果我在 windows 机器上做 docker build,它工作得非常好,但如果我在 Linux 或 Mac 上做,它会给出同样的错误。知道可能是什么原因吗?
标签: node.js angular docker nginx