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
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
Kickass Development Environments with Docker (PHPBenelux 2019)
rawkode
0
96
Other Decks in Technology
See All in Technology
DevFest 2024 Incheon / Songdo - Compose UI 조합 심화
wisemuji
0
120
DUSt3R, MASt3R, MASt3R-SfM にみる3D基盤モデル
spatial_ai_network
2
190
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
480
バクラクのドキュメント解析技術と実データにおける課題 / layerx-ccc-winter-2024
shimacos
2
1.1k
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
1
560
watsonx.ai Dojo #5 ファインチューニングとInstructLAB
oniak3ibm
PRO
0
170
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
170
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
0
210
サーバーなしでWordPress運用、できますよ。
sogaoh
PRO
0
110
事業貢献を考えるための技術改善の目標設計と改善実績 / Targeted design of technical improvements to consider business contribution and improvement performance
oomatomo
0
100
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
KATA
mclloyd
29
14k
Side Projects
sachag
452
42k
Automating Front-end Workflow
addyosmani
1366
200k
Building Your Own Lightsaber
phodgson
103
6.1k
A Tale of Four Properties
chriscoyier
157
23k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Making Projects Easy
brettharned
116
5.9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
520
Speed Design
sergeychernyshev
25
670
Gamification - CAS2011
davidbonilla
80
5.1k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
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