Skip to content

Deployment

nyeholt edited this page Feb 20, 2013 · 6 revisions

The deploy target of the phing build file is used to package up the codebase and deploy it to a remote server. This deployment process is somewhat modeled on capistrano's mechanism, but tailored for SilverStripe, whereby all releases are stored in a folder structure, with a symlink pointing to the 'current' release, which is then targetted by the Apache configuration.

The overall process runs as follows

  • The build package is created - this is either an incremental update package (typically the mysite, modules and themes directory, but each project can define what is in or out via the build.xml file), or a full deployment package
  • (Remote) The file structure is created on the remote host
    • This file structure works out to be something like
      • /data/deployments/prod/projectname/releases/yearmonthdayhourminutesecond
  • (Remote) If doing an incremental update, the current release is copied across to the new release folder
  • The package is uploaded to the target directory /data/deployments/prod/projectname/releases/current
  • (Remote) The package is extracted
  • (Remote) All local system configuration files are copied from the current release to the new release
  • (Remote) dev/build is run, and the current symlink moved to the new release folder

So, there's a few things you need to configure, and for now, it can only be run from the commandline

  • Edit the build.properties file as per normal.
  • Note the following new config items
    • deploy.targets - a list of targets that can be sequentially deployed to, comma separated. Note that the targets specified here MUST match up with the targets in subsequent config.
    • deploy.{target}.host - the hostname of the target
    • deploy.{target}.user - user to deploy as
    • deploy.{target}.pass - password of the user to deploy as. This is OPTIONAL. If not specified, you will be prompted to provide this
    • deploy.{target}.path - The path on the remote system to store deployments at. You then must link your webroot to deploy.{target}.path/current using a symlink AS THE DEPLOY USER
    • deploy.{target}.apache-group - The apache group on the remote server. It is assumed that deploy.user is in this group
  • Run an initial phing deploy -Ddeploy.first=true, which will trigger a copy of the initial codebase. There will be errors, but these are skipped over make sure all the relevant structures are in place first.
  • On the remote system, create a symlink from the webroot to the just deployed folder (via the deploy.path/current path, NOT directly to the releases folder)
  • Create the .htaccess and mysite/local.conf.php for the new system, and run dev/build. This should be enough to install the site and have it initially running - use build/configs/silverstripe/local.conf.sample.php and build/configs/silverstripe/htaccess-sample for examples of what these should contain
  • Run phing deploy from the source system again; this should now successfully run through (you'll see the usual dev/build output)
  • Verify that the /current symlink has moved to the new release
  • Verify that the mysite/scripts/{date}.sql.gz file exists in the PREVIOUS release folder.
  • The site should still be running with whatever changes were in that release.
Clone this wiki locally