docker-多阶段构建

阅读量: zyh 2020-03-24 11:46:44
Categories: > Tags:

示例文件

## 别名 ui-build
FROM node:10 AS ui-build
WORKDIR /usr/src/app
COPY WebApp/ ./WebApp/
RUN cd WebApp && npm install @angular/cli && npm install && npm run build

FROM node:10 AS server-build
WORKDIR /root/
## 从 ui-build:/usr/src/app/WebApp/dist 复制到 server-build:./WebApp/dist
COPY --from=ui-build /usr/src/app/WebApp/dist ./WebApp/dist
COPY package*.json ./
RUN npm install
COPY index.js .

EXPOSE 3070

ENTRYPOINT ["node"]
CMD ["index.js"]