The Techjoomla Blog

Stay updated with all the latest happenings at Techjoomla. From news about the developments in your favourite extensions to Tips & Tricks about the Joomla CMS, Framework & Development.
Font size: +
3 minutes reading time (552 words)

Deploying Joomla projects using GIT

Deploying-Joomla-projects-using-GIT

Over the years we've been using various methods to deploy websites to servers. FTP is everyone's first love and hot favourite. But when GIT came along and we started using that our VCS of choice it became increasingly evident that we can use it for deployment too. The biggest challenge here was managing the database.  Because of the way new table creations and table alterations are handled in Joomla we decided to leave out table updates in the automated deployment process and chose to handle them by extension installation or manual creation. With that decided it became easy to structure and write code so that it can be deployed via a simple script.

I'm giving here an example of the deployment script for a website that relies heavily on Zoo. We also have a few other extensions but Zoo is central. A few points about our setup

  1. The entire Joomla/images folder is excluded from GIT. Any images that the application itself needs are stored in media or along with the template
  2. Zoo saves its fields and settings in .config files somewhere in the /media/zoo folder. These are excluded from git
  3. The user-generated content like images and other files are of course excluded from git
  4. cache, log & tmp are excluded from git
  5. configuration.php too is of course excluded

Here's the structure of the project's git repo

/code
/code/www (Contains Joomla and all extensions -- this is what gets deployed)
/code/scripts (This is where the deployment and other scripts are stored)
/database (Contains schema dump for new devs to start with)
/documentation (Release notes)

 Here's what the dev team follows

  1. All devs work on their own clone. The clone is symlinked into their docroot for ease of development
  2. Every release is tagged within git (The deploy script needs a tag number to be specified for deployment)
  3. If any release involves configuration changes they are handled in the form of a Release Note for that version and run at the time of deployment

Now, to perform the deployment the person doing the deployment has to login to the server and simply run the deployment script.

$ cd /var/www && ./joomla-deploy.sh 0.8.4 0.8.3 alpha

You can download the script from here - Joomla Deploy Script

Here's what the script does in a nutshell

  1. Accepts the deployment version, currently deployed version and environment name
  2.  Updates the server's local git copy and checks out the deployment version
  3. Creates a folder for deployment (Eg: /var/www/alpha-0.8.4)
  4. Moves/Copies images and other assets from the previously deployed version (Ideally these would be symlinked too, but Zoo has problems working with symlinked files, so we have to move these around every time)
  5. Symlinks  the configuration.php
  6. Finally, symlinks the alpha-0.8.4 to alpha so that the QA team can use the same URL for testing
  7. Writes out the deployed version to a small .htversion file (We have a module that reads and displays this version so that the QA team knows which version to report bugs against)

The dev team is very happy with the script since deployment time has reduced to a few seconds and is pretty much error free. Also, in case of any major issues with the deployed version, it is very easy to roll back to the older version by simply changing the symlink to point to the older version!

7
×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

Listen Up ! SocialAds 2.9 is out with Ad wallet, C...
Profile Completeness module for Joomla 2.5.x & 3.0...

Related Posts

 

Blog Topics