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
LaraconEU 2018 - Kickass Development Environmen...
Search
David McKay
August 30, 2018
Technology
2
290
LaraconEU 2018 - Kickass Development Environments with Docker
David McKay
August 30, 2018
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
180
Cloud Native Telegraf - Cloud Native London (September 2019)
rawkode
0
42
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
88
Introduction to Time Series (Cloud Native Wales, April 2019)
rawkode
0
79
Introduction to InfluxDB 2.0 (Kubernetes London - February 2019)
rawkode
0
55
Kickass Development Environments with Docker (PHPBenelux 2019)
rawkode
0
93
Other Decks in Technology
See All in Technology
ラブグラフ紹介資料 〜プロダクト解体新書〜 / Lovegraph Product Deck
lovegraph
0
14k
Low Latency Join Method for Distributed DBMS
yugabytejapan
0
170
DenoでもViteしたい!インポートパスのエイリアスを指定してラクラクアプリ開発
bengo4com
2
1.9k
エムスリー全チーム紹介資料 / Introduction of M3 All Teams
m3_engineering
1
310
Tracking down sources of kernel errors with retsnoop
ennael
PRO
0
160
【shownet.conf_】クロージングセッション
shownet
PRO
0
300
入社半年(合計1年)でGoogle Cloud 認定を全冠した秘訣🤫
risatube
0
140
KubeVirt Networking ONIC 2024
orimanabu
3
270
「ばん・さく・つき・たー!」にならないためにSHIROBAKOから 学んだこと
ysknsid25
3
670
kube-vipとkube-proxy置き換えCiliumを積んだ究極のK3sクラスタを建てる
logica0419
4
210
AWS Lambdaで実現するスケーラブルで低コストなWebサービス構築/YAPC::Hakodate2024
fujiwara3
7
3.1k
LeSSはスクラムではない!?LeSSにおけるスクラムマスターの振る舞い方とは / Scrum Master Behavior in LeSS
toma_sm
0
190
Featured
See All Featured
Unsuck your backbone
ammeep
668
57k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.5k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
7
580
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Six Lessons from altMBA
skipperchong
26
3.4k
The Pragmatic Product Professional
lauravandoore
31
6.2k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.6k
A Tale of Four Properties
chriscoyier
156
22k
Mobile First: as difficult as doing things right
swwweet
222
8.8k
YesSQL, Process and Tooling at Scale
rocio
167
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2k
Agile that works and the tools we love
rasmusluckow
327
21k
Transcript
Hello, LaraconEU 2018
@rawkode @
[email protected]
Organiser of Things ◍ Cloud Native Glasgow ◍
DevOps Glasgow ◍ MongoDB Glasgow ◍ PairProg Glasgow Software & Site Reliability ◍ Elixir / Rust / Go / Pony ◍ Docker / CI / CD ◍ DevOps / SaltStack ◍ Event-Driven Systems ◍ CQRS / ES
Kickass Development Environments with Docker
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 ◍ Image Delivery ◍ Virtualisation ◍
Orchestration (Dev) ➢ docker image build ➢ docker image push/ll ➢ docker container run ➢ docker-compose Build. Ship. Run.
Image Building Introducing the Dockerfile
(Simplified) Dockerfile for PHP FROM ubuntu:18.04 RUN apt install -y
php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
(Simplified) Dockerfile for PHP FROM ubuntu:18.04 RUN apt install -y
php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
(Simplified) Dockerfile for PHP FROM ubuntu:18.04 RUN apt install -y
php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
(Simplified) Dockerfile for PHP FROM ubuntu:18.04 RUN apt install -y
php-cli COPY hello.php /code WORKDIR /code # PLEASE DON’T DO RUN cd /code
(Simplified) Dockerfile for PHP FROM ubuntu:18.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 ◍ Image Delivery ◍ Virtualisation ◍
Orchestration (Dev) ➔ docker image build ➔ docker image push/ll ➔ docker container run ➔ docker-compose
Image Delivery & Virtualisation Running Docker Images as Containers
Demo
Docker ◍ Image Builder ◍ Image Delivery ◍ Virtualisation ◍
Orchestration (Dev) ➔ docker build ➔ docker push / pull ➔ docker run ➔ docker-compose
Orchestration (Dev) Composing Services
Your Super Application
Your Super Application
Docker Compose
Docker for Local Development 4 Easy Steps. I’ll discuss 3.
1. Satisfy Dependencies 2. Introduce Docker for CI 3. Adopt Docker Shell Pattern 4. 12-Factor (Catch Alex’s talk on YouTube)
Satisfy Dependencies PostgreSQL, Redis, Elasticsearch, et al.
docker-compose.yml services: database: image: mariadb:10.1 environment: MYSQL_USER: rawkode MYSQL_PASSWORD: *******
MYSQL_DATABASE: my-awesome-app
docker-compose.yml version: “2.4”
docker-compose.yml version: “2.4” services: php: image: php:7 ports: - 80:80
volumes: - .:/code:cached tmpfs: - /code/var/logs - /code/var/cache
docker-compose.yml version: “2.4” services: php: image: php:7 … database: image:
mariadb:10.1 environment: MYSQL_USERNAME: rawkode MYSQL_PASSWORD: *******
docker-compose.yml version: “2.4” services: php: image: php:7 healthcheck: test: nc
-z localhost 80 depends_on: database: condition: service_healthy
Introduce Docker to CI Craft Your Dockerfile
Docker for CI ◍ Multi-Stage Builds ◍ Mind Your Build-Cache
◍ Be Wary of “Helper” Scripts ◍ We’ll cover these in the demo
Docker Shell Maintain Native Workflows
Docker Shell Pattern ◍ Your base container has all your
system dependencies (Don’t use --ignore-platform-reqs) ◍ Work natively, but in the container ◍ You’ll still get all the perks
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
Zsh Plugin https://github.com /rawkode /zsh-docker-run
Tips: Don’t Bust Your Build Cache COPY composer.json /code RUN
composer install COPY . /code
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 Add -v to remove volumes
Tips: Logging ALWAYS LOG to STDOUT
Tips: Prune docker system prune Docker CE >= 17.04
Tips: Alpine Linux Unless you need Ubuntu / Fedora, use
Alpine Linux Ubuntu -- 130MB / 85MB Alpine -- 3.99MB
Production Tip nginx & fpm --volumes-from=php
Production Tip Open Census Open Metrics Open Tracing
Production Tip Mandatory Requirement --read-only
Thank You! Questions? @
[email protected]
@rawkode