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

Docker: multi-stage multi-environment

Docker: multi-stage multi-environment

Talk given on Unconference Track in LaraconEU 2018

56f3afe5f9545c213ae8fc221c2324f3?s=128

Abdala Cerqueira

August 31, 2018
Tweet

Transcript

  1. Docker: Multi-stage multi-environment Abdala Cerqueira

  2. Dockerfile

  3. FROM COPY --from= docker build --target

  4. Problems

  5. Problem 1 • Keep different Dockerfiles per environment • !

    dev tools and dependencies on production
  6. Problem 2 • Big, huge, immense images • One or

    two commands may leave images out of control
  7. Dependencies

  8. Checklist • Have only one Dockerfile • Use the same

    Dockerfile for all environments (dev, test, prod) • Create small images • Manage less dependencies
  9. Official PHP image • One Dockerfile • All environments •

    Small images • Less dependencies Time: ~39s Size: 430MB Security problems
  10. Multi-stage

  11. Official PHP image multi-stage • One Dockerfile • All environments

    • Small images • Less dependencies Time: ~40s Size: 393MB Not that small, hidden dependencies
  12. Alpine image • One Dockerfile • All environments • Small

    images • Less dependencies Time: ~11s Size: 59.4MB Still have unwanted dependencies
  13. Alpine image multi-stage • One Dockerfile • All environments •

    Small images • Less dependencies Time: ~16s Size: 35.8MB This is ART <3
  14. Comparison table Image Time Size alpine:3.8 - 4.41 MB php:7.2-apache

    - 377 MB laravel-apache 39s 430 MB laravel-apache-multi 40s 393 MB laravel-alpine 11s 59.4 MB laravel-alpine-multi 16s 35.8 MB
  15. Conclusion • Care about dependencies • Try different techniques

  16. Thanks!