Magento – Managing Magento/Composer/Deployment

composerdeploymentmagento-1

So, I'm enjoying using the hackathon Magento Composer installer, but I'm struggling to understand how others use it in relation to a deployment service. Currently I'm using DeployHQ, and yes, I can set it to deploy and run composer when there is an update to the repo, but this doesn't make sense to me now.

My main composer repo, containing just the json file of all of the packages I want to include in my build, only gets updated when I add a new package to the list.

When I update my theme, or custom extension (which is referenced in the json file), there is no "hook" to update my deployment service. So I have to log in to my server and manually run composer (which takes the site down until it's finished).

So how do others manage this? Should I only run composer locally and include the vendor folder in my repo?

Any answers would be greatly appreciated.

Best Answer

I have set up a structure at our agency that allows us to use Composer to deploy all our Magento sites. This might be a bit of overkill for the question you asked but here's a basic overview of the structure anyway:

Repository structure

Below is the folder structure of the 'parent' repository. It contains the composer JSON and lock files and other configuration required for deployment.

- code
   - magento
- deployment
- environmental
   - local
       - local.xml
       - robots.txt
   - staging
       - local.xml
       - robots.txt
   - production
       - local.xml
       - robots.txt
- provisioning
- public
   - index.php
- vendor
- composer.json
- composer.lock
  • All client-specific customisations are stored in a separate "customisations" module that gets installed using Composer
  • The Magento core is included as a Git submodule (code/magento)
  • A custom index.php and other folders like media and errors sit inside a public folder outside of the Magento root
  • Environment specific files (local.xml, robots.txt, etc) get symlinked into the Magento root during the deployment process
  • The vendor folder is excluded from Git, but the composer.lock file is included.

Deployment

  • We deploy using Capsitrano which allows for multiple app servers and environments (staging/production)
  • Capistrano builds the entire codebase on the server in a new folder, and then swaps the webroot symlink at the very end meaning there is no downtime for your website.
  • Capistrano runs composer install during the build and deploys all modules into the Magento submodule.

This is still not a continuous integration setup but I find it works well for Magento sites. Feel free to send me a message if you'd like some more advice that's specific to your setup.

Related Topic