Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Docker Multi Stage Builds

Docker Multi Stage Builds

Human Talks Octobre 2017

Ba2198386e326d6e3ca57b2271d861e9?s=128

Yves Brissaud

October 10, 2017
Tweet

Transcript

  1. Docker Multi Stage Builds Human Talks Grenoble octobre 2017 |

    @_crev_
  2. Human Talks Grenoble octobre 2017 | @_crev_

  3. - Images plus légères - Unique fichier de build Human

    Talks Grenoble octobre 2017 | @_crev_
  4. Pourquoi plus légères Human Talks Grenoble octobre 2017 | @_crev_

  5. push, pull, run Human Talks Grenoble octobre 2017 | @_crev_

  6. container != virtualisation légère Human Talks Grenoble octobre 2017 |

    @_crev_
  7. Étapes de fabrication : Compilation des dépendances Traitements intermédiaires Image

    cible Human Talks Grenoble octobre 2017 | @_crev_
  8. Examples Human Talks Grenoble octobre 2017 | @_crev_

  9. None
  10. Simple Docker FROM golang WORKDIR /go/src/app COPY . . RUN

    go-wrapper download RUN go-wrapper install CMD ["go-wrapper", "run"] 737MB Human Talks Grenoble octobre 2017 | @_crev_
  11. Pattern Builder FROM golang WORKDIR /go/src/ht_docker_multi_stage COPY . . RUN

    go-wrapper download CMD ["go", "build", "-v"] FROM gcr.io/distroless/base COPY ht_docker_multi_stage / CMD ["/ht_docker_multi_stage"] Human Talks Grenoble octobre 2017 | @_crev_
  12. Pattern Builder (2) build: docker build -t ht_build_and_package-builder -f Dockerfile.build

    . docker run --rm -v $$PWD:/go/src/ht_docker_multi_stage \ ht_build_and_package-builder 17.5MB Human Talks Grenoble octobre 2017 | @_crev_
  13. Multi Stage FROM golang as builder WORKDIR /go/src/ht_docker_multi_stage COPY .

    . RUN go-wrapper download RUN go-wrapper install FROM gcr.io/distroless/base COPY --from=builder /go/bin/ht_docker_multi_stage / CMD ["/ht_docker_multi_stage"] 17.5MB Human Talks Grenoble octobre 2017 | @_crev_
  14. None
  15. NGinx FROM nginx:1.13-alpine EXPOSE 80 COPY conf/default.conf /etc/nginx/conf.d/default.conf COPY build/

    /usr/share/nginx/html Human Talks Grenoble octobre 2017 | @_crev_
  16. React build FROM node:8-alpine as dependencies WORKDIR /usr/src/app COPY package.json

    yarn.lock /usr/src/app/ RUN yarn install FROM node:8-alpine as builder WORKDIR /usr/src/app COPY . . COPY --from=dependencies /usr/src/app/node_modules /usr/src/app/node_modules RUN yarn build FROM nginx:1.13-alpine EXPOSE 80 COPY conf/default.conf /etc/nginx/conf.d/default.conf COPY --from=builder /usr/src/app/build/ /usr/share/nginx/html Human Talks Grenoble octobre 2017 | @_crev_
  17. Sass build FROM ruby:2-alpine3.6 as sass RUN apk add --no-cache

    --virtual build-dep build-base \ && gem install sass --no-doc \ && apk del build-dep && rm -rf /var/cache/apk/* COPY scss /usr/src/app WORKDIR /usr/src/app RUN sass bootstrap.scss > App.css #... FROM node:8-alpine as builder WORKDIR /usr/src/app COPY . . COPY --from=dependencies /usr/src/app/node_modules /usr/src/app/node_modules COPY --from=sass /usr/src/app/App.css /usr/src/app/src/App.css RUN yarn build Human Talks Grenoble octobre 2017 | @_crev_
  18. Limites Human Talks Grenoble octobre 2017 | @_crev_

  19. Limites Pas de partage de stag Linter pas à jour

    Docker >= 17.05 Human Talks Grenoble octobre 2017 | @_crev_
  20. Limites Pas de partage de stag Comment partager dependencie entre

    container de dev et container intermédiaire de prod ? Partage de step au travers du cache docker ? Génération des Dockerfile ? Human Talks Grenoble octobre 2017 | @_crev_
  21. Limites Linter pas à jour $ docker run --rm -it

    --privileged -v $PWD:/root/ \ projectatomic/dockerfile-lint dockerfile_lint lint --------ERRORS--------- Line 1: -> FROM ruby:2-alpine3.6 as sass ERROR: Invalid parameters for command.. Reference -> https://docs.docker.com/engine/reference/builder/ Line 12: -> FROM node:8-alpine as dependencies ERROR: Invalid parameters for command.. Reference -> https://docs.docker.com/engine/reference/builder/ Human Talks Grenoble octobre 2017 | @_crev_
  22. Limites Docker >= 17.05 Kubernetes < 1.8 docker <= 1.12

    Human Talks Grenoble octobre 2017 | @_crev_
  23. Avantages Human Talks Grenoble octobre 2017 | @_crev_

  24. Avantages Toute la construction présente dans un unique chier Suppression

    d'outils de build externes (type Makefile ) docker build + docker run , that's all folks Human Talks Grenoble octobre 2017 | @_crev_
  25. Thanks Human Talks Grenoble octobre 2017 | @_crev_ | docker

    run --rm -it squarescale/ybrissaud