zoukankan      html  css  js  c++  java
  • [Docker] Benefits of Multi-stage Builds

    The benfits of multi-stage builds:

    • Avoid manual creation of intermediate images
    • Reduce complexity
    • Selectively copy artifacts from one stage to another
    • Smaller final image size
    // nginx.prod.dockerfile
    ##### Stage 1
    FROM node:latest as node
    LABEL author="ZWT"
    WORKDIR /app
    # Copy the package.json to working dir
    COPY package.json package.json
    # install FE packages
    RUN npm install
    # copy all the code to the working dir
    COPY . .
    # start ng build -- prod
    RUN npm run build -- --prod
    
    ##### Stage 2
    FROM nginx:alpine
    VOLUME /var/cache/nginx
    COPY --from=node /app/dist /usr/share/nginx/html
    COPY ./config/nginx.conf /etc/nginx/conf.d/default.conf

    Run build:

    docker build -t nginx-angular -f nginx.prod.dockerfile .
  • 相关阅读:
    用VS Code写C++程序如何运行
    DRF
    DRF
    DRF
    DRF
    DRF
    DRF
    DRF
    DRF
    DRF
  • 原文地址:https://www.cnblogs.com/Answer1215/p/10759402.html
Copyright © 2011-2022 走看看