Deploying Silverstripe projects with `deployer`

Prerequisites

  • SSH access to your servers
  • deployer 8 installed on your local system
  • deployer8-silverstripe6.php script present somewhere in your local filesystem
  • mandatory: composer, acl and rsync installed on your servers
  • reccomended: cachetool and unzip installed on your servers

What you need to configure manually

This deployment strategy is webserver and database agnostic. You must preemptively configure webserver and database by yourself.

Keep in mind if your deploy_path is /path/to/production, Silverstripe will be installed under /path/to/production/current.

How to deploy

Create a deploy.yaml file in the root of your Silverstripe project.

import: /path/to/deployer8-silverstripe6.php
hosts:
  staging:
    hostname: mystagingserver
    keep_releases: 1
    deploy_path: '/path/to/staging'
  production:
    hostname: myproductionserver
    deploy_path: '/path/to/production'

Create different environments to match the various hosts: .env for development, .env.staging for staging and .env.production for production. You can theoretically have as many hosts as you want: staging and production are just two names I use by convention.

If everything is configured properly, you should be able to:

dep deploy staging       # Deploy to staging host
dep deploy production    # Deploy to production host
dep rollback production  # Rollback to previous version
dep backup production    # Download both assets and database dump

Are you using deployer shared files and directories? Things like the cms-uploaded assets (and the env file) need to persist across deployments, so it’s a good way to manage those.

Yes: the deployer silverstripe recipe already does that. I also have a PR to fix devbuild for Silverstripe 6 but it is not merged yet.

This is uploaded on each deployment by the deploy:dotenv action.