SlideShare a Scribd company logo
1 of 18
Download to read offline
Jak se ^bonami.(cz|pl|sk)$ vešlo
do kontejneru
Václav Boch, Bonami.cz
31.3.2016
What you can use for deployment?
• FTP
• SFTP/SSHFS
• GIT
• Bash
• Capistrano
• RPM
• Docker
Docker
• Docker is shipping container for your application.
• Contains everything that your app needs.
Virtualization vs. Docker
App
A
Hypervisor
HostOS
Server
Guest
OS
Bins/
Libs
VM
App
C
Guest
OS
Bins/
Libs
App
B
Guest
OS
Bins/
Libs
AppA’
Docker
HostOS
Server
Bins/Libs
AppA
Bins/Libs
AppB
AppB’
AppB’
AppB’
Container
Image
• Layers
• Read Only
• Running image is container
Base Image (Ubuntu / Alpine)
Apps PHP, extensions, vim,
runtime configuration
Your configuration +
ceritificates
Your codeRead only
Cache warm up
Container
• Running image
• The last layer of image
• Only layer that is writable
Base Image (Ubuntu / Alpine)
Apps PHP, extensions, vim,
runtime configuration
Your configuration +
ceritificates
Your code
Running container (tmp files)
Read only
Writable
Cache warm up
Production & test Image
Base Image (Ubuntu / Alpine)
Apps PHP, extensions, vim,
runtime configuration
Your prod configuration +
ceritificates
Your code
Bonami Base
Cache warm up
Your test configuration +
ceritificates
Test tools (PHPUnit)
Cache warm up
Production image
Test image
Source
Code
repo
Docker
Registry
How does it work?
Dockerfile
For
Core,
Test, Prod
Docker Engine
Push
Docker
Production server + Docker
Push
Search
Pull
Run
HostCI server
ContainerA
ContainerB
ContainerC
BaseImage
Local DEV machine CI server Production
Test Image
Prod Image
Search
Pull & Run
Docker
Test server + Docker
ContainerA
ContainerB
ContainerC
Build
Bonami Base – Dockerfile
FROM registry.bonami.cz/bonami/fedora
ENV TERM xterm
RUN dnf install -y 
php-fpm php-cli php-curl php-intl php-mysql php-mcrypt php-gd php-redis php-igbinary 
php-pecl-http php-pecl-imagick php-bcmath vim sudo php-mbstring php-xml php-soap php-pdo 
php-mysqlnd php-opcache php-twig redis php-pecl-apcu msmtp nginx tar && 
curl -SLO "https://nodejs.org/dist/v0.12.7/node-v0.12.7-linux-x64.tar.gz" && 
tar -xzf "node-v0.12.7-linux-x64.tar.gz" -C /usr/local --strip-components=1 && 
rm -f /node-v0.12.7-linux-x64.tar.gz && 
mkdir -p /var/www/bonami-web && 
echo "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" >> /etc/environment && 
dnf clean all && 
rm -rf /var/cache/dnf && 
rm -rf /var/log/dnf && 
sed -i -e "s/([;]*)(upload_max_filesize[ t]*=)(.*)$/2 16M /g" /etc/php.ini && 
sed -i -e "s/([;]*)(date.timezone[ t]*=)(.*)$/2 "Europe/Prague" /g" /etc/php.ini
Bonami Dockerfile
FROM registry.bonami.cz/bonami/bonami-runtime
COPY . /var/www/bonami-web
RUN chown -R apache:apache /var/www/bonami-web/app/cache /var/www/bonami-web/app/logs && 
chmod 775 /var/www/bonami-web/app/cache /var/www/bonami-web/app/logs && 
cp /var/www/bonami-web/docker/nginx_staticfiles.conf /etc/nginx/nginx.conf && 
sudo -u apache /var/www/bonami-web/app/console cache:warmup --env=prod
ENTRYPOINT ["/var/www/bonami-web/docker/start.sh"]
#!/bin/bash
case "$1" in
fpm)
echo "PHP-FPM starting on port 9000..."
exec ${fpmBinary} -F
;;
cron)
if [ ! -f $DIR/tools/docker/crontab/$2 ]; then
echo "error: specified crontab does not exist in crontab directory" >&2; exit 1
fi
echo "Crontab $2 starting..."
exec sudo -u $wwwUser ${cronBinary} $DIR/tools/docker/crontab/$2
;;
daemon|job|script|tool)
if [ -z $2 ] || [ ! -x $DIR/bin/$1s/$2 ]; then
echo "error: $1 does not exist" >&2; exit 1
fi
arr=(sudo -u $wwwUser BONAMI_ENVIRONMENT=prod $DIR/bin/$1s/$2)
exec "${arr[@]}"
;;
bash)
exec /bin/bash
;;
static)
echo "Static content is served on port 8080..."
exec /usr/sbin/nginx -g "daemon off;"
;;
echo $"Usage: {fpm|daemon|job|cron|bash|script|static|tool|git_hash}"
exit 2
esac
Entrypoint
Some guidelines
• Only one application in container (no Supervisord)
• There is no need for SSHd (we have Docker exec)
• Keep the container small (remove all that is not necessary)
• Keep layers count small
• If you use some tmp files, delete them in same layer
How to deploy our image?
boch@bart.bonami.cz~$ sudo docker run -d --log-opt "gelf-
address=udp://quimby.bonami.cz:12201" --name "bonamiweb-fpm" --
log-driver "gelf" --volume "/tmp:/tmp" --net "host" --restart
"always" registry.bonami.cz/bonami/bonamiweb:latest daemon
flexibee-queue-daemon
Fabric
• SSH Connection manager + some usefull tools
• Written in Python
• http://www.fabfile.org/
from fabric.api import *
from fabric.colors import *
from fabric.operations import prompt
env.forward_agent = True
env.use_ssh_config = True
env.user = "deploy"
env.deployServer = "quimby.bonami.cz"
@hosts(env.deployServer)
def deploy(service):
_load_service_configuration(service)
execute (_run_hooks, "onLoad", hosts=env.config["hooks"].keys());
_set_current_release()
_wait_for_jenkins()
_check_build_status()
execute(_run_hooks, "onStart", hosts=env.config["hooks"].keys());
execute(_docker_login, hosts = env.config["hosts"].keys());
execute(_docker_pull, hosts = env.config["hosts"].keys());
execute(_run_hooks, "beforeReplace", hosts = env.config["hooks"].keys());
execute(_docker_replace, hosts = env.config["hosts"].keys());
execute(_run_hooks, "afterReplace", hosts = env.config["hooks"].keys());
Fabric
deploy@quimby.bonami.cz~$ cat config/bonamiweb.yml
jenkins:
username: fabric
password: supertajneheslo
host: "https://jenkins.bonami.cz"
job: bonami-production
registry:
host: "registry.bonami.cz"
username: fabric
password: supertajneheslo
keepReleases: 5
hooks:
homer.bonami.cz:
beforeReplace:
- "echo "Switching to deploy virtualhost""
- "sudo rm /etc/nginx/sites/bonami.cz.conf"
- "sudo ln -s /etc/nginx/sites-available/deploy.bonami.cz.conf /etc/nginx/sites/bonami.cz.conf"
- "sudo service nginx reload"
afterReplace:
- "echo "Switching to live virtualhost""
- "sudo rm /etc/nginx/sites/bonami.cz.conf"
- "sudo ln -s /etc/nginx/sites-available/bonami.cz.loadbalace.conf /etc/nginx/sites/bonami.cz.conf"
- "sudo service nginx reload"
- "curl -X POST --data-urlencode 'payload={"channel": "#dev", "username": "deploy", "text":
"It'"'"'s alive!", "icon_emoji": ":computer:"}' https://hooks.slack.com/services/..."
Deploy skript
hosts:
apu.bonami.cz:
- image: bonami/bonamiweb
name: "bonamiweb-draft-storage-daemon"
restart: always
net: host
arg: "daemon draft-storage-daemon"
volume:
- "/tmp:/tmp:ro"
homer1.bonami.cz:
- image: bonami/bonamiweb
name: "bo namiweb-fpm"
restart: always
net: host
arg: "fpm 9000"
- image: bonami/redis
name: "redis"
restart: always
net: host
- image: bonami/bonamiweb
name: "bonamiweb-static"
restart: always
net: host
arg: "static"
Deploy skript
Vašek Boch
That’s it.
@vasekboch
vaclav.boch@bonami.cz
Do you want to work with us?
hledamevyvojare@bonami.cz
https://www.startupjobs.cz/startup/bonami-cz

More Related Content

What's hot

Deploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRubyDeploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRubyJoe Kutner
 
Using filesystem capabilities with rsync
Using filesystem capabilities with rsyncUsing filesystem capabilities with rsync
Using filesystem capabilities with rsyncHazel Smith
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013Tomas Doran
 
Red hat lvm cheatsheet
Red hat   lvm cheatsheetRed hat   lvm cheatsheet
Red hat lvm cheatsheetPrakash Ghosh
 
Docker Ecosystem: Part V - Docker Registry
Docker Ecosystem: Part V - Docker RegistryDocker Ecosystem: Part V - Docker Registry
Docker Ecosystem: Part V - Docker RegistryMario IC
 
A Better WordPress Workflow with WP-CLI
A Better WordPress Workflow with WP-CLIA Better WordPress Workflow with WP-CLI
A Better WordPress Workflow with WP-CLIRikesh Ramlochund
 
Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)
Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)
Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)Japheth Thomson
 
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...Develcz
 
Docker Compose to Production with Docker Swarm
Docker Compose to Production with Docker SwarmDocker Compose to Production with Docker Swarm
Docker Compose to Production with Docker SwarmMario IC
 
Travel with your mock server
Travel with your mock serverTravel with your mock server
Travel with your mock serverJorge Ortiz
 
Node.js streaming csv downloads proxy
Node.js streaming csv downloads proxyNode.js streaming csv downloads proxy
Node.js streaming csv downloads proxyIsmael Celis
 
OpenShift4 Installation by UPI on kvm
OpenShift4 Installation by UPI on kvmOpenShift4 Installation by UPI on kvm
OpenShift4 Installation by UPI on kvmJooho Lee
 
Quay 3.3 installation
Quay 3.3 installationQuay 3.3 installation
Quay 3.3 installationJooho Lee
 
Pursue container architecture with mincs
Pursue container architecture with mincsPursue container architecture with mincs
Pursue container architecture with mincsYuki Nishiwaki
 

What's hot (20)

Deploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRubyDeploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRuby
 
Using filesystem capabilities with rsync
Using filesystem capabilities with rsyncUsing filesystem capabilities with rsync
Using filesystem capabilities with rsync
 
Docker Workshop
Docker WorkshopDocker Workshop
Docker Workshop
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013
 
Docker in practice
Docker in practiceDocker in practice
Docker in practice
 
Red hat lvm cheatsheet
Red hat   lvm cheatsheetRed hat   lvm cheatsheet
Red hat lvm cheatsheet
 
Test driven infrastructure
Test driven infrastructureTest driven infrastructure
Test driven infrastructure
 
!!! Huong dan !!!
!!! Huong dan !!!!!! Huong dan !!!
!!! Huong dan !!!
 
Ubic YAPC 2012
Ubic YAPC 2012Ubic YAPC 2012
Ubic YAPC 2012
 
Phd3
Phd3Phd3
Phd3
 
Docker Ecosystem: Part V - Docker Registry
Docker Ecosystem: Part V - Docker RegistryDocker Ecosystem: Part V - Docker Registry
Docker Ecosystem: Part V - Docker Registry
 
A Better WordPress Workflow with WP-CLI
A Better WordPress Workflow with WP-CLIA Better WordPress Workflow with WP-CLI
A Better WordPress Workflow with WP-CLI
 
Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)
Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)
Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)
 
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
 
Docker Compose to Production with Docker Swarm
Docker Compose to Production with Docker SwarmDocker Compose to Production with Docker Swarm
Docker Compose to Production with Docker Swarm
 
Travel with your mock server
Travel with your mock serverTravel with your mock server
Travel with your mock server
 
Node.js streaming csv downloads proxy
Node.js streaming csv downloads proxyNode.js streaming csv downloads proxy
Node.js streaming csv downloads proxy
 
OpenShift4 Installation by UPI on kvm
OpenShift4 Installation by UPI on kvmOpenShift4 Installation by UPI on kvm
OpenShift4 Installation by UPI on kvm
 
Quay 3.3 installation
Quay 3.3 installationQuay 3.3 installation
Quay 3.3 installation
 
Pursue container architecture with mincs
Pursue container architecture with mincsPursue container architecture with mincs
Pursue container architecture with mincs
 

Similar to Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru

Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Bo-Yi Wu
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014D
 
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 2014biicode
 
Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyAndré Rømcke
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer ToolboxPablo Godel
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)Soshi Nemoto
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...Puppet
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configurationlutter
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabricandymccurdy
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual InfrastructureBryan McLellan
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 applicationRoman Rodomansky
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment TacticsIan Barber
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabricandymccurdy
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slidesDocker, Inc.
 
Amazon Web Services and Docker: from developing to production
Amazon Web Services and Docker: from developing to productionAmazon Web Services and Docker: from developing to production
Amazon Web Services and Docker: from developing to productionPaolo latella
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby TeamArto Artnik
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoHannes Hapke
 
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...Docker, Inc.
 

Similar to Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru (20)

Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014
 
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
 
Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and Symfony
 
Belvedere
BelvedereBelvedere
Belvedere
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer Toolbox
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual Infrastructure
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment Tactics
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabric
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Amazon Web Services and Docker: from developing to production
Amazon Web Services and Docker: from developing to productionAmazon Web Services and Docker: from developing to production
Amazon Web Services and Docker: from developing to production
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
 
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
 

Recently uploaded

Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 

Recently uploaded (20)

Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 

Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru

  • 1. Jak se ^bonami.(cz|pl|sk)$ vešlo do kontejneru Václav Boch, Bonami.cz 31.3.2016
  • 2. What you can use for deployment? • FTP • SFTP/SSHFS • GIT • Bash • Capistrano • RPM • Docker
  • 3. Docker • Docker is shipping container for your application. • Contains everything that your app needs.
  • 5. Image • Layers • Read Only • Running image is container Base Image (Ubuntu / Alpine) Apps PHP, extensions, vim, runtime configuration Your configuration + ceritificates Your codeRead only Cache warm up
  • 6. Container • Running image • The last layer of image • Only layer that is writable Base Image (Ubuntu / Alpine) Apps PHP, extensions, vim, runtime configuration Your configuration + ceritificates Your code Running container (tmp files) Read only Writable Cache warm up
  • 7. Production & test Image Base Image (Ubuntu / Alpine) Apps PHP, extensions, vim, runtime configuration Your prod configuration + ceritificates Your code Bonami Base Cache warm up Your test configuration + ceritificates Test tools (PHPUnit) Cache warm up Production image Test image
  • 8. Source Code repo Docker Registry How does it work? Dockerfile For Core, Test, Prod Docker Engine Push Docker Production server + Docker Push Search Pull Run HostCI server ContainerA ContainerB ContainerC BaseImage Local DEV machine CI server Production Test Image Prod Image Search Pull & Run Docker Test server + Docker ContainerA ContainerB ContainerC Build
  • 9. Bonami Base – Dockerfile FROM registry.bonami.cz/bonami/fedora ENV TERM xterm RUN dnf install -y php-fpm php-cli php-curl php-intl php-mysql php-mcrypt php-gd php-redis php-igbinary php-pecl-http php-pecl-imagick php-bcmath vim sudo php-mbstring php-xml php-soap php-pdo php-mysqlnd php-opcache php-twig redis php-pecl-apcu msmtp nginx tar && curl -SLO "https://nodejs.org/dist/v0.12.7/node-v0.12.7-linux-x64.tar.gz" && tar -xzf "node-v0.12.7-linux-x64.tar.gz" -C /usr/local --strip-components=1 && rm -f /node-v0.12.7-linux-x64.tar.gz && mkdir -p /var/www/bonami-web && echo "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" >> /etc/environment && dnf clean all && rm -rf /var/cache/dnf && rm -rf /var/log/dnf && sed -i -e "s/([;]*)(upload_max_filesize[ t]*=)(.*)$/2 16M /g" /etc/php.ini && sed -i -e "s/([;]*)(date.timezone[ t]*=)(.*)$/2 "Europe/Prague" /g" /etc/php.ini
  • 10. Bonami Dockerfile FROM registry.bonami.cz/bonami/bonami-runtime COPY . /var/www/bonami-web RUN chown -R apache:apache /var/www/bonami-web/app/cache /var/www/bonami-web/app/logs && chmod 775 /var/www/bonami-web/app/cache /var/www/bonami-web/app/logs && cp /var/www/bonami-web/docker/nginx_staticfiles.conf /etc/nginx/nginx.conf && sudo -u apache /var/www/bonami-web/app/console cache:warmup --env=prod ENTRYPOINT ["/var/www/bonami-web/docker/start.sh"]
  • 11. #!/bin/bash case "$1" in fpm) echo "PHP-FPM starting on port 9000..." exec ${fpmBinary} -F ;; cron) if [ ! -f $DIR/tools/docker/crontab/$2 ]; then echo "error: specified crontab does not exist in crontab directory" >&2; exit 1 fi echo "Crontab $2 starting..." exec sudo -u $wwwUser ${cronBinary} $DIR/tools/docker/crontab/$2 ;; daemon|job|script|tool) if [ -z $2 ] || [ ! -x $DIR/bin/$1s/$2 ]; then echo "error: $1 does not exist" >&2; exit 1 fi arr=(sudo -u $wwwUser BONAMI_ENVIRONMENT=prod $DIR/bin/$1s/$2) exec "${arr[@]}" ;; bash) exec /bin/bash ;; static) echo "Static content is served on port 8080..." exec /usr/sbin/nginx -g "daemon off;" ;; echo $"Usage: {fpm|daemon|job|cron|bash|script|static|tool|git_hash}" exit 2 esac Entrypoint
  • 12. Some guidelines • Only one application in container (no Supervisord) • There is no need for SSHd (we have Docker exec) • Keep the container small (remove all that is not necessary) • Keep layers count small • If you use some tmp files, delete them in same layer
  • 13. How to deploy our image? boch@bart.bonami.cz~$ sudo docker run -d --log-opt "gelf- address=udp://quimby.bonami.cz:12201" --name "bonamiweb-fpm" -- log-driver "gelf" --volume "/tmp:/tmp" --net "host" --restart "always" registry.bonami.cz/bonami/bonamiweb:latest daemon flexibee-queue-daemon
  • 14. Fabric • SSH Connection manager + some usefull tools • Written in Python • http://www.fabfile.org/
  • 15. from fabric.api import * from fabric.colors import * from fabric.operations import prompt env.forward_agent = True env.use_ssh_config = True env.user = "deploy" env.deployServer = "quimby.bonami.cz" @hosts(env.deployServer) def deploy(service): _load_service_configuration(service) execute (_run_hooks, "onLoad", hosts=env.config["hooks"].keys()); _set_current_release() _wait_for_jenkins() _check_build_status() execute(_run_hooks, "onStart", hosts=env.config["hooks"].keys()); execute(_docker_login, hosts = env.config["hosts"].keys()); execute(_docker_pull, hosts = env.config["hosts"].keys()); execute(_run_hooks, "beforeReplace", hosts = env.config["hooks"].keys()); execute(_docker_replace, hosts = env.config["hosts"].keys()); execute(_run_hooks, "afterReplace", hosts = env.config["hooks"].keys()); Fabric
  • 16. deploy@quimby.bonami.cz~$ cat config/bonamiweb.yml jenkins: username: fabric password: supertajneheslo host: "https://jenkins.bonami.cz" job: bonami-production registry: host: "registry.bonami.cz" username: fabric password: supertajneheslo keepReleases: 5 hooks: homer.bonami.cz: beforeReplace: - "echo "Switching to deploy virtualhost"" - "sudo rm /etc/nginx/sites/bonami.cz.conf" - "sudo ln -s /etc/nginx/sites-available/deploy.bonami.cz.conf /etc/nginx/sites/bonami.cz.conf" - "sudo service nginx reload" afterReplace: - "echo "Switching to live virtualhost"" - "sudo rm /etc/nginx/sites/bonami.cz.conf" - "sudo ln -s /etc/nginx/sites-available/bonami.cz.loadbalace.conf /etc/nginx/sites/bonami.cz.conf" - "sudo service nginx reload" - "curl -X POST --data-urlencode 'payload={"channel": "#dev", "username": "deploy", "text": "It'"'"'s alive!", "icon_emoji": ":computer:"}' https://hooks.slack.com/services/..." Deploy skript
  • 17. hosts: apu.bonami.cz: - image: bonami/bonamiweb name: "bonamiweb-draft-storage-daemon" restart: always net: host arg: "daemon draft-storage-daemon" volume: - "/tmp:/tmp:ro" homer1.bonami.cz: - image: bonami/bonamiweb name: "bo namiweb-fpm" restart: always net: host arg: "fpm 9000" - image: bonami/redis name: "redis" restart: always net: host - image: bonami/bonamiweb name: "bonamiweb-static" restart: always net: host arg: "static" Deploy skript
  • 18. Vašek Boch That’s it. @vasekboch vaclav.boch@bonami.cz Do you want to work with us? hledamevyvojare@bonami.cz https://www.startupjobs.cz/startup/bonami-cz