Does anyone have a script which will deploy magento2 to the server using Capistrano or other auto deploy scripts?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
We successfully used this one to deploy magento 2 single server projects: https://github.com/davidalger/capistrano-magento2 by @davidalger. It also supports multiservers setup, but we havent yet look into it.
A very good info about it you can find it here: http://davidalger.com/development/magento/deploying-magento-2-using-capistrano/.
This is in german but should be workable
Capistrano is a very common deploy tool to deploy anything, but I prefer Magallanes. It is written in PHP and seems very easy (for me) to extend with my custom tasks.
But you can see that is lack of documentation, I have to check their code to learn about the flow and realise that they are absolutely compatiable to GitLab CI - my current solution for CI/CD.
Here is my example Magallanes environment for a live Magento 2 site:
# staging environment deployment: strategy: git-remote-cache user: www-data port: 10220 from: ./ to: /srv/users/www/apps/magento2 extras: enabled: true directory: shared vcs: enabled: true kind: git repository: email@example.com:company/magento2.git branch: master remote: origin directory: repo magento: enabled: false # do not enable this, don't ask me why app_path: bin/magento version: 2 # leave this alone if you are deploying magento 2 shared: enabled: true linking_strategy: absolute linked_files: - app/etc/env.php - app/etc/config.php - var/.magento_cronjob_status - var/.setup_cronjob_status - var/.update_cronjob_status - sitemap.xml linked_folders: - pub/media - var/backups - var/composer_home - var/importexport - var/import_history - var/log - var/session - var/tmp releases: enabled: true max: 10 symlink: public # symlink of current version in release directory directory: releases hosts: - ssh-alias-in-ssh-config # it is ssh alias in ~/.ssh/config, say goodbye to enter password every single time tasks: pre-deploy: on-deploy: post-release: # before the script create release folder - composer/update - magento/set-permissions - filesystem/link-shared-files - magento/production-setup # it is compatiable to magento 2.1 actually, if you aren't, use your custom tasks post-deploy:
In the real life, your remote directory will look like this after deployed.
magento2 ├── @public -> releases/20160920093107/ ├── releases │ ├── 20160920092207 │ └── 20160920093107 ├── shared │ ├── app │ ├── pub │ ├── repo │ ├── var │ └── sitemap.xml └── something_secret
So, that's it. This is how I automate my deployment workflow with Magento 2 and the others.
If you need more supports and documentations, I recommend you go with Capistrano. (it supports Magento 2, check the links in #2 answer, I myself tested it and it works very well but it is slower than Magallanes)