Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kickass Development Environments with Docker (P...
Search
David McKay
January 26, 2019
Technology
0
96
Kickass Development Environments with Docker (PHPBenelux 2019)
David McKay
January 26, 2019
Tweet
Share
More Decks by David McKay
See All by David McKay
The Telegraf Toolbelt (InfluxDays SF, 2019)
rawkode
0
130
The DShell Pattern (DevOpsDays London 2019)
rawkode
0
190
Cloud Native Telegraf - Cloud Native London (September 2019)
rawkode
0
45
Developing Your Own Flux Packages (InfluxDays London 2019)
rawkode
0
120
Introduction to Time Series (Software Circus, April 2019)
rawkode
0
140
Introduction to Time Series (Cloud Native Kraków, April 2019)
rawkode
0
89
Introduction to Time Series (Cloud Native Wales, April 2019)
rawkode
0
81
Introduction to InfluxDB 2.0 (Kubernetes London - February 2019)
rawkode
0
56
LaraconEU 2018 - Kickass Development Environments with Docker
rawkode
2
290
Other Decks in Technology
See All in Technology
MLOps の現場から
asei
7
650
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
360
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
130
なぜCodeceptJSを選んだか
goataka
0
160
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
200
Qiita埋め込み用スライド
naoki_0531
0
5.1k
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
19
18k
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
170
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
110
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
290
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
17
4.8k
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
600
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
For a Future-Friendly Web
brad_frost
175
9.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
4 Signs Your Business is Dying
shpigford
181
21k
Docker and Python
trallard
42
3.1k
Producing Creativity
orderedlist
PRO
341
39k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Designing for humans not robots
tammielis
250
25k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Being A Developer After 40
akosma
87
590k
Transcript
Hi #phpbnl19
Kickass Development Environments with Docker
@rawkode David McKay ◍ Developer Advocate at InfluxData ◍ Docker
/ CI / CD ◍ DevOps / SaltStack ◍ Event-Driven Systems ◍ CQRS / ES ◍ Elixir, Go, and Rust
Let us travel through time ...
My Development Environment Circa 2000 $ tree awesome-million-pound-project └── src
├── game.php ├── game.php.bk-david ├── game.php.bk-deano ├── main.php ├── main.php.maybe-fixed ├── main.php.bk-1999-12-02 ├── main.php.bk-1999-12-02.2 ├── player.php ├── player.php.orig └── .swp.player.php
My Development Production Environment Circa 2000 $ tree awesome-million-pound-project └──
src ├── game.php ├── game.php.bk-david ├── game.php.bk-deano ├── main.php ├── main.php.maybe-fixed ├── main.php.bk-1999-12-02 ├── main.php.bk-1999-12-02.2 ├── player.php ├── player.php.orig └── .swp.player.php
Things eventually got better ...
None
None
Dev / Prod Parity
Eurgh, DSL Hell
None
Problems with Vagrant Slow to provision RAM intensive Really, development
only Requires a CM tool
How long does your vagrant up take?
None
“ Docker allows you to package an application with all
of its dependencies into a standardized unit for software development.
Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍
Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
Image Building Introducing the Dockerfile
(Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y
php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
(Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y
php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
(Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y
php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
(Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y
php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
(Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y
php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
None
ENTRYPOINT & CMD Explained in 20 seconds
ENTRYPOINT and CMD Explained in 17 seconds ... CMD [“echo”,
“Hello”] in a Dockerfile docker run my-image == $ Hello
ENTRYPOINT and CMD Explained in 13 seconds ... CMD [“echo”,
“Hello”] in a Dockerfile docker run my-image echo Goodbye == $ Goodbye
ENTRYPOINT and CMD Explained in 10 seconds ... ENTRYPOINT [“echo”]
CMD [“Hello”] in a Dockerfile docker run my-image == $ Hello
ENTRYPOINT and CMD Explained in 7 seconds ... ENTRYPOINT [“echo”]
CMD [“Hello”] in a Dockerfile docker run --entrypoint=”echo” my-image Woop! == $ Woop!
ENTRYPOINT and CMD Explained in 4 seconds ... ENTRYPOINT [“echo”]
CMD [“Hello”] in a Dockerfile docker run --entrypoint=”echo” my-image == $
None
Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍
Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
Virtualisation Running Docker Images as Containers
Demo
Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍
Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
Orchestration (Dev) Composing Services
Your Super Application
Your Super Application
Docker Compose
docker-compose.yml version: “3”
docker-compose.yml version: “3” services: php: image: php:7 ports: - 80:80
volumes: - .:/code
docker-compose.yml version: “3” services: php: image: php:7 … database: image:
mariadb:latest environment: MYSQL_USERNAME: rawkode MYSQL_PASSWORD: *******
docker-compose.yml version: “3” services: php: image: php:7 … database: image:
mariadb:latest environment: MYSQL_USERNAME: rawkode MYSQL_PASSWORD: *******
docker-compose.yml version: “3” services: php: image: php:7 healthcheck: test: nc
-z localhost 80 depends_on: - database
Demo
Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍
Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
Tips I’ve learnt the hard way, so you don’t have
to
Tips: Use Random Ports services: php: ports: - 80
Tips: Mindful of Network Collisions Every new docker-compose file is,
potentially, a new docker network / bridge on your host. Eventually, you’ll get a collision docker-compose down
Tips: Prune docker system prune Docker CE >= 17.04
Tips: env_file Lots of environment variables defined inside compose.yml? Duplication?
env_file: - some file
Tips: Alpine Linux Unless you need Ubuntu / Fedora, use
Alpine Linux Ubuntu -- 130MB Alpine -- 3.99MB
Tips: Keep a Single Dockerfile Using MultiStage Builds, you can
usually keep your project to a single Dockerfile FROM node AS node RUN npm install FROM php COPY --from=node assets
Tips: Don’t Bust Your Build Cache COPY composer.json /code RUN
composer install COPY . /code
Tips: Logging ALWAYS LOG to STDOUT
Production Tip Mandatory Requirement --read-only
Warning Microservices
“ That which is old will be new again
Microservices
Microservices
Microservices
Microservices
Microservices
What is old will be new again Shared Kubernetes Dev
Server
Microservices
Shared Kubernetes Dev Server Tooling Skaffold github.com/GoogleContainerTools/skaffold Draft github.com/Azure/draft Telepresence
github.com/telepresenceio/telepresence
Shared Kubernetes Dev Server Tooling Istio github.com/istio/istio Linkerd linkerd/linkerd2 Consul
Connect github.com/hashicorp/consul
Creating a fast Kubernetes Development Workflow Bastian Hofmann / 1140
/ Track B
Questions?