SlideShare a Scribd company logo
GETTING INSTANTLY UP AND RUNNING

WITH DOCKER AND SYMFONY
GETTING STARTED AND BEYOND WITH DOCKER AND SYMFONY
André Rømcke - VP Engineering @ezsystems
Symfony Live London, 16th of September 2016
www.ez.no
Warning
๏Won’t cover performance issues on Win/Mac in dev mode due to very slow FS
๏Pragmatic “fix” is to use Linux, or VM with files shared to host over nfs
๏Besides that there are third party solutions with own pitfalls, eg docker-sync
๏This is the first time I do this talk, so hold on tight
๏Including demo effect ;)
www.ez.no
Who?
๏André Rømcke | @andrerom
๏Norwegian, like being social, mountains, skiing, biking, running, technology
๏PHP for 11 years. From 96: Html, CSS, JS, VB, C#, PHP, Bash, Groovy, (Hack)
๏Contributed to Symfony, FOS, Composer, FIG, Docker, and attempting for PHP
๏VP Engineering at eZ Systems
๏eZ Systems AS | ez.no
๏Global, 70 people across 7 countries, partners & community in many many more
๏Maker of eZ Publish since 2001, 6th+ gen called eZ Studio (commercial) & eZ Platform
๏eZ Platform | ezplatform.com
๏Open source Content Management System, a super flexible Full and Headless CMS
๏Developed since 2011, on Symfony Full Stack since 2012 (v2.0)
www.ez.no
Getting started
basic example
The instant part, what we’ll cover:
1.Clone Symfony standard
2.Add Dockerfile for building our application container
3.Add docker-compose.yml to define our software services
4.[Optional] Add .dockerignore file to hint which files should be ignored
5.[Optional] Add .env variable for default variables
www.ez.nowww.ez.no
Getting started: #1 Clone Symfony standard
$ git clone https://github.com/symfony/symfony-standard.git
$ cd symfony-standard
# Or using composer	create-project, or using Symfony installer, ..
www.ez.nowww.ez.no
Getting started: #2 Add basic Dockerfile
$ vim Dockerfile
FROM php:7.0-apache

MAINTAINER André Rømcke "ar@ez.no"

ENV COMPOSER_HOME=/root/.composer SYMFONY_ENV=prod



COPY . /var/www/html



# … (install Composer, or skip the composer instal step below)



RUN composer install -o -n --no-progress --prefer-dist 

&& echo "Clear cache and logs so container starts clean" 

&& rm -Rf var/logs/* var/cache/*/* 

&& echo "Set perm for www-data, add data folder if you have" 

&& chown -R www-data:www-data var/cache var/logs var/sessions





EXPOSE 80

CMD ["apache2-foreground"]
www.ez.nowww.ez.no
Getting started: #3 Add basic docker-compose.yml
$ vim docker-compose.yml
version: '2'



services:

web:

build: .

image: my_web

ports: [ "8088:80" ]

environment:

- SYMFONY_ENV

- SYMFONY_DEBUG
www.ez.nowww.ez.no
Getting started: #4 Add basic .dockerignore
$ vim .dockerignore
# GIT files

.git/
# Cache, session files and logs (Symfony3)

var/cache/*

var/logs/*

var/sessions/*

!var/cache/.gitkeep

!var/logs/.gitkeep

!var/sessions/.gitkeep
www.ez.nowww.ez.no
Getting started: #5 Add default .env variables
Or having to hard code and duplicate defaults in your docker-compose.yml:
environment:

- SYMFONY_ENV=prod

- SYMFONY_DEBUG=0
Instead of having to always specify ENV variables on command line:
export SYMFONY_ENV=prod SYMFONY_DEBUG=0



docker-compose up -d
www.ez.nowww.ez.no
Getting started: #5 Add default .env variables
Instead we can set all default in one file:

$ vim .env
# Default env variables, see: https://docs.docker.com/compose/env-file/

#COMPOSE_FILE=docker-compose.yml



SYMFONY_ENV=prod

SYMFONY_DEBUG=0
Demo time
Up and running
git clone https://github.com/andrerom/symfony-live-london-2016-docker-demo.git sf_demo
cd sf_demo
git show

docker up -d
Conventions in official docker images
order in docker, in official images, and in php image
As the getting started example is way to simple, lets go over some things to know before we
make a more advance example.
We’ll cover:
1.Entrypoints
2.Data dirs
3.EVN variables & Symfony
4.Image Layers (and how it affects image size)
www.ez.nowww.ez.no
Convention: Entrypoint
Found in for instance official mysql/mariadb, postgres, solr images:
# https://github.com/docker-library/mariadb/blob/master/10.1/docker-entrypoint.sh
for f in /docker-entrypoint-initdb.d/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo
done
This lets you to pass in sql and/or shell scripts to enhance a
official image without having to extend it with own docker image:
db:

image: ${MYSQL_IMAGE}

volumes_from:

- db_vol:ro
www.ez.nowww.ez.no
Convention: Data dir
Found in for instance mysql/mariadb, postgres, elastic:
Same benefit as entrypoint usage with sql files, but more specifically
for mounting backup data for start up when starting a new environment.
VOLUME /var/lib/mysql
VOLUME /usr/share/elasticsearch/data
VOLUME /var/lib/postgresql/data
www.ez.nowww.ez.no
Convention: ENV variables with Symfony
As “SYMFONY__” ENV variables are broken, common solution is:
env/docker.php
imports:

- { resource: default_parameters.yml }

- { resource: parameters.yml }

- { resource: security.yml }

- { resource: env/docker.php}
<?php

// Executed on symfony container compilation





if ($value = getenv('SYMFONY_SECRET')) {

$container->setParameter('secret', $value);

}
www.ez.nowww.ez.no
Convention: ENV variables with Symfony
But this is hopefully not needed anymore, as of 3.2 we will have this:
www.ez.nowww.ez.no
Convention: Image Layers & image size
• Each instruction in Dockerfile will by default create a new layer
• Which means files added in one layer continues taking space in final image
• Which means you will have to do things like:
# Install and configure php plugins

RUN set -xe 

&& buildDeps=" 

$PHP_EXTRA_BUILD_DEPS 

libfreetype6-dev 

libjpeg62-turbo-dev libxpm-dev libpng12-dev libicu-dev libxslt1-dev 

&& apt-get update && apt-get install -y --force-yes $buildDeps --no-install-
recommends && rm -rf /var/lib/apt/lists/* 

# Extract php source and install missing extensions

&& docker-php-source extract 

&& (…)

# Delete source & builds deps so it does not hang around in layers taking up space

&& docker-php-source delete 

&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
$buildDeps
Advance use
extending, composing and using
Lets have a look at some actual code.
Sources:
- https://github.com/ezsystems/docker-php/blob/master/php/Dockerfile-7.0#L33
- https://github.com/ezsystems/ezplatform/tree/master/doc/docker-compose
Fin
the end, but hopefully just the beginning
For more on eZ Platform see ezplatform.com

More Related Content

What's hot

Scaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and ChefScaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
bridgetkromhout
 
Docker perl build
Docker perl buildDocker perl build
Docker perl build
Workhorse Computing
 
Docker up and running
Docker up and runningDocker up and running
Docker up and running
Victor S. Recio
 
Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)
Žilvinas Kuusas
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
Larry Cai
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the Cloud
Salesforce Developers
 
Infrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & AnsibleInfrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & Ansible
Robert Reiz
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90mins
Larry Cai
 
Web scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannelWeb scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannel
purpleocean
 
Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by Docker
Terry Chen
 
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/20146 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
Christian Beedgen
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
raccoony
 
Docker 原理與實作
Docker 原理與實作Docker 原理與實作
Docker 原理與實作
kao kuo-tung
 
Logging & Metrics with Docker
Logging & Metrics with DockerLogging & Metrics with Docker
Logging & Metrics with Docker
Stefan Zier
 
Lessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containersLessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containers
Ben Hall
 
Lessons from running potentially malicious code inside Docker containers
Lessons from running potentially malicious code inside Docker containersLessons from running potentially malicious code inside Docker containers
Lessons from running potentially malicious code inside Docker containers
Ben Hall
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPress
dotCloud
 
CoreOS : 설치부터 컨테이너 배포까지
CoreOS : 설치부터 컨테이너 배포까지CoreOS : 설치부터 컨테이너 배포까지
CoreOS : 설치부터 컨테이너 배포까지
충섭 김
 
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command lineInstalling and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command line
dotCloud
 
CoreOSによるDockerコンテナのクラスタリング
CoreOSによるDockerコンテナのクラスタリングCoreOSによるDockerコンテナのクラスタリング
CoreOSによるDockerコンテナのクラスタリング
Yuji ODA
 

What's hot (20)

Scaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and ChefScaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
Scaling Next-Generation Internet TV on AWS With Docker, Packer, and Chef
 
Docker perl build
Docker perl buildDocker perl build
Docker perl build
 
Docker up and running
Docker up and runningDocker up and running
Docker up and running
 
Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the Cloud
 
Infrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & AnsibleInfrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & Ansible
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90mins
 
Web scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannelWeb scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannel
 
Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by Docker
 
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/20146 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 
Docker 原理與實作
Docker 原理與實作Docker 原理與實作
Docker 原理與實作
 
Logging & Metrics with Docker
Logging & Metrics with DockerLogging & Metrics with Docker
Logging & Metrics with Docker
 
Lessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containersLessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containers
 
Lessons from running potentially malicious code inside Docker containers
Lessons from running potentially malicious code inside Docker containersLessons from running potentially malicious code inside Docker containers
Lessons from running potentially malicious code inside Docker containers
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPress
 
CoreOS : 설치부터 컨테이너 배포까지
CoreOS : 설치부터 컨테이너 배포까지CoreOS : 설치부터 컨테이너 배포까지
CoreOS : 설치부터 컨테이너 배포까지
 
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command lineInstalling and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command line
 
CoreOSによるDockerコンテナのクラスタリング
CoreOSによるDockerコンテナのクラスタリングCoreOSによるDockerコンテナのクラスタリング
CoreOSによるDockerコンテナのクラスタリング
 

Viewers also liked

PHP Benelux 2017 - Caching The Right Way
PHP Benelux 2017 -  Caching The Right WayPHP Benelux 2017 -  Caching The Right Way
PHP Benelux 2017 - Caching The Right Way
André Rømcke
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP Generators
Mark Baker
 
Create, test, secure, repeat
Create, test, secure, repeatCreate, test, secure, repeat
Create, test, secure, repeat
Michelangelo van Dam
 
Amp your site an intro to accelerated mobile pages
Amp your site  an intro to accelerated mobile pagesAmp your site  an intro to accelerated mobile pages
Amp your site an intro to accelerated mobile pages
Robert McFrazier
 
php[world] 2015 Training - Laravel from the Ground Up
php[world] 2015 Training - Laravel from the Ground Upphp[world] 2015 Training - Laravel from the Ground Up
php[world] 2015 Training - Laravel from the Ground Up
Joe Ferguson
 
Hack the Future
Hack the FutureHack the Future
Hack the Future
Jason McCreary
 
Zend Framework Foundations
Zend Framework FoundationsZend Framework Foundations
Zend Framework Foundations
Chuck Reeves
 
Engineer - Mastering the Art of Software
Engineer - Mastering the Art of SoftwareEngineer - Mastering the Art of Software
Engineer - Mastering the Art of Software
Cristiano Diniz da Silva
 
Adding 1.21 Gigawatts to Applications with RabbitMQ (Bulgaria PHP 2016 - Tuto...
Adding 1.21 Gigawatts to Applications with RabbitMQ (Bulgaria PHP 2016 - Tuto...Adding 1.21 Gigawatts to Applications with RabbitMQ (Bulgaria PHP 2016 - Tuto...
Adding 1.21 Gigawatts to Applications with RabbitMQ (Bulgaria PHP 2016 - Tuto...
James Titcumb
 
Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win
Joe Ferguson
 
Git Empowered
Git EmpoweredGit Empowered
Git Empowered
Jason McCreary
 
Dip Your Toes in the Sea of Security
Dip Your Toes in the Sea of SecurityDip Your Toes in the Sea of Security
Dip Your Toes in the Sea of Security
James Titcumb
 
Code Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsCode Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application Migrations
Dana Luther
 
Presentation Bulgaria PHP
Presentation Bulgaria PHPPresentation Bulgaria PHP
Presentation Bulgaria PHP
Alena Holligan
 
Php extensions
Php extensionsPhp extensions
Php extensions
Elizabeth Smith
 
Conscious Coupling
Conscious CouplingConscious Coupling
Conscious Coupling
CiaranMcNulty
 
SunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQLSunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQL
Gabriela Ferrara
 
Modern sql
Modern sqlModern sql
Modern sql
Elizabeth Smith
 
PHP World DC 2015 - What Can Go Wrong with Agile Development and How to Fix It
PHP World DC 2015 - What Can Go Wrong with Agile Development and How to Fix ItPHP World DC 2015 - What Can Go Wrong with Agile Development and How to Fix It
PHP World DC 2015 - What Can Go Wrong with Agile Development and How to Fix It
Matt Toigo
 
Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHP
David Stockton
 

Viewers also liked (20)

PHP Benelux 2017 - Caching The Right Way
PHP Benelux 2017 -  Caching The Right WayPHP Benelux 2017 -  Caching The Right Way
PHP Benelux 2017 - Caching The Right Way
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP Generators
 
Create, test, secure, repeat
Create, test, secure, repeatCreate, test, secure, repeat
Create, test, secure, repeat
 
Amp your site an intro to accelerated mobile pages
Amp your site  an intro to accelerated mobile pagesAmp your site  an intro to accelerated mobile pages
Amp your site an intro to accelerated mobile pages
 
php[world] 2015 Training - Laravel from the Ground Up
php[world] 2015 Training - Laravel from the Ground Upphp[world] 2015 Training - Laravel from the Ground Up
php[world] 2015 Training - Laravel from the Ground Up
 
Hack the Future
Hack the FutureHack the Future
Hack the Future
 
Zend Framework Foundations
Zend Framework FoundationsZend Framework Foundations
Zend Framework Foundations
 
Engineer - Mastering the Art of Software
Engineer - Mastering the Art of SoftwareEngineer - Mastering the Art of Software
Engineer - Mastering the Art of Software
 
Adding 1.21 Gigawatts to Applications with RabbitMQ (Bulgaria PHP 2016 - Tuto...
Adding 1.21 Gigawatts to Applications with RabbitMQ (Bulgaria PHP 2016 - Tuto...Adding 1.21 Gigawatts to Applications with RabbitMQ (Bulgaria PHP 2016 - Tuto...
Adding 1.21 Gigawatts to Applications with RabbitMQ (Bulgaria PHP 2016 - Tuto...
 
Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win
 
Git Empowered
Git EmpoweredGit Empowered
Git Empowered
 
Dip Your Toes in the Sea of Security
Dip Your Toes in the Sea of SecurityDip Your Toes in the Sea of Security
Dip Your Toes in the Sea of Security
 
Code Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsCode Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application Migrations
 
Presentation Bulgaria PHP
Presentation Bulgaria PHPPresentation Bulgaria PHP
Presentation Bulgaria PHP
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
Conscious Coupling
Conscious CouplingConscious Coupling
Conscious Coupling
 
SunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQLSunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQL
 
Modern sql
Modern sqlModern sql
Modern sql
 
PHP World DC 2015 - What Can Go Wrong with Agile Development and How to Fix It
PHP World DC 2015 - What Can Go Wrong with Agile Development and How to Fix ItPHP World DC 2015 - What Can Go Wrong with Agile Development and How to Fix It
PHP World DC 2015 - What Can Go Wrong with Agile Development and How to Fix It
 
Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHP
 

Similar to Getting instantly up and running with Docker and Symfony

Agile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: IntroductionAgile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Partner S.A.
 
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
Ben Hall
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
Docker, Inc.
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
Bo-Yi Wu
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
andymccurdy
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
Christophe Muller
 
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneruJak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru
Vašek Boch
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvars
Sam Marley-Jarrett
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
양재동 코드랩
 
How to create your own hack environment
How to create your own hack environmentHow to create your own hack environment
How to create your own hack environment
Sumedt Jitpukdebodin
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peek
msyukor
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
Ben Hall
 
Docker 101
Docker 101 Docker 101
Docker 101
Kevin Nord
 
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)
Ben Hall
 
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
Willian Molinari
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
adrian_nye
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
Alexandre Salomé
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
biicode
 
Be a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeBe a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the trade
Nicola Paolucci
 
Pluralsight Webinar: Simplify Your Project Builds with Docker
Pluralsight Webinar: Simplify Your Project Builds with DockerPluralsight Webinar: Simplify Your Project Builds with Docker
Pluralsight Webinar: Simplify Your Project Builds with Docker
Elton Stoneman
 

Similar to Getting instantly up and running with Docker and Symfony (20)

Agile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: IntroductionAgile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: Introduction
 
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
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneruJak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvars
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
 
How to create your own hack environment
How to create your own hack environmentHow to create your own hack environment
How to create your own hack environment
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peek
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
 
Docker 101
Docker 101 Docker 101
Docker 101
 
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)
 
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Be a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeBe a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the trade
 
Pluralsight Webinar: Simplify Your Project Builds with Docker
Pluralsight Webinar: Simplify Your Project Builds with DockerPluralsight Webinar: Simplify Your Project Builds with Docker
Pluralsight Webinar: Simplify Your Project Builds with Docker
 

More from André Rømcke

SymfonyCon 2019: Head first into Symfony Cache, Redis & Redis Cluster
SymfonyCon 2019:   Head first into Symfony Cache, Redis & Redis ClusterSymfonyCon 2019:   Head first into Symfony Cache, Redis & Redis Cluster
SymfonyCon 2019: Head first into Symfony Cache, Redis & Redis Cluster
André Rømcke
 
SfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
SfDay 2019: Head first into Symfony Cache, Redis & Redis ClusterSfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
SfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
André Rømcke
 
Symfony live London 2018 - Take your http caching to the next level with xke...
Symfony live London 2018 -  Take your http caching to the next level with xke...Symfony live London 2018 -  Take your http caching to the next level with xke...
Symfony live London 2018 - Take your http caching to the next level with xke...
André Rømcke
 
Look Towards 2.0 and Beyond - eZ Conference 2016
Look Towards 2.0 and Beyond -   eZ Conference 2016Look Towards 2.0 and Beyond -   eZ Conference 2016
Look Towards 2.0 and Beyond - eZ Conference 2016
André Rømcke
 
PhpTour Lyon 2014 - Transparent caching & context aware http cache
PhpTour Lyon 2014 - Transparent caching & context aware http cachePhpTour Lyon 2014 - Transparent caching & context aware http cache
PhpTour Lyon 2014 - Transparent caching & context aware http cache
André Rømcke
 
eZ publish 5[-alpha1] Introduction & Architecture
eZ publish 5[-alpha1] Introduction & ArchitectureeZ publish 5[-alpha1] Introduction & Architecture
eZ publish 5[-alpha1] Introduction & Architecture
André Rømcke
 
eZ Publish 5, Re architecture, pitfalls and opportunities
eZ Publish 5, Re architecture, pitfalls and opportunitieseZ Publish 5, Re architecture, pitfalls and opportunities
eZ Publish 5, Re architecture, pitfalls and opportunities
André Rømcke
 

More from André Rømcke (7)

SymfonyCon 2019: Head first into Symfony Cache, Redis & Redis Cluster
SymfonyCon 2019:   Head first into Symfony Cache, Redis & Redis ClusterSymfonyCon 2019:   Head first into Symfony Cache, Redis & Redis Cluster
SymfonyCon 2019: Head first into Symfony Cache, Redis & Redis Cluster
 
SfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
SfDay 2019: Head first into Symfony Cache, Redis & Redis ClusterSfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
SfDay 2019: Head first into Symfony Cache, Redis & Redis Cluster
 
Symfony live London 2018 - Take your http caching to the next level with xke...
Symfony live London 2018 -  Take your http caching to the next level with xke...Symfony live London 2018 -  Take your http caching to the next level with xke...
Symfony live London 2018 - Take your http caching to the next level with xke...
 
Look Towards 2.0 and Beyond - eZ Conference 2016
Look Towards 2.0 and Beyond -   eZ Conference 2016Look Towards 2.0 and Beyond -   eZ Conference 2016
Look Towards 2.0 and Beyond - eZ Conference 2016
 
PhpTour Lyon 2014 - Transparent caching & context aware http cache
PhpTour Lyon 2014 - Transparent caching & context aware http cachePhpTour Lyon 2014 - Transparent caching & context aware http cache
PhpTour Lyon 2014 - Transparent caching & context aware http cache
 
eZ publish 5[-alpha1] Introduction & Architecture
eZ publish 5[-alpha1] Introduction & ArchitectureeZ publish 5[-alpha1] Introduction & Architecture
eZ publish 5[-alpha1] Introduction & Architecture
 
eZ Publish 5, Re architecture, pitfalls and opportunities
eZ Publish 5, Re architecture, pitfalls and opportunitieseZ Publish 5, Re architecture, pitfalls and opportunities
eZ Publish 5, Re architecture, pitfalls and opportunities
 

Recently uploaded

Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
OnePlan Solutions
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery FleetStork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Vince Scalabrino
 
The Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdfThe Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdf
mohitd6
 
Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.
KrishnaveniMohan1
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
VictoriaMetrics
 
Boost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management AppsBoost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management Apps
Jhone kinadey
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
Pedro J. Molina
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Peter Caitens
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
Paul Brebner
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
ICS
 
42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert
vaishalijagtap12
 
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdfTheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
Ortus Solutions, Corp
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
kalichargn70th171
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
dhavalvaghelanectarb
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies
 

Recently uploaded (20)

Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery FleetStork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
 
The Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdfThe Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdf
 
Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.Penify - Let AI do the Documentation, you write the Code.
Penify - Let AI do the Documentation, you write the Code.
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
 
Boost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management AppsBoost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management Apps
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
 
42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert
 
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdfTheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
 
bgiolcb
bgiolcbbgiolcb
bgiolcb
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
 

Getting instantly up and running with Docker and Symfony

  • 1. GETTING INSTANTLY UP AND RUNNING
 WITH DOCKER AND SYMFONY GETTING STARTED AND BEYOND WITH DOCKER AND SYMFONY André Rømcke - VP Engineering @ezsystems Symfony Live London, 16th of September 2016
  • 2. www.ez.no Warning ๏Won’t cover performance issues on Win/Mac in dev mode due to very slow FS ๏Pragmatic “fix” is to use Linux, or VM with files shared to host over nfs ๏Besides that there are third party solutions with own pitfalls, eg docker-sync ๏This is the first time I do this talk, so hold on tight ๏Including demo effect ;)
  • 3. www.ez.no Who? ๏André Rømcke | @andrerom ๏Norwegian, like being social, mountains, skiing, biking, running, technology ๏PHP for 11 years. From 96: Html, CSS, JS, VB, C#, PHP, Bash, Groovy, (Hack) ๏Contributed to Symfony, FOS, Composer, FIG, Docker, and attempting for PHP ๏VP Engineering at eZ Systems ๏eZ Systems AS | ez.no ๏Global, 70 people across 7 countries, partners & community in many many more ๏Maker of eZ Publish since 2001, 6th+ gen called eZ Studio (commercial) & eZ Platform ๏eZ Platform | ezplatform.com ๏Open source Content Management System, a super flexible Full and Headless CMS ๏Developed since 2011, on Symfony Full Stack since 2012 (v2.0)
  • 4. www.ez.no Getting started basic example The instant part, what we’ll cover: 1.Clone Symfony standard 2.Add Dockerfile for building our application container 3.Add docker-compose.yml to define our software services 4.[Optional] Add .dockerignore file to hint which files should be ignored 5.[Optional] Add .env variable for default variables
  • 5. www.ez.nowww.ez.no Getting started: #1 Clone Symfony standard $ git clone https://github.com/symfony/symfony-standard.git $ cd symfony-standard # Or using composer create-project, or using Symfony installer, ..
  • 6. www.ez.nowww.ez.no Getting started: #2 Add basic Dockerfile $ vim Dockerfile FROM php:7.0-apache
 MAINTAINER André Rømcke "ar@ez.no"
 ENV COMPOSER_HOME=/root/.composer SYMFONY_ENV=prod
 
 COPY . /var/www/html
 
 # … (install Composer, or skip the composer instal step below)
 
 RUN composer install -o -n --no-progress --prefer-dist 
 && echo "Clear cache and logs so container starts clean" 
 && rm -Rf var/logs/* var/cache/*/* 
 && echo "Set perm for www-data, add data folder if you have" 
 && chown -R www-data:www-data var/cache var/logs var/sessions
 
 
 EXPOSE 80
 CMD ["apache2-foreground"]
  • 7. www.ez.nowww.ez.no Getting started: #3 Add basic docker-compose.yml $ vim docker-compose.yml version: '2'
 
 services:
 web:
 build: .
 image: my_web
 ports: [ "8088:80" ]
 environment:
 - SYMFONY_ENV
 - SYMFONY_DEBUG
  • 8. www.ez.nowww.ez.no Getting started: #4 Add basic .dockerignore $ vim .dockerignore # GIT files
 .git/ # Cache, session files and logs (Symfony3)
 var/cache/*
 var/logs/*
 var/sessions/*
 !var/cache/.gitkeep
 !var/logs/.gitkeep
 !var/sessions/.gitkeep
  • 9. www.ez.nowww.ez.no Getting started: #5 Add default .env variables Or having to hard code and duplicate defaults in your docker-compose.yml: environment:
 - SYMFONY_ENV=prod
 - SYMFONY_DEBUG=0 Instead of having to always specify ENV variables on command line: export SYMFONY_ENV=prod SYMFONY_DEBUG=0
 
 docker-compose up -d
  • 10. www.ez.nowww.ez.no Getting started: #5 Add default .env variables Instead we can set all default in one file:
 $ vim .env # Default env variables, see: https://docs.docker.com/compose/env-file/
 #COMPOSE_FILE=docker-compose.yml
 
 SYMFONY_ENV=prod
 SYMFONY_DEBUG=0
  • 11. Demo time Up and running git clone https://github.com/andrerom/symfony-live-london-2016-docker-demo.git sf_demo cd sf_demo git show
 docker up -d
  • 12. Conventions in official docker images order in docker, in official images, and in php image As the getting started example is way to simple, lets go over some things to know before we make a more advance example. We’ll cover: 1.Entrypoints 2.Data dirs 3.EVN variables & Symfony 4.Image Layers (and how it affects image size)
  • 13. www.ez.nowww.ez.no Convention: Entrypoint Found in for instance official mysql/mariadb, postgres, solr images: # https://github.com/docker-library/mariadb/blob/master/10.1/docker-entrypoint.sh for f in /docker-entrypoint-initdb.d/*; do case "$f" in *.sh) echo "$0: running $f"; . "$f" ;; *.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; esac echo done This lets you to pass in sql and/or shell scripts to enhance a official image without having to extend it with own docker image: db:
 image: ${MYSQL_IMAGE}
 volumes_from:
 - db_vol:ro
  • 14. www.ez.nowww.ez.no Convention: Data dir Found in for instance mysql/mariadb, postgres, elastic: Same benefit as entrypoint usage with sql files, but more specifically for mounting backup data for start up when starting a new environment. VOLUME /var/lib/mysql VOLUME /usr/share/elasticsearch/data VOLUME /var/lib/postgresql/data
  • 15. www.ez.nowww.ez.no Convention: ENV variables with Symfony As “SYMFONY__” ENV variables are broken, common solution is: env/docker.php imports:
 - { resource: default_parameters.yml }
 - { resource: parameters.yml }
 - { resource: security.yml }
 - { resource: env/docker.php} <?php
 // Executed on symfony container compilation
 
 
 if ($value = getenv('SYMFONY_SECRET')) {
 $container->setParameter('secret', $value);
 }
  • 16. www.ez.nowww.ez.no Convention: ENV variables with Symfony But this is hopefully not needed anymore, as of 3.2 we will have this:
  • 17. www.ez.nowww.ez.no Convention: Image Layers & image size • Each instruction in Dockerfile will by default create a new layer • Which means files added in one layer continues taking space in final image • Which means you will have to do things like: # Install and configure php plugins
 RUN set -xe 
 && buildDeps=" 
 $PHP_EXTRA_BUILD_DEPS 
 libfreetype6-dev 
 libjpeg62-turbo-dev libxpm-dev libpng12-dev libicu-dev libxslt1-dev 
 && apt-get update && apt-get install -y --force-yes $buildDeps --no-install- recommends && rm -rf /var/lib/apt/lists/* 
 # Extract php source and install missing extensions
 && docker-php-source extract 
 && (…)
 # Delete source & builds deps so it does not hang around in layers taking up space
 && docker-php-source delete 
 && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps
  • 18. Advance use extending, composing and using Lets have a look at some actual code. Sources: - https://github.com/ezsystems/docker-php/blob/master/php/Dockerfile-7.0#L33 - https://github.com/ezsystems/ezplatform/tree/master/doc/docker-compose
  • 19. Fin the end, but hopefully just the beginning For more on eZ Platform see ezplatform.com