SlideShare ist ein Scribd-Unternehmen logo
1 von 53
2017.LARAVEL
DAYDeploy di applicazioni Laravel con le
pipeline di Bitbucket
@SENSORARI
OSimone (Demo) Gentili
IL PROGETTO
LEGACYlaravel 4, forge, homestead, beanstalk, …
N configurazioni,
N branch, N code
(~_~;)
1 codebase, 1 deploy,
N configurazioni
(◠‿◠)
Totale assenza
di una suite di test
(~_~;)
Un po’ di test
end2end
(◠‿◠)
beanstalk effettua il deploy
anche se i test si rompono
¯_(ツ)_/¯
CONTINUOUS
DEPLOYMENTCircleCI, TravisCI, CodeShip, Go-CD,
Jenkins, …
Jenkins, Go-CD
(◠‿◠)
No software
da installare
(╯°□°)╯︵ ┻━┻
CircleCI, TravisCI, CodeShip, Go-CD,
Jenkins, …
CircleCI, TravisCI, ..
(◠‿◠)
Budget a disposizione
Limitato
(ノಠ益ಠ)ノ彡┻━┻
CircleCI, TravisCI, CodeShip, Go-CD,
Jenkins, …
$ git remote add bitbucket git@…
$ git push bitbucket master
(☞゚ヮ゚)☞
Bitbucket
Pipelines
(◠‿◠)
BITBUCKET
PIPELINESssh, code deploy, private repositories,
environments, …
When someone pushes to the repo,
Pipelines runs the build in a Docker
image.
- https://confluence.atlassian.com
Repository
privati
(~_~;)
umask 077 ; echo $SSH_KEY |
base64 --decode > ~/.ssh/id_rsa
(◠‿◠)
1 codebase, 1 deploy,
N configurazioni
(◠‿◠)
branches:
master:
- step:
script:
- apt-get update && apt-get install -qy git curl libmcrypt-dev mysql-client zip unzip
- docker-php-ext-install mcrypt && docker-php-ext-install pdo_mysql
- apt-get update && apt-get install -y vim … …
- chmod +x install-composer.sh
- ./install-composer.sh
- composer dumpautoload
- composer install
- mkdir -p ~/.ssh
- cat my_known_hosts >> ~/.ssh/known_hosts
- (umask 077 ; echo $MY_SSH_KEY | base64 --decode > ~/.ssh/id_rsa)
- php artisan migrate
- ./runtests
- tar -czf build.tar.gz ./*
- sftp $SERVER_SSH_USER@$SERVER_SSH_IP <<< $'put build.tar.gznEXIT'
- ssh $SERVER_SSH_USER@$SERVER_SSH_IP ' export TEMP=tmp-folder && export CURRENT=/home/forge/www.example.com &&
export BACKUP=/home/forge/old_api && mkdir -p $CURRENT && mkdir -p /home/forge/$TEMP && rm -rf $TEMP && mkdir $TEMP && tar -vxzf
build.tar.gz -C $TEMP && mkdir -p $BACKUP && rm -rf $BACKUP && mv $CURRENT $BACKUP && mv $TEMP $CURRENT && cp $BACKUP/.env
$CURRENT/.env && cd $CURRENT && php artisan migrate --force'
- sftp $SERVER_SSH_USER_FOO@$SERVER_SSH_IP_FOO <<< $'put build.tar.gznEXIT’
- ssh $SERVER_SSH_USER_FOO@$SERVER_SSH_IP_FOO ' export TEMP=tmp-folder && export
Deploy di applicazioni Laravel con le
pipeline di Bitbucket
(◠‿◠)
- aws deploy push --application-name
LaravelDaySample --s3-location
s3://production-artifacts-
laravel/production_api_build.zip —no-ignore-
hidden-files
- aws deploy create-deployment --application-
name LaravelDaySample --s3-location
bucket=production-artifacts-
laravel,key=production_api_build.zip,bundleTyp
e=zip --deployment-group-name LaravelDaySample
--auto-rollback-configuration
enabled=true,events="DEPLOYMENT_FAILURE" --
file-exists-behavior RETAIN
LARAVEL
TENANT.env, models, controllers, …
.ENV MAIL_DRIVER=smtp
MAIL_HOST=********
MAIL_PORT=2525
MAIL_USERNAME=42
MAIL_PASSWORD=42
MAIL_ADDRESS=********
MAIL_NAME=********
API_PREFIX=api
API_DEBUG=true
S3_KEY=********
S3_SECRET=********
S3_REGION=eu-west-1
S3_BUCKET=********
SMS_SEND=0
SMS_USERNAME=********
SMS_PASSWORD=********
APP_ENV=local
APP_DEBUG=true
APP_KEY=********
APP_TENANT=Tenant
APP_BACKUP_PATH=tenant
DB_HOST=127.0.0.1
DB_DATABASE=********
DB_USERNAME=********
DB_PASSWORD=********
DB_PORT=3306
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
./APP/HTTP/ROUTES.PHP
<?php $tenant = env(‘APP_TENANT');
$root = file_exists(
base_path() . ‘/$tenant/' .
‘/Http/Controllers/Api/FooController.php'
))
? $tenant
: ’App';
$api->get(
‘resource/{id}',
$root . ‘HttpControllersApiFooController@show’
)->where(['id' => '[0-9]+']);
./COMPOSER.JSON
"autoload": {
"psr-4": {
"App": "app/",
"Verona": "tenants/verona/",
"Forli": "tenants/forli/",
"Molise": "tenants/molise/",
"Cesena": "tenants/cesena/",
"Veneto": "tenants/veneto/",
"Tokyo": “tenants/tokyo/"
}
},
ASPETTI
MIGLIORABILIdatabase, scripts, …
Spazio su
disco scarso
(~_~;)
Configurazione tenant
legata al dominio
(◠‿◠)
pipeline da ricostruire
ad ogni nuovo progetto
(~_~;)
deployer,
capistrano, rsync, …
(◠‿◠)
budget
(◠‿◠)
budget
(~_~;)
LINK &
RISORSEascii, documentazione, …
LINKS
➤ https://en.wikipedia.org/wiki/List_of_emoticons
➤ https://bitbucket.org/product/features/pipelines
➤ https://confluence.atlassian.com/bitbucket/laravel-with-
bitbucket-pipelines-913473967.html
➤ https://github.com/sensorario
➤ https://github.com/edbizarro/bitbucket-pipelines-php7
➤ https://www.slideshare.net/sensorario
➤ https://joind.in/event/laravelday/deploy-di-applicazioni-laravel-
con-le-pipeline-di-bitbucket
FINE
QUESTIO
N
TIME
https://joind.in/event/laravelday/deploy-di-applicazioni-laravel-con-le-pipeline-di-bitbucket
2017.LARAVEL
DAYDeploy di applicazioni Laravel con le
pipeline di Bitbucket

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Shared Object images in Docker: What you need is what you want.
Shared Object images in Docker: What you need is what you want.Shared Object images in Docker: What you need is what you want.
Shared Object images in Docker: What you need is what you want.
 
Deploying Plone and Volto, the Hard Way
Deploying Plone and Volto, the Hard WayDeploying Plone and Volto, the Hard Way
Deploying Plone and Volto, the Hard Way
 
DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)
 
Puppet User Group Presentation - 15 March 2012
Puppet User Group Presentation - 15 March 2012Puppet User Group Presentation - 15 March 2012
Puppet User Group Presentation - 15 March 2012
 
DevOps(2) : Vagrant - (MOSG)
DevOps(2) : Vagrant  -  (MOSG)DevOps(2) : Vagrant  -  (MOSG)
DevOps(2) : Vagrant - (MOSG)
 
Puppet and Openshift
Puppet and OpenshiftPuppet and Openshift
Puppet and Openshift
 
Anyevent
AnyeventAnyevent
Anyevent
 
DevOps with Fabric
DevOps with FabricDevOps with Fabric
DevOps with Fabric
 
nginx mod PSGI
nginx mod PSGInginx mod PSGI
nginx mod PSGI
 
Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
 
nouka inventry manager
nouka inventry managernouka inventry manager
nouka inventry manager
 
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
 
Ansible, Simplicity, and the Zen of Python
Ansible, Simplicity, and the Zen of PythonAnsible, Simplicity, and the Zen of Python
Ansible, Simplicity, and the Zen of Python
 
Puppet
PuppetPuppet
Puppet
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
 
Steam Learn: Composer
Steam Learn: ComposerSteam Learn: Composer
Steam Learn: Composer
 
Adventures in infrastructure as code
Adventures in infrastructure as codeAdventures in infrastructure as code
Adventures in infrastructure as code
 

Ähnlich wie Laravel Day / Deploy

Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
tomcopeland
 
Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13
Rafael Dohms
 

Ähnlich wie Laravel Day / Deploy (20)

Composer, putting dependencies on the score
Composer, putting dependencies on the scoreComposer, putting dependencies on the score
Composer, putting dependencies on the score
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
 
Composer: putting dependencies on the score
Composer: putting dependencies on the scoreComposer: putting dependencies on the score
Composer: putting dependencies on the score
 
[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
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
Git::Hooks
Git::HooksGit::Hooks
Git::Hooks
 
Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13
 
infra-as-code
infra-as-codeinfra-as-code
infra-as-code
 
Ubic
UbicUbic
Ubic
 
Ubic-public
Ubic-publicUbic-public
Ubic-public
 
Instrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabInstrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con Gitlab
 
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
 
Autotesting rails app
Autotesting rails appAutotesting rails app
Autotesting rails app
 
Docker, the Future of DevOps
Docker, the Future of DevOpsDocker, the Future of DevOps
Docker, the Future of DevOps
 
Os Treat
Os TreatOs Treat
Os Treat
 
Developing with-devstack
Developing with-devstackDeveloping with-devstack
Developing with-devstack
 

Mehr von Simone Gentili (9)

test driven development with phpunit
test driven development with phpunittest driven development with phpunit
test driven development with phpunit
 
Back end User Group / Golang Intro
Back end User Group / Golang IntroBack end User Group / Golang Intro
Back end User Group / Golang Intro
 
DevRomagna / Golang Intro
DevRomagna / Golang IntroDevRomagna / Golang Intro
DevRomagna / Golang Intro
 
Pubmi gitflow
Pubmi gitflowPubmi gitflow
Pubmi gitflow
 
#pugMi - DDD - Value objects
#pugMi - DDD - Value objects#pugMi - DDD - Value objects
#pugMi - DDD - Value objects
 
Corso yii #04 - il database
Corso yii   #04 - il databaseCorso yii   #04 - il database
Corso yii #04 - il database
 
Yii workshop
Yii workshopYii workshop
Yii workshop
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery Plugin
 
Javascript Camp - Listener Per Eventi
Javascript Camp - Listener Per EventiJavascript Camp - Listener Per Eventi
Javascript Camp - Listener Per Eventi
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Laravel Day / Deploy