dockerizing php apps - aurelijus.banelis.lt · docker hub for development task definition =...
TRANSCRIPT
![Page 2: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/2.jpg)
Aurelijus Banelis
PGP 0x320205E7539B6203130D C446 1F1A 2E50 D6E33DA8 3202 05E7 539B 6203
Backend/[email protected]
![Page 3: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/3.jpg)
AdaptingPHP applicationsto be used with
docker
![Page 4: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/4.jpg)
Why to dockerizeWhat is dockerHow to dockerize
Introduction
Development
Production
Context/AlternativesWhat I really likedWhat I do not like
Deploying to AWS
![Page 5: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/5.jpg)
Why to dockerizeWhat is dockerHow to dockerize
Introduction
Development
Production
Context/AlternativesWhat I really likedWhat I do not like
Deploying to AWS
![Page 6: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/6.jpg)
Monolith (VirtualBox) → SplitDevelopment bottleneck
Jenkins (time based) → CircleCIConfidence/tooling bottleneck
Release coordination → AWS servicesProvisioning speed bottleneck
![Page 7: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/7.jpg)
Monolith (VirtualBox) → SplitDevelopment bottleneck
Jenkins (time based) → CircleCIConfidence/tooling bottleneck
Release coordination → AWS servicesProvisioning speed bottleneck
Need for better virtualization tools
![Page 8: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/8.jpg)
Monolith (VirtualBox) → SplitDevelopment bottleneck
Jenkins (time based) → CircleCIConfidence/tooling bottleneck
Release coordination → AWS servicesProvisioning speed bottleneck
Need for better virtualization tools
docker?
![Page 9: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/9.jpg)
We migrated to dockerUsing docker extensively at
Learning curve was highWere pioniers, added tooling around
I would do the same againRight decision for current scaleFuture opportunities
![Page 10: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/10.jpg)
Why to dockerizeWhat is dockerHow to dockerize
Introduction
Development
Production
Context/AlternativesWhat I really likedWhat I do not like
Deploying to AWS
![Page 11: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/11.jpg)
Tool to run in isolated environmentMany ifs in kernel = cgroupsNot VirtualBox, not unikernel
Open source tool backed by Docker IncContainer hosting and premium serviceImproved by community (AWS, K8s)
![Page 12: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/12.jpg)
Why to dockerizeWhat is dockerHow to dockerize
Introduction
Development
Production
Context/AlternativesWhat I really likedWhat I do not like
Deploying to AWS
![Page 13: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/13.jpg)
![Page 14: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/14.jpg)
![Page 15: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/15.jpg)
docker build . -t vilniusphp-exampledocker run -p 8080:80 vilniusphp-example
![Page 16: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/16.jpg)
https://gist.github.com/aurelijusb/6f6b1c86c440ce527250193ffcae62d7
docker build . -t vilniusphp-exampledocker run -p 8080:80 vilniusphp-example
![Page 17: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/17.jpg)
https://gist.github.com/aurelijusb/6f6b1c86c440ce527250193ffcae62d7
docker build . -t vilniusphp-exampledocker run -p 8080:80 vilniusphp-exampleSimple?
![Page 18: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/18.jpg)
https://gist.github.com/aurelijusb/6f6b1c86c440ce527250193ffcae62d7
docker build . -t vilniusphp-exampledocker run -p 8080:80 vilniusphp-exampleSimple?But for simple cases
![Page 19: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/19.jpg)
Multiple containers
Development tools
PHP extensions
xDebug support
...https://github.com/nfqakademija/docker/blob/master/php/Dockerfile
![Page 20: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/20.jpg)
Multiple containers
Development tools
PHP extensions
xDebug support
...https://github.com/nfqakademija/docker/blob/master/php/Dockerfile
More configuration
![Page 21: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/21.jpg)
Multiple containers
Development tools
PHP extensions
xDebug support
...https://github.com/nfqakademija/docker/blob/master/php/Dockerfile
More configurationBut infrastructure
as a code
![Page 23: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/23.jpg)
Multiple containers
Development tools
PHP extensions
xDebug support
...https://github.com/nfqakademija/docker/blob/master/php/Dockerfile
Docker wayLogging stdout/stderrConfiguration via ENV
Kill-it-not-heal-it….
![Page 24: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/24.jpg)
Why to dockerizeWhat is dockerHow to dockerize
Introduction
Development
Production
Context/AlternativesWhat I really likedWhat I do not like
Deploying to AWS
![Page 25: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/25.jpg)
Why to dockerizeWhat is dockerHow to dockerize
Introduction
Development
Production
Context/AlternativesWhat I really likedWhat I do not like
Deploying to AWS
![Page 26: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/26.jpg)
DockerFeaturetoggle
IDE in cloud
Run & pray
Virtual box
Not many alternativesFor isolated environments
![Page 27: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/27.jpg)
Why to dockerizeWhat is dockerHow to dockerize
Introduction
Development
Production
Context/AlternativesWhat I really likedWhat I do not like
Deploying to AWS
![Page 28: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/28.jpg)
Sandboxed development environmentHigh quality mocks (real MySql, wireshark)True integration/acceptance testsDockerfile→docker-compose→custom tooling
Experimenting with new software saferNo trash, no sensitive informationEasy to swap (DynamoDB local vs dynalite)Install/compile on your machine? Seriously?
![Page 29: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/29.jpg)
Switching between branches/tasksLess issues with cache invalidationKill-it-not-heal-itData volumes = test data in branch
Infrastructure as a codeFixed versions, fixed php.ini+extensionsLess “works on my machine” = reproducibleMany bash scripts, configuration via ENV
![Page 30: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/30.jpg)
Huge ecosystemPioniers are using and improvingAmazon, Google (K8s) is investingKnown issues and solutions in StackOverflow
![Page 31: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/31.jpg)
Why to dockerizeWhat is dockerHow to dockerize
Introduction
Development
Production
Context/AlternativesWhat I really likedWhat I do not like
Deploying to AWS
![Page 32: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/32.jpg)
High learning curve = blame dockerMisuse of the tool – isn’t docker silver bullet?Docker wraps – everyone blames the wrapperMany ways to install docker incorrectlyMounting vs copy-on-write operationNo Windows, more tooling/docs around
![Page 33: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/33.jpg)
Not mature tooling / edge casesDownload private dependency: github token?Password protected SSH key? (Mac+Linux)CircleCI limited “remote docker”Host IP for xDebugEven more bash scripts/docs
![Page 34: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/34.jpg)
Cache everything by designFull HDD because of docker imagesMissing log rotation (no “log-opts” by default)“Latest” tag, that is not immutableNetwork unreachable, since used by dockerDocker-clean sh, docker pull, RTFM
![Page 35: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/35.jpg)
Why to dockerizeWhat is dockerHow to dockerize
Introduction
Development
Production
Context/AlternativesWhat I really likedWhat I do not like
Deploying to AWS
![Page 36: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/36.jpg)
Why to dockerizeWhat is dockerHow to dockerize
Introduction
Development
Production
Context/AlternativesWhat I really likedWhat I do not like
Deploying to AWS
![Page 37: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/37.jpg)
○ ECS (not yet K8s, AWS backed infrastructure/improvements, canary deployment by default)
○ ECR – uptime for downloads. Docker hub for development○ Task definition = docker-compose.yml○ PHP+Apache = PHP+Nginx (no big difference)○ Custom tooling for credentials via environment○ Spot-instances (currently for staging, targeting production)
PHP + Docker in productionMigrated Tier1 service – nobody noticed
AWS ECS PHP 7.2
Docker Apache
![Page 38: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/38.jpg)
○ ECS (not yet K8s, AWS backed infrastructure/improvements, canary deployment by default)
○ ECR – uptime for downloads. Docker hub for development○ Task definition = docker-compose.yml○ PHP+Apache = PHP+Nginx (no big difference)○ Custom tooling for credentials via environment○ Spot-instances (currently for staging, targeting production)
PHP + Docker in productionMigrated Tier1 service – nobody noticed
AWS ECS PHP 7.2
Docker Apache
![Page 39: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/39.jpg)
Amazon Web ServicesElastic Container ServiceHigh quality AWS integrationK8s on AWS then was not matureKnow-how (our Go apps in prod)
Naming in AWSDocker-compose → Task definitionContainer → TaskDocker Hub → ECR
![Page 40: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/40.jpg)
Apache mod_phpPHP 7.2 log trimming in Nginx+FPMSingle process container – easierInternal service (no slow loris attack)No visible performance impact
Replica Daemon External
Logging
![Page 41: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/41.jpg)
Why to dockerizeWhat is dockerHow to dockerize
Introduction
Development
Production
Context/AlternativesWhat I really likedWhat I do not like
Deploying to AWS
![Page 42: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/42.jpg)
DockerFeaturetoggle
IDE in cloud
Run & pray
Virtual box
Docker:Good to understand
Use on demand
![Page 43: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/43.jpg)
Aurelijus Banelis
Dockerizing PHP Apps
VilniusPHP2018-11-08
Thank youQuestions?
![Page 44: Dockerizing PHP Apps - aurelijus.banelis.lt · Docker hub for development Task definition = docker-compose.yml PHP+Apache = PHP+Nginx (no big difference) Custom tooling for credentials](https://reader035.vdocument.in/reader035/viewer/2022081517/5fc4a8173283a01132354559/html5/thumbnails/44.jpg)
Further reading/references● https://www.docker.com/● https://hub.docker.com/ ● https://aws.amazon.com/ecs/● https://aws.amazon.com/ecr/ ● https://fluentbit.io/● https://www.home24.de/ ● https://home24.tech.blog/category/aws/● https://aws.amazon.com/blogs/opensource/network-load-balancer-support-in-kubernetes-1-9/