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
300
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
140
The DShell Pattern (DevOpsDays London 2019)
rawkode
0
200
Cloud Native Telegraf - Cloud Native London (September 2019)
rawkode
0
48
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
90
Introduction to Time Series (Cloud Native Wales, April 2019)
rawkode
0
86
Introduction to InfluxDB 2.0 (Kubernetes London - February 2019)
rawkode
0
56
Kickass Development Environments with Docker (PHPBenelux 2019)
rawkode
0
100
Other Decks in Technology
See All in Technology
Cloud Spanner 導入で実現した快適な開発と運用について
colopl
1
320
現場で役立つAPIデザイン
nagix
32
11k
Tech Blogを書きやすい環境づくり
lycorptech_jp
PRO
1
230
開発スピードは上がっている…品質はどうする? スピードと品質を両立させるためのプロダクト開発の進め方とは #DevSumi #DevSumiB / Agile And Quality
nihonbuson
2
2.4k
開発組織のための セキュアコーディング研修の始め方
flatt_security
3
1.4k
Larkご案内資料
customercloud
PRO
0
650
プロセス改善による品質向上事例
tomasagi
2
2.2k
OpenID BizDay#17 KYC WG活動報告(法人) / 20250219-BizDay17-KYC-legalidentity
oidfj
0
140
30分でわかる『アジャイルデータモデリング』
hanon52_
9
2.5k
地方拠点で エンジニアリングマネージャーってできるの? 〜地方という制約を楽しむオーナーシップとコミュニティ作り〜
1coin
1
220
モノレポ開発のエラー、誰が見る?Datadog で実現する適切なトリアージとエスカレーション
biwashi
6
790
滅・サービスクラス🔥 / Destruction Service Class
sinsoku
6
1.6k
Featured
See All Featured
Faster Mobile Websites
deanohume
306
31k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Fireside Chat
paigeccino
34
3.2k
How to train your dragon (web standard)
notwaldorf
91
5.8k
Docker and Python
trallard
44
3.3k
Producing Creativity
orderedlist
PRO
343
39k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Side Projects
sachag
452
42k
Six Lessons from altMBA
skipperchong
27
3.6k
Facilitating Awesome Meetings
lara
51
6.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
A better future with KSS
kneath
238
17k
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