SlideShare a Scribd company logo
1 of 67
A Docker-based
Development Environment
Even I Can Understand
Jeremy Gimbel @dreadfullyposh
Obligatory “Who Am I” Slide
● Husband
● Father
● Based in Philadelphia
● Have worked with ExpressionEngine since 2010
● I was the MojoAddons guy
● Web Services Manager at Vector Media Group
The Development Environment Progression
The Development Environment Progression
1. Do It Live™
The Development Environment Progression
1. Do It Live™
2. MAMP / Local Servers
The Development Environment Progression
1. Do It Live™
2. MAMP / Local Servers
3. Vagrant (Homestead / Scotchbox / etc.)
Docker
What is this “Docker” you speak of?
Docker is virtual computing platform.
The big idea behind it is containerization
Creates a virtual host machine on your physical computer
Application-specific containers run your web server stack
My First Look at Docker
Image
Machine
Docker Compose
Registry
Services
Container
Dockerfile
Network
Swarm
How does Docker work?
Docker works in Layers
Dockerfile
Image
Built to become
an image
Container is
created from an
image
Container
Ok, it’s not that simple
Dockerfile
Image
Container
Dockerfile
Dockerfile FROM: debian:jessie-backports
apache:latest
FROM: debian:jessie
FROM: scratch
Docker Compose
Docker Compose
Docker Compose is a tool within Docker that lets you define
and run multi-container applications.
Applications are defined inside a file called docker-
compose.yml.
The containers inside an application are called services.
Docker Compose
Apache
PHP-FPM
Redis
Your Application
Learning More
Learning More
Check out the two Docker for Development
series on Servers for Hackers
https://serversforhackers.com/t/containers
Dash
The Fine Print
What is Dash
Dash is an approach to using Docker and an accompanying
shell script, originally written by IFTTT.
What is Dash
Nginx Proxy
MySQL
DNSMasq
Your Application
MailHog
Dash
Apache
PHP-FPM
Another
Application
Nginx
PHP-FPM
PHPMyAdmin
Nginx Proxy? DNSMasq? Oh my!
Nginx Proxy? DNSMasq? Oh my!
Your
Application
Apache
PHP-FPM
Another
Application
Nginx
PHP-FPM
Docker Machine
Your Local
Machine
Port 80
Port 443
Port 3306
Nginx Proxy? DNSMasq? Oh my!
Nginx Proxy
MySQL
DNSMasq
Your
Application
MailHog
Dash
Apache
PHP-FPM
Another
Application
Nginx
PHP-FPM
Docker Machine
Your Local
Machine
Port 80
Port 443
Port 3306
PHPMyAdmin
How do I set up this wizardry?
Setting Up Dash
1. Install Docker (duh)
2. Clone the Dash repo:
https://github.com/dreadfullyposh/dash
3. Add your Dash directory to your path
Adding Dash to your Path
1. Open Terminal
2.cd ~ <enter>
3.nano .bash_profile <enter>
4. Add a line like this: PATH=$PATH:/path/to/dash
<control-x> <y> <enter>
5. Exit Terminal
6.echo $PATH <enter> to confirm your the PATH variable
has been updated.
Adding Dash to your Path
At this point you should be able to type dev <enter> in your
terminal window and see a bunch of information display.
jeremy@mac ~> dev
Execute various commands within the developer environment
Usage:
dev [options] [COMMAND] [ARGS...]"
Setting Up Dash
1. Install Docker (duh)
2. Clone the Dash repo: github.com/dreadfullyposh/dash
3. Add your Dash directory to your path
4. Create a Docker network for your Dash setup by running
docker network create dash
Setting Up Dash
1. Install Docker (duh)
2. Clone the Dash repo: github.com/dreadfullyposh/dash
3. Add your Dash directory to your path
4. Create a Docker network for your Dash setup by running
docker network create dash
5. Configure your Mac to resolve *.test with DNSMasq
Configure Resolver
1. Open Terminal
2.cd /etc <enter>
3.mkdir resolver <enter>
4.cd resolver <enter>
5.nano test <enter>
6. type nameserver 127.0.0.1
7. <control-x> <y> <enter>
8. Restart, in honor of our Windows friends
Setting Up Dash
1. Install Docker (duh)
2. Clone the Dash repo: github.com/dreadfullyposh/dash
3. Add your Dash directory to your path
4. Create a Docker network for your Dash setup by running
docker network create dash
5. Configure your Mac to resolve *.test with DNSMasq
6. Setup SSL
Setup SSL
1. Open Terminal
2.cd /your/dash/directory/certs <enter>
3../generatecertificate.sh <enter>
4. Open Keychain Access
5. Drag the .crt file from the certs directory to the Keychain
Access window.
6. Double click the certificate
7. Edit the Trust option to Always
Start it Up
Open Terminal
dev dash up <enter>
jeremy@mac ~> dev dash up
Creating dash_dnsmasq_1 ... done
Creating dash_mysql_1 ... done
Creating dash_nginx_1 ... done
Creating dash_phpmyadmin_1 ... done
Creating dash_mailhog_1 ... done
But.. what did that do? - Looking at dash.yml
version: '3'
services:
# Nginx Proxy
nginx:
build: ./docker/nginx
ports:
- "80:80"
Looking at dash.yml
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs
restart: always
# DNSMasq Server
dnsmasq:
Looking at dash.yml
image: andyshinn/dnsmasq
ports:
- "127.0.0.1:53:53/tcp"
- "127.0.0.1:53:53/udp"
cap_add:
- NET_ADMIN
command: --address=/test/127.0.0.1
Looking at dash.yml
restart: always
# MySQL
mysql:
image: mysql:5.6
environment:
- MYSQL_ROOT_PASSWORD=root
Looking at dash.yml
volumes:
- ./data/mysql:/var/lib/mysql:rw
ports:
- "3306:3306"
restart: always
# MailHog
mailhog:
Looking at dash.yml
image: mailhog/mailhog
ports:
- "1025:1025"
expose:
- 8025
restart: always
Looking at dash.yml
depends_on:
- nginx
environment:
VIRTUAL_HOST: mailhog.dev.test
VIRTUAL_PORT: 8025
# PHPMyAdmin
phpmyadmin:
image: phpmyadmin/phpmyadmin
Looking at dash.yml
expose:
- 80
restart: always
depends_on:
- nginx
- mysql
environment:
VIRTUAL_HOST: phpmyadmin.dev.test
PMA_HOST: mysql
PMA_USER: root
PMA_PASSWORD: root
Looking at dash.yml
# Configure the Docker network to use
networks:
default:
external:
name: dash
Setting up a Project
Setting Up a Project
1. Copy example/docker-compose.yml to your project
directory.
Setting Up a Project
1. Copy example/docker-compose.yml to your project
directory.
2. Configure docker-compose.yml
Configure docker-compose.yml
version: '3'
services:
web:
image: webdevops/php-apache:latest
ports:
- 80
environment:
WEB_DOCUMENT_ROOT: /app/public
VIRTUAL_HOST: projectname.dev.test
HTTPS_METHOD: redirect
volumes:
Configure docker-compose.yml
version: '3'
services:
web:
image: webdevops/php-apache:latest
ports:
- 80
environment:
WEB_DOCUMENT_ROOT: /app/public
VIRTUAL_HOST: projectname.dev.test
HTTPS_METHOD: redirect
volumes:
Configure docker-compose.yml
version: '3'
services:
web:
image: webdevops/php-apache:latest
ports:
- 80
environment:
WEB_DOCUMENT_ROOT: /app/public
VIRTUAL_HOST: projectname.dev.test
HTTPS_METHOD: redirect
volumes:
Configure docker-compose.yml
version: '3'
services:
web:
image: webdevops/php-apache:latest
ports:
- 80
environment:
WEB_DOCUMENT_ROOT: /app/public
VIRTUAL_HOST: projectname.dev.test
HTTPS_METHOD: redirect
volumes:
Configure docker-compose.yml
version: '3'
services:
web:
image: webdevops/php-apache:latest
ports:
- 80
environment:
WEB_DOCUMENT_ROOT: /app/public
VIRTUAL_HOST: projectname.dev.test
HTTPS_METHOD: redirect
volumes:
Configure docker-compose.yml
volumes:
- ./:/app
networks:
default:
external:
name: dash
Setting Up a Project
1. Copy example/docker-compose.yml to your project
directory.
2. Configure docker-compose.yml
3. Start project
Start your Project
1. Open Terminal
2.cd /your/project/directory <enter>
3.dev up <enter>
jeremy@mac ~> dev up
dash_nginx_1 is up-to-date
dash_dnsmasq_1 is up-to-date
dash_mysql_1 is up-to-date
dash_mailhog_1 is up-to-date
dash_phpmyadmin_1 is up-to-date
Starting projectdir_web_1 ... done
Connecting to MySQL
Since MySQL is in the Dash, you can’t just connect to it via
localhost.
From Web Container
Host: mysql
Username: root
Password: root
From Local Computer (Sequel Pro)
Host: 127.0.0.1
Username: root
Password: root
Connecting to MailHog
With MailHog running, we have a fake SMTP server running
so we can monitor any messages sent from our application.
From Application
SMTP Server: mailhog
Port: 1025
Access MailHog From Local Machine
Host: https://mailhog.dev.test
Connecting to PHPMyAdmin
PHPMyAdmin is available in the Dash if you don’t want to
use Sequel Pro.
Access PHPMyAdmin From Local Machine
Host: https://phpmyadmin.dev.test
The username and password are already defined, so you
should be logged in automatically.
That’s it?
Gotchas
● Make sure you aren’t running MAMP or some other
servers on the same ports: 80, 443, 53 and 3306.
● Make sure you dev down your projects when you’re not
using them. The more containers you run, the more of
your computer’s resources will be tied up running Docker.
Other Useful Tips
To shut down a project: dev down
To shut down the Dash: dev dash down
Make sure to download and install Kitematic, available from
the Docker menubar icon.
To run a command inside a container in your project:
dev exec servicename somecommand
Where to Go From Here
Now that you’ve got a base setup running, you can extend it
by adding more containers. Here are some ideas.
Where to Go From Here
Need to install Node dependencies? Add a node container.
Then run dev run node yarn install
node:
image: node:8
volumes:
- .:/opt
working_dir: /opt
Where to Go From Here
Need to share your development environment with others?
Install an ngrok container.
ngroktunnel:
image: gtriggiano/ngrok-tunnel:development
ports:
- "4040"
environment:
NGROK_REGION: us
TARGET_HOST: web
TARGET_PORT: 80
VIRTUAL_HOST: appname-ngrok.dev.vmg
depends_on:
- web
Wait.. what were those links again?
Servers for Hackers Containers Courses
https://serversforhackers.com/t/containers
Dash Repo on Github
https://github.com/dreadfullyposh/dash
WebDevOps Docker Images
https://hub.docker.com/r/webdevops/
Also, please leave speaker feedback
https://eeconf.com/speaker-feedback

More Related Content

What's hot

Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
LumoSpark
 
Create dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLCreate dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQL
kangaro10a
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorial
tutorialsruby
 

What's hot (20)

Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))
 
A complete guide to Node.js
A complete guide to Node.jsA complete guide to Node.js
A complete guide to Node.js
 
About Node.js
About Node.jsAbout Node.js
About Node.js
 
Building your own Desktop Cloud Environment
Building your own Desktop Cloud EnvironmentBuilding your own Desktop Cloud Environment
Building your own Desktop Cloud Environment
 
IaC and Immutable Infrastructure with Terraform, Сергей Марченко
IaC and Immutable Infrastructure with Terraform, Сергей МарченкоIaC and Immutable Infrastructure with Terraform, Сергей Марченко
IaC and Immutable Infrastructure with Terraform, Сергей Марченко
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
 
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP ModeEmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Create dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLCreate dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQL
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
 
Deploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows ContainersDeploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows Containers
 
Getting Started with Docker (For Developers)
Getting Started with Docker (For Developers)Getting Started with Docker (For Developers)
Getting Started with Docker (For Developers)
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorial
 
Hands on Docker - Launch your own LEMP or LAMP stack
Hands on Docker -  Launch your own LEMP or LAMP stackHands on Docker -  Launch your own LEMP or LAMP stack
Hands on Docker - Launch your own LEMP or LAMP stack
 
Vagrant for real
Vagrant for realVagrant for real
Vagrant for real
 
WordPress + Amazon Web Services Hands-on WARSAW
WordPress + Amazon Web Services Hands-on WARSAWWordPress + Amazon Web Services Hands-on WARSAW
WordPress + Amazon Web Services Hands-on WARSAW
 
Migration from ASP to ASP.NET
Migration from ASP to ASP.NETMigration from ASP to ASP.NET
Migration from ASP to ASP.NET
 
AMIMOTO: WordPress + Amazon Web Services Hands-on WARSAW
AMIMOTO: WordPress + Amazon Web Services Hands-on WARSAW AMIMOTO: WordPress + Amazon Web Services Hands-on WARSAW
AMIMOTO: WordPress + Amazon Web Services Hands-on WARSAW
 
Docker - from development to production (PHPNW 2017-09-05)
Docker - from development to production (PHPNW 2017-09-05)Docker - from development to production (PHPNW 2017-09-05)
Docker - from development to production (PHPNW 2017-09-05)
 

Similar to A Docker-based Development Environment Even I Can Understand

Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
Patrick Mizer
 

Similar to A Docker-based Development Environment Even I Can Understand (20)

Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccion
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
 
Docker
DockerDocker
Docker
 
A Hands-on Introduction to Docker
A Hands-on Introduction to DockerA Hands-on Introduction to Docker
A Hands-on Introduction to Docker
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
 
Docker for (Java) Developers
Docker for (Java) DevelopersDocker for (Java) Developers
Docker for (Java) Developers
 
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
 
Capistrano Overview
Capistrano OverviewCapistrano Overview
Capistrano Overview
 
Container (Docker) Orchestration Tools
Container (Docker) Orchestration ToolsContainer (Docker) Orchestration Tools
Container (Docker) Orchestration Tools
 
Dockerize Laravel Application
Dockerize Laravel ApplicationDockerize Laravel Application
Dockerize Laravel Application
 
Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 

Recently uploaded

Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
imonikaupta
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Sheetaleventcompany
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
sexy call girls service in goa
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 

Recently uploaded (20)

Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 

A Docker-based Development Environment Even I Can Understand

  • 1. A Docker-based Development Environment Even I Can Understand Jeremy Gimbel @dreadfullyposh
  • 2. Obligatory “Who Am I” Slide ● Husband ● Father ● Based in Philadelphia ● Have worked with ExpressionEngine since 2010 ● I was the MojoAddons guy ● Web Services Manager at Vector Media Group
  • 4. The Development Environment Progression 1. Do It Live™
  • 5. The Development Environment Progression 1. Do It Live™ 2. MAMP / Local Servers
  • 6. The Development Environment Progression 1. Do It Live™ 2. MAMP / Local Servers 3. Vagrant (Homestead / Scotchbox / etc.)
  • 7.
  • 9. What is this “Docker” you speak of? Docker is virtual computing platform. The big idea behind it is containerization Creates a virtual host machine on your physical computer Application-specific containers run your web server stack
  • 10. My First Look at Docker Image Machine Docker Compose Registry Services Container Dockerfile Network Swarm
  • 11.
  • 13. Docker works in Layers Dockerfile Image Built to become an image Container is created from an image Container
  • 14. Ok, it’s not that simple Dockerfile Image Container Dockerfile Dockerfile FROM: debian:jessie-backports apache:latest FROM: debian:jessie FROM: scratch
  • 16. Docker Compose Docker Compose is a tool within Docker that lets you define and run multi-container applications. Applications are defined inside a file called docker- compose.yml. The containers inside an application are called services.
  • 19. Learning More Check out the two Docker for Development series on Servers for Hackers https://serversforhackers.com/t/containers
  • 20. Dash
  • 22. What is Dash Dash is an approach to using Docker and an accompanying shell script, originally written by IFTTT.
  • 23. What is Dash Nginx Proxy MySQL DNSMasq Your Application MailHog Dash Apache PHP-FPM Another Application Nginx PHP-FPM PHPMyAdmin
  • 25. Nginx Proxy? DNSMasq? Oh my! Your Application Apache PHP-FPM Another Application Nginx PHP-FPM Docker Machine Your Local Machine Port 80 Port 443 Port 3306
  • 26. Nginx Proxy? DNSMasq? Oh my! Nginx Proxy MySQL DNSMasq Your Application MailHog Dash Apache PHP-FPM Another Application Nginx PHP-FPM Docker Machine Your Local Machine Port 80 Port 443 Port 3306 PHPMyAdmin
  • 27. How do I set up this wizardry?
  • 28. Setting Up Dash 1. Install Docker (duh) 2. Clone the Dash repo: https://github.com/dreadfullyposh/dash 3. Add your Dash directory to your path
  • 29. Adding Dash to your Path 1. Open Terminal 2.cd ~ <enter> 3.nano .bash_profile <enter> 4. Add a line like this: PATH=$PATH:/path/to/dash <control-x> <y> <enter> 5. Exit Terminal 6.echo $PATH <enter> to confirm your the PATH variable has been updated.
  • 30. Adding Dash to your Path At this point you should be able to type dev <enter> in your terminal window and see a bunch of information display. jeremy@mac ~> dev Execute various commands within the developer environment Usage: dev [options] [COMMAND] [ARGS...]"
  • 31. Setting Up Dash 1. Install Docker (duh) 2. Clone the Dash repo: github.com/dreadfullyposh/dash 3. Add your Dash directory to your path 4. Create a Docker network for your Dash setup by running docker network create dash
  • 32. Setting Up Dash 1. Install Docker (duh) 2. Clone the Dash repo: github.com/dreadfullyposh/dash 3. Add your Dash directory to your path 4. Create a Docker network for your Dash setup by running docker network create dash 5. Configure your Mac to resolve *.test with DNSMasq
  • 33. Configure Resolver 1. Open Terminal 2.cd /etc <enter> 3.mkdir resolver <enter> 4.cd resolver <enter> 5.nano test <enter> 6. type nameserver 127.0.0.1 7. <control-x> <y> <enter> 8. Restart, in honor of our Windows friends
  • 34. Setting Up Dash 1. Install Docker (duh) 2. Clone the Dash repo: github.com/dreadfullyposh/dash 3. Add your Dash directory to your path 4. Create a Docker network for your Dash setup by running docker network create dash 5. Configure your Mac to resolve *.test with DNSMasq 6. Setup SSL
  • 35. Setup SSL 1. Open Terminal 2.cd /your/dash/directory/certs <enter> 3../generatecertificate.sh <enter> 4. Open Keychain Access 5. Drag the .crt file from the certs directory to the Keychain Access window. 6. Double click the certificate 7. Edit the Trust option to Always
  • 36. Start it Up Open Terminal dev dash up <enter> jeremy@mac ~> dev dash up Creating dash_dnsmasq_1 ... done Creating dash_mysql_1 ... done Creating dash_nginx_1 ... done Creating dash_phpmyadmin_1 ... done Creating dash_mailhog_1 ... done
  • 37. But.. what did that do? - Looking at dash.yml version: '3' services: # Nginx Proxy nginx: build: ./docker/nginx ports: - "80:80"
  • 38. Looking at dash.yml - "443:443" volumes: - /var/run/docker.sock:/tmp/docker.sock:ro - ./certs:/etc/nginx/certs restart: always # DNSMasq Server dnsmasq:
  • 39. Looking at dash.yml image: andyshinn/dnsmasq ports: - "127.0.0.1:53:53/tcp" - "127.0.0.1:53:53/udp" cap_add: - NET_ADMIN command: --address=/test/127.0.0.1
  • 40. Looking at dash.yml restart: always # MySQL mysql: image: mysql:5.6 environment: - MYSQL_ROOT_PASSWORD=root
  • 41. Looking at dash.yml volumes: - ./data/mysql:/var/lib/mysql:rw ports: - "3306:3306" restart: always # MailHog mailhog:
  • 42. Looking at dash.yml image: mailhog/mailhog ports: - "1025:1025" expose: - 8025 restart: always
  • 43. Looking at dash.yml depends_on: - nginx environment: VIRTUAL_HOST: mailhog.dev.test VIRTUAL_PORT: 8025 # PHPMyAdmin phpmyadmin: image: phpmyadmin/phpmyadmin
  • 44. Looking at dash.yml expose: - 80 restart: always depends_on: - nginx - mysql environment: VIRTUAL_HOST: phpmyadmin.dev.test PMA_HOST: mysql PMA_USER: root PMA_PASSWORD: root
  • 45. Looking at dash.yml # Configure the Docker network to use networks: default: external: name: dash
  • 46. Setting up a Project
  • 47. Setting Up a Project 1. Copy example/docker-compose.yml to your project directory.
  • 48. Setting Up a Project 1. Copy example/docker-compose.yml to your project directory. 2. Configure docker-compose.yml
  • 49. Configure docker-compose.yml version: '3' services: web: image: webdevops/php-apache:latest ports: - 80 environment: WEB_DOCUMENT_ROOT: /app/public VIRTUAL_HOST: projectname.dev.test HTTPS_METHOD: redirect volumes:
  • 50. Configure docker-compose.yml version: '3' services: web: image: webdevops/php-apache:latest ports: - 80 environment: WEB_DOCUMENT_ROOT: /app/public VIRTUAL_HOST: projectname.dev.test HTTPS_METHOD: redirect volumes:
  • 51. Configure docker-compose.yml version: '3' services: web: image: webdevops/php-apache:latest ports: - 80 environment: WEB_DOCUMENT_ROOT: /app/public VIRTUAL_HOST: projectname.dev.test HTTPS_METHOD: redirect volumes:
  • 52. Configure docker-compose.yml version: '3' services: web: image: webdevops/php-apache:latest ports: - 80 environment: WEB_DOCUMENT_ROOT: /app/public VIRTUAL_HOST: projectname.dev.test HTTPS_METHOD: redirect volumes:
  • 53. Configure docker-compose.yml version: '3' services: web: image: webdevops/php-apache:latest ports: - 80 environment: WEB_DOCUMENT_ROOT: /app/public VIRTUAL_HOST: projectname.dev.test HTTPS_METHOD: redirect volumes:
  • 55. Setting Up a Project 1. Copy example/docker-compose.yml to your project directory. 2. Configure docker-compose.yml 3. Start project
  • 56. Start your Project 1. Open Terminal 2.cd /your/project/directory <enter> 3.dev up <enter> jeremy@mac ~> dev up dash_nginx_1 is up-to-date dash_dnsmasq_1 is up-to-date dash_mysql_1 is up-to-date dash_mailhog_1 is up-to-date dash_phpmyadmin_1 is up-to-date Starting projectdir_web_1 ... done
  • 57. Connecting to MySQL Since MySQL is in the Dash, you can’t just connect to it via localhost. From Web Container Host: mysql Username: root Password: root From Local Computer (Sequel Pro) Host: 127.0.0.1 Username: root Password: root
  • 58. Connecting to MailHog With MailHog running, we have a fake SMTP server running so we can monitor any messages sent from our application. From Application SMTP Server: mailhog Port: 1025 Access MailHog From Local Machine Host: https://mailhog.dev.test
  • 59. Connecting to PHPMyAdmin PHPMyAdmin is available in the Dash if you don’t want to use Sequel Pro. Access PHPMyAdmin From Local Machine Host: https://phpmyadmin.dev.test The username and password are already defined, so you should be logged in automatically.
  • 61. Gotchas ● Make sure you aren’t running MAMP or some other servers on the same ports: 80, 443, 53 and 3306. ● Make sure you dev down your projects when you’re not using them. The more containers you run, the more of your computer’s resources will be tied up running Docker.
  • 62. Other Useful Tips To shut down a project: dev down To shut down the Dash: dev dash down Make sure to download and install Kitematic, available from the Docker menubar icon. To run a command inside a container in your project: dev exec servicename somecommand
  • 63. Where to Go From Here Now that you’ve got a base setup running, you can extend it by adding more containers. Here are some ideas.
  • 64. Where to Go From Here Need to install Node dependencies? Add a node container. Then run dev run node yarn install node: image: node:8 volumes: - .:/opt working_dir: /opt
  • 65. Where to Go From Here Need to share your development environment with others? Install an ngrok container. ngroktunnel: image: gtriggiano/ngrok-tunnel:development ports: - "4040" environment: NGROK_REGION: us TARGET_HOST: web TARGET_PORT: 80 VIRTUAL_HOST: appname-ngrok.dev.vmg depends_on: - web
  • 66.
  • 67. Wait.. what were those links again? Servers for Hackers Containers Courses https://serversforhackers.com/t/containers Dash Repo on Github https://github.com/dreadfullyposh/dash WebDevOps Docker Images https://hub.docker.com/r/webdevops/ Also, please leave speaker feedback https://eeconf.com/speaker-feedback

Editor's Notes

  1. Hi, I’m Jeremy. And here’s my obligatory who am i slide <click> I’m Not husband <click> Not a father. Sorry borrowed this template from every other tech conference speaker. <click> I live and work in Philadelphia. <click> I’m a bit of an EE veteran, though I consider myself an equal opportunity developer. I’ve been using EE since 2010. <click> I was also briefly known as the mojoaddons guy *laugh track* <click> I’m the Web Services Manager at Vector Media Group in New York.
  2. Before we get into talking about Docker, let’s look at what I call the development environment progression. This is the path I took to finally arrive at docker, and i’m sure many of you can commiserate
  3. I think we all start the same way. Editing live on the server with FTP. The Do it Live™ approach is pretty typical for a person just dipping their toes into development for the first time. It’s scary, dangerous.. Generally awful. If this is your approach to web development, please stop.
  4. Eventually we get frustrated with doing it live. Or we have a colossal disaster that forces us to change our ways. So we look for ways to develop locally. I stumbled on MAMP pretty early on, but others just install server software locally. Either way it’s pretty much the same effect. It works pretty well. It leads its way into better development practices like version control, deployment processes, etc. But then you need some random PHP module. Anyone installed ionCube? Yeah, it’s fun. Or you have a client that’s running nginx, or a different PHP version on their server and something doesn’t work right there “but it works for me.” Or you upgrade OS X. Womp. Womp.
  5. You can only have your local development environment implode on you so many times before you start thinking “there’s got to be a better way to do this.” You might have started building your own Vagrant box, or you might have used someone else’s like Laravel Homestead or Scotchbox. Now you’re cooking. You have a virtual machine based development environment that is portable and repeatable. But...
  6. … your development environment still doesn’t match your production servers. And your hard drive is 97.3% full. And if you want to swap out just one thing, like a PHP version then you’re in for quite a ride. Now what?
  7. That’s how I got to Docker. The promised land.
  8. So before we get into the specifics here, let’s talk about what exactly IS Docker? Docker is virtual computing platform. <click> The big idea behind it is containerization <click> Creates a virtual host machine on your physical computer <click> Application-specific containers run your web server stack. The containers are lighter weight than a full virtual machine since they don’t run a full OS on their own.
  9. All that sounds good, but if you’ve taken a look at Docker before you start to see all these terms. <click> There are a lot of them If you’re like me, you got bogged down with all of these different terms, what they mean and how they related to each other.
  10. But it’s ok, we’ll get through this. We have to. Or else we’ll never make it to the after party...
  11. How does Docker work? Let's go through the basics.
  12. The key thing you need to understand is that Docker works in layers. <click> Dockerfiles are the the base layer. A dockerfile is a set of instructions to build an image. <click> An image is built from a Dockerfile and is package that contains everything needed to run a container. <click> A container is a running instance of an image.
  13. But it’s not quite that simple. <click> Dockerfiles can actually be built on top of other Dockerfiles. <click> So for example the official Dockerfile for Apache is based on a debian Dockerfile, which is based on another debian Dockerfile, which is based on Scratch (Docker’s base empty image). The layers can be endless.
  14. Next let’s look at docker compose. Docker compose is a tool that lets you define multi-container applications.
  15. These applications get defined in a docker-compose.yml file, which configures all the settings needed to run one or more containers that make up your application. Important terminology sidenote: The containers defined in the application’s docker compose file are called services.
  16. Here’s a sample application that you might define with docker compose. You can see it has three containers. One for Apache, one for PHP-FPM and one for Redis. An application could have more or less containers depending on what you need. We’ll look at how you actually define the application a bit later.
  17. If you’re serious about docker, I’d suggest reading through some tutorials to continue to expand your knowledge on the core concepts. The approach I’m about to show you is fairly self contained and automated, so it’ll shield you from having to know a lot of the details of dealing with Docker containers, but it’s really helpful background to have, especially as you start using the tool and want to expand your usage of it.
  18. I definitely recommend checking out Servers for Hackers if you haven’t already. They have two series available about Docker for Development. I’ll put this link up again later if you don’t catch it now
  19. Now for the fun part. Now that we have some docker basics under our belt, I’d like to unveil to you my docker-based local development environment Dash
  20. However before I do that, two brief disclaimers: Dash is one way to use Docker for development. It’s certainly not the only way. But I feel like it’s a good approach for someone just coming from MAMP or a Vagrant box and wanting to make as simple a move as possible to Docker. Please don’t come at me if this isn’t how you’d do it. I haven’t tested this outside of a Mac. I’m sure the core of it will work fine, but some of the finer details will need to be worked out on each operating system to make it work as smoothly as it does in OSX. Feel free to contribute to the repository!
  21. That aside let’s go on. Dash is an approach to using Docker and an accompanying shell script, that was originally written by IFTTT
  22. It creates a “dash”, which is a persistent stack of services used across all of your projects <click> and then you have project-specific services that you configure for each project you work on <click> The dash shell script is really just wrapper for docker-compose which you install globally. And it allows you to control both the dash and your projects with the same script without having to change directories all the time in your terminal So you can see the dash here on the left and then your applications over here on the right.
  23. As you take that in, I’m sure you’re looking at the containers in the dash and feeling a little concerned. Nginx proxy? DNSMasq? What on earth are they for? Let’s look at that a little closer
  24. As I mentioned, my first efforts to use Docker for local dev failed. This happened because I wasn’t able to get my head around how to run multiple projects in parallel. As we talked about earlier, all of your containers run inside the Docker machine. But only the machine has network access directly to your computer. You can quickly see the problem is that you can only map a port to one container at a time. This doesn’t work so well when you have multiple applications running and needing to be accessed from the browser. Does anyone here have the luxury of working on just one project at a time?.. Didn’t think so.
  25. Dash solves this by adding the nginx proxy into the mix. The proxy will look at the hostname of the incoming request and send it to the appropriate container. So now we can run as many sites as we want and our dash will keep traffic moving to the right place based on the hostname. It sounds complicated. But luckily someone else figured out how to do all of that automatically and packaged it up in a Docker container, so all we have to do is run it. To make things even easier, we use DNSMasq in the Dash so that we don’t even have to edit the hosts file for all of these project hostname.
  26. Are you excited yet? I’ll warn you now, there are quite a few steps in setting up dash, but it’s not hard per se. I’m going to run through this very quickly in the interest of time, but every step needed to get started is documented in these slides, which I’ll make available. So you can follow along with this at your own pace again later.
  27. Let’s get started. Obviously you need Docker installed. Then clone this repo. (Link will be shown again later) Then you need to add the Dash directory to your path.
  28. Won’t go through all the details here, but it’s pretty easy to follow. Again, slides will be available later to help with this.
  29. skip
  30. Now we create a Docker network. Sounds complicated. It isn’t. Just type to command and hit enter. That’s about it. This setups a network inside your docker machine that lets all of our containers talk to each other.
  31. Next we need to make our Mac resolve all .test domains with the DNSMasq server in our Dash. This is one of the more magical bits of Dash, because as long as you’re using a hostname on the top level domain you’ve mapped, it will always already point to Dash.
  32. This is fairly straightforward it just takes a few steps. I won’t go through them all now. Don’t forget to restart by the way.
  33. The last thing is setting up SSL. This is optional, but it’s easy enough. One thing to note here is that you can only create a wildcard certificate for a second level domain. So we’ll be securing dev.test. This means every project will need to have the hostname set to something.dev.test to work with the certificate. It looks a little stupid, but it saves us from having to manually generate certificates for each project. Which will save you 10s of seconds in the long run.
  34. Again it’s some pretty straightforward steps. I’ve included a script in the Dash repo which will generate the certificates for you easily, you just need to run it.
  35. Starting Dash is simple. Just run dev dash up. <click> And very untriumphantly, your dash will start. In the background, your nginx-proxy, MySQL database, DNSMasq, mailhog and phpmyadmin are now running on in your docker machine.
  36. So that’s all fine and dandy, but what did it actually do? Let’s take a quick look at dash.yml, which is the docker-compose file for Dash. This is all preconfigured for you in the repo, so if this doesn’t make any sense, you don’t need to worry about it. This looks just like the docker-compose file we looked at earlier. The first service is the nginx proxy. It’s building from a dockerfile. And it exposes port 80
  37. And port 443 It maps the docker socket from the local machine to the nginx container. Which is the magical part of how nginx proxy works And it maps the certificates directory. Then we move on to dnsmasq
  38. It exposes port 53
  39. The command there tells it what domain to respond to. Then we move to the mysql service container.
  40. The important part of the mysql container is this volume mapping, which makes sure our databases are persistent. Without this, the database server would be wiped clean each time we rebuild the container. Port 3306 is exposed so we can connect to the database from our local machine
  41. Then next is mailhog, a utility that makes a mock smtp server for testing It maps one port to our host machine and exposes a port internally
  42. We make sure it depends on the nginx proxy. Adding this dependency will ensure that the nginx proxy starts first. And then we set a hostname and tell nginx proxy we want it to proxy port 8025, which this image uses by default The last service is PHPMyAdmin
  43. Again we expose port 80 internally And then make sure it depends on nginx proxy and mysql Then we set a hostname and pass in the environment variables for the host, user and password
  44. Last we tell dash to use the dash network. Having the network is key to making sure that our Dash and our project containers can all talk to each other. Because this is just a standard docker-compose file, you can add any other services you want, keeping in mind that the same core service containers will be shared across your projects.
  45. With Dash running, we’re ready to setup a project. Create a directory for your project. Or select an existing site directory.
  46. With Dash running, we’re ready to setup a project. Create a directory for your project. Or select an existing site directory. Copy the example docker compose file from the example directory in your dash repo. Open up the copied docker compose file and configure it for your project. Let’s take a look at that.
  47. The example docker-compose has just about everything you need.
  48. I have it configured with a php and apache image. You can look at the other images from webdevops for other stacks. They tend to be very nice images that are super easy to configure right from the docker compose file.
  49. Set the document root /app is an arbitrary directory where this image points Apache by default. We’re just moving that one level deeper to /app/public so we can have our repo above the document root. This can be renamed or adjusted as needed based on your own directory structure
  50. The virtual host entered here is what the nginx-proxy container uses to route traffic to this container. This is a special environment variable that nginx-proxy is configured to look at to automate the configuration of the proxy.
  51. The https method forces all traffic to be redirected to run over https. You can adjust this option if you need to support http only or both.
  52. Last is our volumes. This is where we map the current directory, usually the root of your site repository, to the app directory on the container. Last we have the network, which just makes sure this container runs on the same docker network as our Dash
  53. That’s pretty much it. Of course you can get a lot more complicated. The webdevops images are well documented with all of their environment variable options for adjusting Apache and PHP configuration. And you can add any other application-specific services you need into the docker compose file.
  54. So now we can fire it up. If the dash services aren’t already running, they’ll start. Otherwise they’ll show as already up to date. Then it starts the project’s containers. Done.
  55. Obviously as CMS developers, it’s important for us to be able to connect to the mysql database. From your web server container, you use the mysql host name (which is the name of the service in your dash). From your local computer, if you’re connecting with Sequel Pro or something like that, the mysql port is mapped so you can connect to it directly with 127.0.0.1
  56. Sending out email from applications is also a common use case. MailHog helps with this by creating a fake SMTP server we can send mail through and then access the messages through a web browser. It’s pretty simple to configure an application to send through mailhog. And to access the control panel through the browser.
  57. I’ve also included PHPMyadmin in the dash. Just visit the phpmyadmin url and you should be taken right in.
  58. That’s pretty much it for the basics. Obviously there’s a lot more to learn, but this should be enough to get you going. Once you start up your project, you should be able to access the virtual host url you chose from your browser.
  59. A couple gotchas: First make sure you don’t have mamp or any other server running on these ports. We have them mapped from the containers to the local machine, so they can’t be in use elsewhere. While you can successfully run multiple projects at once, be careful about how many containers you try to run at once.
  60. To shut down a project: dev down To shut down the Dash: dev dash down To view running containers and their output, use Kitematic, can be helpful for debugging. To run a command inside a container in your project: dev exec servicename somecommand
  61. That was the base setup, getting you up and running with a simple Apache/PHP server. But there are so many images out there that it’s easy to extend your setup just by adding them to your docker-compose file.
  62. You could use a node image to use a consistent node version across environments and run npm or yarn. The node container itself won’t stay running, and so you can easily run dev run with a command to use it at any time.
  63. You could also use an ngrok container to share your dev environment with others. Opening the virtual host you specify in the browser will bring up the ngrok control panel to reveal your public ngrok url
  64. Here are the links from earlier in my slides. Thanks for listening. Please remember to leave speaker feedback on the ee conference website