Code builders take your source code and prepare it for deployment to your servers. Traditionally, this has meant installing Composer dependencies and very little else, but with the introduction of the Advanced code builder, developers will be able to add their own scripts to this process!
The Advanced code builder is now available on all Silverstripe Cloud stacks and you can read on to find out what you need to know about how to use it.
Getting started
Building your front-end assets is a great example of how custom scripts can enhance your development experience. With the traditional Basic code builder, these assets need to be baked into your source code, which often leads to unnecessary rebasing and rebuilding during development. With the Advanced code builder, you can remove these assets once and for all, and allow Silverstripe Cloud to take care of building them during deployment.
We recommend testing the Advanced code builder and any custom scripts in your UAT environment first, and enabling it in your production environment only once you’re confident that everything’s running smoothly.
To get started, switch to the Advanced code builder using the new Code Builders tab in the Environment view on Silverstripe Cloud.
Once you’ve switched to the Advanced code builder, you can specify a script in your package.json file named cloud-build. This script should run whatever script/process is responsible for building the production version of your front-end assets. The code builder will automatically identify whether to use NPM or Yarn, and install your dependencies prior to running the cloud-build script, cleaning them up afterwards to save disk space on your web servers.
“scripts”: {
“cloud-build”: “webpack -p”
}
By default, NPM / Yarn scripts will run against Node 10, but you can tell it to run a different version if necessary by defining it in an .nvmrc file in the root directory of your project. We currently support Node LTS versions 6, 8, 10 and 12.
Once you’ve configured your cloud-build script, you can remove the production assets from your source code, push these changes to a branch, and start a deployment. Keep an eye on the deployment log for progress, as any errors in your script will be reported there. If all goes well, you’ll now be ready to roll this out to your production environment!
Harmony with Package Deployments
Silverstripe Cloud offers another deployment mechanism called Package Deployments, which allows you to deploy code that has been pre-packaged by a separate tool - most commonly a CI pipeline.
A limitation of this approach is that if a manual deployment is ever required, the traditional Basic code builder is unable to match any custom build steps used for pre-packaged deployments.
With the Advanced code builder, you can configure your CI pipeline and Silverstripe Cloud to run the same cloud-build script, so that deployments work correctly no matter how they are started.
Wrapping up
We’ve labelled this feature as a ‘beta’ in Silverstripe Cloud until we see broader adoption from customers. Rest assured we’ve been testing the Advanced code builder with our web development teams at Silverstripe and have seen great results so far.
We’re excited to get this new capability into the hands of development teams using Silverstripe Cloud, and look forward to seeing how this improves the development and deployment experience. If you have any feedback on the new functionality, please reach out to us via the Silverstripe Service Desk.
For more information on Code Builders and custom scripts, visit the new Code Builders documentation.
Post your comment
Comments
No one has commented on this page yet.
RSS feed for comments on this page | RSS feed for all comments