This is a module for the n98-magerun toolset. It adds a set of commands intended to manage Capistrano configuration for your Magento 1.x codebase.
-
Either clone this repository or download the latest version of 6by6/magerun-deploy. You should unzip/clone the package into the module directory configured above.
-
Ensure the module has been installed correctly by running
n98-magerun.phar deploy:config
within a Magento codebase.
Capistrano is a Ruby application. You will therefore need to ensure your environment has Ruby installed (see Installing Ruby). We would recommend using a Ruby manager, we prefer rbenv.
You will also require Bundler as we'll be using Gemfiles to manage dependencies.
The first step involves creating the directory structure for your Capistrano configuration.
Navigate to the root of your Magento instance e.g.
$ cd ~/code/web/magento/vanilla/1.9.2.4
Run the setup command
$ n98-magerun.phar deploy:setup
You should see output similar to the following:
Inspecting codebase for existing Cap files...
✔ Wrote ~/code/web/magento/vanilla/1.9.2.4/Gemfile
✔ Wrote ~/code/web/magento/vanilla/1.9.2.4/Capfile
✔ Created ~/code/web/magento/vanilla/1.9.2.4/config
✔ Created ~/code/web/magento/vanilla/1.9.2.4/config/deploy
✔ Created ~/code/web/magento/vanilla/1.9.2.4/config/sixbysix-deploy.json
If you have existing Capistrano files you'll see output similar to:
Inspecting codebase for existing Cap files...
Found the following files/dirs:
⇒ ~/code/web/magento/vanilla/1.9.2.4/Gemfile
⇒ ~/code/web/magento/vanilla/1.9.2.4/Capfile
⇒ ~/code/web/magento/vanilla/1.9.2.4/config/deploy
⇒ ~/code/web/magento/vanilla/1.9.2.4/config/sixbysix-deploy.json
⇒ ~/code/web/magento/vanilla/1.9.2.4/config
✖ It looks like there is an existing setup. Please run 'deploy:wipe' to remove the above files.
This is simply warning you that you should check out the existing files and ensure you're not about to delete anything important. If you're happy to continue run $ n98-magerun.phar deploy:wipe
.
You have two options:
We have included a wizard to help you setup general and stage configuration. You can invoke this by running
$ n98-magerun.phar deploy:config:wizard
Actually a two-liner...
The first command, demonstrated below, can be used to set your general options. You can include as many or as few options as you wish here. Check out $ n98-magerun.phar deploy:config --help
for available options.
$ n98-magerun.phar deploy:config update --name="vanilla-1.9.2.4" --scm=git [email protected]:6by6/magento-1.9.2.4.git --shared_dirs=/wp --shared_files=/.htaccess --shared_files=/maintenance.flag
The second command is used to add/update/remove stages from your config, for example:
$ n98-magerun.phar deploy:config:stage add --name=prod --host=127.0.0.1 --user=daniel --deploy_to=/var/www/prod --branch=master
$ n98-magerun.phar deploy:config:stage edit --name=prod --rename=demo --branch=develop
$ n98-magerun.phar deploy:config:stage delete --name=demo
When you have modified your config you'll need to regenerate your Ruby files. We have included one last command for this:
$ n98-magerun.phar deploy:generate
With configuration out the way all that's left is initiating a deployment.
From your codebase root:
-
$ bundle --path=.bundle
(installs gems locally) -
$ bundle exec cap $STAGE_NAME deploy:setup
(creates shared files etc.) -
$ bundle exec cap $STAGE_NAME deploy
(deploys your code)