Slide 1

Slide 1 text

PUT YOUR DOCKER IMAGE ON A DIET @PFWD @HowToCodeWell

Slide 2

Slide 2 text

SELF TAUGHT DOCKER DEV IF YOU SEE AN IMPROVEMENT PLEASE LET ME KNOW WE ARE ALL LEARNING ALL THE TIME @PFWD @HowToCodeWell

Slide 3

Slide 3 text

PHP 7.4 RC 1 SYMFONY 4.3.6 APACHE 2 WEB SERVER ORIGINAL 1.09GB AFTER DIET 171 MB @PFWD @HowToCodeWell

Slide 4

Slide 4 text

@PFWD @HowToCodeWell

Slide 5

Slide 5 text

WHY | WHAT | HOW @PFWD @HowToCodeWell

Slide 6

Slide 6 text

PETER FISHER BSC MBSC HOW TO CODE WELL

Slide 7

Slide 7 text

@PFWD @HowToCodeWell

Slide 8

Slide 8 text

WHY | WHAT | HOW @PFWD @HowToCodeWell

Slide 9

Slide 9 text

SPEED | SECURITY | SANITY | SCALABILITY @PFWD @HowToCodeWell

Slide 10

Slide 10 text

SPEED THE LIGHTER THE IMAGE THE FASTER THE DEVELOPMENT @PFWD @HowToCodeWell

Slide 11

Slide 11 text

SPEED THE LIGHTER THE IMAGE THE FASTER THE DEPLOYMENT @PFWD @HowToCodeWell

Slide 12

Slide 12 text

SPEED THE LIGHTER THE IMAGE THE FASTER THE DISTRIBUTION @PFWD @HowToCodeWell

Slide 13

Slide 13 text

SECURITY THE SMALLER THE IMAGE THE SMALLER THE ATTACK SURFACE @PFWD @HowToCodeWell

Slide 14

Slide 14 text

SECURITY DO NOT BAKE SECURITY CREDS INTO YOUR IMAGES @PFWD @HowToCodeWell

Slide 15

Slide 15 text

SANITY THE SMALLER THE IMAGE THE LESS YOU HAVE TO MAINTAIN @PFWD @HowToCodeWell

Slide 16

Slide 16 text

SANITY THE SMALLER THE IMAGE THE MORE CONTROL YOU HAVE @PFWD @HowToCodeWell

Slide 17

Slide 17 text

SANITY THE SMALLER THE IMAGE THE QUICKER YOU CAN SPOT PROBLEMS @PFWD @HowToCodeWell

Slide 18

Slide 18 text

SANITY THE SMALLER THE IMAGE THE LESS RESPONSIBILITY IT HAS @PFWD @HowToCodeWell

Slide 19

Slide 19 text

SCALEABILITY THE SMALLER THE IMAGE THE QUICKER IT CAN INSTALL @PFWD @HowToCodeWell

Slide 20

Slide 20 text

SCALEABILITY THE SMALLER THE IMAGE THE QUICKER TO EXPAND @PFWD @HowToCodeWell

Slide 21

Slide 21 text

SCALEABILITY THE SMALLER THE IMAGE THE QUICKER TO CONTRACT @PFWD @HowToCodeWell

Slide 22

Slide 22 text

SCALEABILITY THE SMALLER THE IMAGE THE QUICKER TO REUSE @PFWD @HowToCodeWell

Slide 23

Slide 23 text

WHY | WHAT | HOW @PFWD @HowToCodeWell

Slide 24

Slide 24 text

WHAT IS THE DIFFERENCE BETWEEN A DOCKER CONTAINER AND A VIRTUAL MACHINE? @PFWD @HowToCodeWell

Slide 25

Slide 25 text

@PFWD @HowToCodeWell

Slide 26

Slide 26 text

VIRTUALIZATION != CONTAINERIZATION @PFWD @HowToCodeWell

Slide 27

Slide 27 text

VIRTUALIZATION = IS A HOUSE @PFWD @HowToCodeWell

Slide 28

Slide 28 text

CONTAINERIZATION = IS A ROOM @PFWD @HowToCodeWell

Slide 29

Slide 29 text

DIFFERENT LEVELS OF ABSTRACTION @PFWD @HowToCodeWell

Slide 30

Slide 30 text

BOTH SOLVE DIFFERENT PROBLEMS @PFWD @HowToCodeWell

Slide 31

Slide 31 text

BOTH SHOULD BE USED DIFFERENTLY @PFWD @HowToCodeWell

Slide 32

Slide 32 text

VIRTUALIZATION CUSTOM ENVIRONMENT ALLOCATED RESOURCES ECOSYSTEM @PFWD @HowToCodeWell

Slide 33

Slide 33 text

CONTAINIZATION SINGLE PROCESS SINGLE RESPONSIBILITY SINGLE PURPOSE @PFWD @HowToCodeWell

Slide 34

Slide 34 text

WHAT IS A DOCKER IMAGE ANYWAY? @PFWD @HowToCodeWell

Slide 35

Slide 35 text

WHAT IS A DOCKER IMAGE ANYWAY? ANSWER: A FILE MADE FROM MANY LAYERS WHICH
 CREATES A CONTAINER @PFWD @HowToCodeWell

Slide 36

Slide 36 text

CONTAINERS ARE BUILT FROM IMAGES @PFWD @HowToCodeWell

Slide 37

Slide 37 text

WHAT IS A DOCKER IMAGE MADE FROM? @PFWD @HowToCodeWell

Slide 38

Slide 38 text

WHAT IS A DOCKER IMAGE ANYWAY? ANSWER: MANY DIFFERENT IMAGES @PFWD @HowToCodeWell

Slide 39

Slide 39 text

WHAT IS A DOCKER FILE? @PFWD @HowToCodeWell

Slide 40

Slide 40 text

WHAT IS A DOCKER FILE? ANSWER: A SERIES OF INSTRUCTIONS THAT
 BUILD A DOCKER IMAGE @PFWD @HowToCodeWell

Slide 41

Slide 41 text

WHY | WHAT | HOW @PFWD @HowToCodeWell

Slide 42

Slide 42 text

VERSION 1.0.0 1.09 GB @PFWD @HowToCodeWell

Slide 43

Slide 43 text

VERSION 1.0.0 1.09 GB @PFWD @HowToCodeWell

Slide 44

Slide 44 text

26 BUILD STEPS 18 RUN INSTRUCTIONS VERSION 1.0.0 1.09 GB @PFWD @HowToCodeWell

Slide 45

Slide 45 text

10 BUILD STEPS VERSION 1.1.0 1.06 GB @PFWD @HowToCodeWell

Slide 46

Slide 46 text

MULTIPLE CONTAINER RESPONSIBILITIES VERSION 1.1.0 1.06 GB @PFWD @HowToCodeWell

Slide 47

Slide 47 text

REMOVED MULTIPLE CONTAINER REPSONSIBILTES MYSQL-SERVER MYSQL-CLIENT RABBITMQ-SERVER VERSION 1.2.0 708MB @PFWD @HowToCodeWell

Slide 48

Slide 48 text

DO NOT VERSION 1.2.0 708MB @PFWD @HowToCodeWell

Slide 49

Slide 49 text

REMOVED PHP-7.4-* VERSION 1.3.0 449MB @PFWD @HowToCodeWell

Slide 50

Slide 50 text

WRONG BASE IMAGE VERSION 1.3.0 449MB @PFWD @HowToCodeWell

Slide 51

Slide 51 text

VERSION 1.4.0 601MB USE PHP APACHE BASE IMAGE @PFWD @HowToCodeWell

Slide 52

Slide 52 text

VERSION 1.5.0 485MB @PFWD @HowToCodeWell

Slide 53

Slide 53 text

VERSION 1.6.0 478MB DON’T INSTALL
 RECOMENDED PACKAGES —no-install-recommends @PFWD @HowToCodeWell

Slide 54

Slide 54 text

VERSION 1.7.0 444MB MULTI STAGE DOCKER BUILD 3 STAGES! @PFWD @HowToCodeWell

Slide 55

Slide 55 text

DEV PACKAGES SHOULD BE FOR DEV NOT FOR PROD! @PFWD @HowToCodeWell

Slide 56

Slide 56 text

VERSION 1.8.0 424MB MULTI STAGE DOCKER BUILD 5 STAGES! 2 TARGETS NO DEV PACKAGES IN STAGING STAGING HAS AUTOLOADER DUMPED @PFWD @HowToCodeWell

Slide 57

Slide 57 text

VERSION 1.9.0 171MB ALPINE IMAGES DECOUPLING PHP FROM APACHE @PFWD @HowToCodeWell

Slide 58

Slide 58 text

VERSION 1.9.0 88.5MB USE PHP FPM PHP AND APACHE ARE IN 2 CONTAINERS @PFWD @HowToCodeWell

Slide 59

Slide 59 text

VERSION 1.9.0 PHP 88.5MB APACHE 171MB ER… HOW? @PFWD @HowToCodeWell

Slide 60

Slide 60 text

VERSION 1.9.0 PHP 88.5MB APACHE 171MB PROXY PHP REQUESTS TO THE PHP CONTAINER @PFWD @HowToCodeWell

Slide 61

Slide 61 text

VERSION 1.9.0 PHP 88.5MB APACHE 171MB 1) USE THE PHP SERVICE NAME 2) NETWORK APACHE AND PHP 3) SHARE THE SITE VOLUME @PFWD @HowToCodeWell

Slide 62

Slide 62 text

VERSION 1.9.0 PHP 88.5MB APACHE 171MB 1) USE THE PHP SERVICE NAME 2) NETWORK APACHE AND PHP 3) SHARE THE SITE VOLUME @PFWD @HowToCodeWell

Slide 63

Slide 63 text

Version Size 1.0.0 1.0.9 GB 1.1.0 1.0.6 GB Reduced build steps 1.2.0 708 MB Removed other responsibilities 1.3.0 449 MB Removed unknown PHP packages (php7.4-*) 1.4.0 601 MB Changed the base image 1.5.0 485 MB Removed package and composer cache 1.6.0 478 MB Didn’t install recommend packages 1.7.0 444 MB Used Multi Stage Docker Images 1.8.0 424 MB Removed dev composer packages 1.9.0 171 MB - Apache 88 MB - PHP Separated Apache and PHP @PFWD @HowToCodeWell

Slide 64

Slide 64 text

Peter Fisher BSC MBSC GITHUB https://github.com/pfwd/how-to-put- your-docker-image-on-a-diet Version 1.0.0 $ docker-compose up -d --build Grab a ☕ @PFWD @HowToCodeWell

Slide 65

Slide 65 text

Peter Fisher BSC MBSC THANK YOU QUESTIONS? LET ME KNOW WHAT YOU THINK! @PFWD @HowToCodeWell