Our system consists of

  • 2 frontend applications A and B (both in JavaScript/Angular),
  • 3 backend applications C, D and E (main API and two microservices all in Go)
  • MongoDB as F

Our team grows bigger, it's 10 developers at the moment.

We are working on 2, 3 new major features at the same time.

We only have two pre-production environments which makes it hard to test/present different features that are being built at the moment (and on top of that, to test fixed bugs and hot fixes etc.).

We use Git and try to follow git branching model (which might not be relevant here).

To make it easier, we can assume, that each repository has its own Dockerfile to create a fully working container with that application.

What are the options to make it super easy (one command) to publish/switch to a feature that a developer is working on so it's available on one of the environments (that could maybe be created dynamically?)

Should we create 6 new servers/containers if we only make changes in application A?

I would like to have easily accessible versions via a URL like https://a166.preview.example.com where a is the application name and 166 is the application version (or branch name).

1 Answer 1


What you're after is referred to as "Review Apps" by Gitlab and Heroku. It relies on a CI/CD system that runs pipelines on every branch, and exposes the branch name to the build (usually as an environment variable). You can then use the branch name to namespace the resources created by your Infrastructure as Code.

You have mentioned Docker so I will use Kubernetes as an example, but this approach can be applied to just about any deployment method.

Normally when deploying a Docker image, you would name your deployment after the app, e.g.:

apiVersion: apps/v1
kind: Deployment
  name: my-app
# ...

Using either some kind of preprocessor (Jinja, envsubst, etc.) or a tool like Helm we can pass in some parameters to make the resource include the branch name during the pipeline:

apiVersion: apps/v1
kind: Deployment
  name: my-app-${BRANCH_NAME}
# ...

This way, branches do not deploy on top of each other. The resources they deploy are isolated to the branch.

For an API or web app, you'll want some kind of DNS name and load balancer. Kubernetes handles this quite easily with Ingress and DNS controllers, so I'll use CloudFormation as an example this time.

AWSTemplateFormatVersion: '2010-09-09'
    Type: String
    Type: String
    Type: String

# ALB resources omitted for brevity...

    Type: AWS::Route53::RecordSet
      Name: !Sub
        - "my-app-${Branch}.${Environment}.${Zone}"
      HostedZoneName: !Ref Zone
      Type: A
        HostedZoneId: !GetAtt ALB.CanonicalHostedZoneID
        DNSName: !GetAtt ALB.DNSName

Here we create a DNS record that is very specific to the branch. The DNS record resolves to a load balancer which should point to the containers deployed by the pipeline for this branch. The stack name is also specific to the branch, so pipelines on other branches will not affect it. The end result is that each feature branch will have a dedicated URL (https://my-app-my-feature.dev.example.com) that your developers can use to test and showcase to stakeholders.

Should we create 6 new servers/containers if we only make changes in application A?

No. This isn't specifically related to Review Apps, but microservices in general should be self-contained: decoupled from each other so that they can be deployed in isolation. Removing dependencies and making small changes will increase your development/deployment velocity.



What happens when you merge or delete your branch? Without setting up some kind of cleanup, those containers and DNS records will sit around forever. You need some kind of cleanup. Something that just runs periodically and deletes resources associated to old branches is pretty simple to write, or you could take webhooks from your git server and delete those resources on an event.


Some resources may not warrant getting deployed per-branch, although this should be the exception rather than the norm. You probably don't want to deploy a new database every time someone makes a branch (perhaps unless you have a good schema management tool and DB population scripts). You can have all deployments connect back to the same DB. Ensure that any changes you make to the schema are backwards compatible at least one version behind.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.