Skip to content

Latest commit

 

History

History
57 lines (43 loc) · 1.46 KB

README.md

File metadata and controls

57 lines (43 loc) · 1.46 KB

Deploy Laravel 5 using Ansible in Capistrano way

Prepare

Create hosts file for all your environments from example:

cp hosts.example production

Create group_vars/laravel.yml from example:

cp group_vars/laravel.example.yml group_vars/laravel.yml

Edit it to match your environment.

Note! Playbook uses Ansistrano, so you are free to update default group_vars and use Ansistrano's.

Use

Playbooks:

  • playbook-deploy.yml - Run files deployment
  • playbook-rollback.yml - Rollback deploy
  • playbook-migrate.yml - Run migrations
  • playbook-seed.yml - Run seeding
ansible-playbook playbook-deploy.yml -i production -u root

Deployment order

  1. Init releases directory structure
  2. Update repository
  3. Export a copy of the repo to a new release directory
  4. Copy .env.example to shared/.env if it was absent
  5. Copy storage to shared/storage if it was absent
  6. Remove local .env & storage from release directory
  7. Create soft links to shared .env & storage
  8. Install composer locally
  9. Run composer self-update
  10. Run composer install
  11. Clear Laravel cache
  12. Optimize code
  13. Run npm install
  14. Run gulp --production
  15. Change soflink to new release
  16. Update chown
  17. Install cachetool to clear opcache
  18. Run cachetool opcache:reset
  19. Restart Laravel queue
  20. Delete old relases

Attention! Don't forget to update your shared/.env file after first deploy!