Over the past eighteen months, we've developed and refined a workflow that has transformed how we review, test and ship code to production. We call it "Pull request review deployments". I recently presented this at Docker Athens, and I wanted to share the core concepts in our blog, as well.
In a nutshell, we deploy every pull request on its own dedicated environment. When we open a new pull request, a new deployment happens automatically, and we get a URL where we can preview the work from that particular branch. The key difference from traditional approaches is that there's no centralized staging environment - just isolated pull request deployments and the production deployment.
This approach is primarily a Git and GitHub-based workflow. We have instrumented it to work with pushing new commits to or commenting on a pull request, to trigger deployments.
Being autonomous, is a top priority for us and it requires both speed and reliability, in order to deliver great results. Traditional staging environments are not compatible with this for a few reasons:
We've kept our infrastructure remarkably simple:
This simple setup works because these are development environments with no critical user data.
Our Docker setup follows three principles:
services: web: image: ghcr.io/withlogicco/rwc:${GIT_COMMIT} environment: ENVIRONMENT: ${ENVIRONMENT} networks: default: ceryx: external: true
Our CI/CD workflow is built on three key elements:
.recreate
For observability we focus on three aspects:
To make environments useful from the start, we:
dumpdata
This approach means each environment starts with useful sample data and pre-configured users for testing different roles.
For each deployment, we need a unique URL secured with SSL. We handle this by:
pr-11.rwc.<development-domain>
To avoid managing DNS records at deployment times, we have set up up a wildcard DNS record (*.<development-domain>) pointing to our bare-metal server, where all environments are deployed.
*.<development-domain>
Since these environments, are often sensitive, we grant access only to authorised people. We secure these environments with Cloudflare Access, which offers:
Summing up, the key take aways of pull request review deployments are:
And as a bonus, since this is running on a 64GB bare-metal server, we get to host tens of deployed environments concurrently, without breaking the bank.
If you're considering implementing something similar, here are a few things to keep in mind:
Pull request review deployments have been a game-changer for our development workflow at LOGIC. We have been working this way daily on multiple projects for more than a eighteen months and we can never go back. The only thing we look forward to is making this even better with more ideas we have in mind.
If you're interested in learning more or want to discuss implementing a similar approach, feel free to contact us.
Get notified when an article lands on the LOGIC blog.