4

Does anyone have a script which will deploy magento2 to the server using Capistrano or other auto deploy scripts?

Thank you.

2

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/.

  • Agreed in regards to the link only comment, however the material referenced is pretty useful. This answer didn't deserve a negative in my opinion. – themanwhoknowstheman Dec 8 '16 at 22:48
1

This is in german but should be workable

http://slideshare.net/rhutterer/magento-capistrano-46254101

1

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: git@gitlab.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)

Cheers.

  • Structure wise it's similar to Capistrano. Definitely, Capistrano has big user-base which is a plus as compared to this. – MagePsycho Jul 1 '18 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.