Blog
Product
5
minutes

3 ways of cloning an application and a database per git branch

Back in the early days of software development, having multiple developers working on the same application was a tough challenge. That’s why VCS (Version Control System) like Git was created and methodology like Feature Branching was introduced.
Romaric Philogène
CEO & Co-founder
Summary
Twitter icon
linkedin icon

1 feature = 1 branch

The basic idea of working per git branch (also known as Feature Branching) is that when you start to work on a feature, you take a branch of your repository (e.g., git) to work on that feature.

null

The advantage of feature branching is that each developer can work on their feature and be isolated from changes going on elsewhere. This concept has been initiated for stateless application. However, most applications rely on databases (also known as “stateful application”).

The question is: How to use the concept of Feature Branch with a stateful application?

Let’s take a concrete example:

We have a NodeJS application that connects to a PostgreSQL database, for which we have 3 distinct branches: master, staging, and feature_1.

Applications from different branches connected to the same database

No matter which branch we are working on, we are always connected to the same database. If our application writes, modifies, or deletes data in the database, while we are on the "feature_1" branch, all branches will also be impacted by these changes. Meaning, we violate the main Feature Branch principle - isolation. There is nothing more stressful than having to keep in mind that we can lose data and break everything at any time.

so -

How to be compliant with the feature branch principle (isolation) with a database?

One possible solution is to have one copy of the database per branch. Each database can be modified without the risk of modifying the others.

Branches have their own database
How to have one database per branch?

3 main choices are possible (manual, partially automated, and fully automated) with all their advantages and disadvantages.

Manual

Manual means that you need to install all your required services (DNS, databases, VPC...) manually. This approach is fast enough to bootstrap, but it is hard to maintain over time.

Advantages

  • Fast to bootstrap

Disadvantages

  • You need to configure the system and network services (DNS, network, security...)
  • You need to create the databases according to the number of branches manually.
  • You need to synchronize the data between the databases manually
  • You need to setup observability, monitoring, and alerting
  • Hard to maintain over time
  • Error-prone

Partially automated

Partially automated means that you will spend time setting up a complete system that provides your required services for your project. This type of architecture needed time and effort from experienced DevOps. It's a good choice for large corporations that can support the cost, but most of the time a really bad for smaller ones.

Advantages

  • Automatic system and network configuration + database provisioning with tools like Terraform (Infrastructure as Code)
  • Automatic data synchronization between databases (with a custom script)
  • Perfectly fit your need

Disadvantages

  • You need to manually create the databases according to the number of branches
  • Required months to fully set up
  • Expensive maintenance over time (experienced DevOps engineer required)
  • You need to setup observability, monitoring, and alerting

Fully automated (with Qovery)

Fully automated means that all the required resources by the developer will be deployed no matter his needs. With Qovery, all resources are automatically provided and the developer doesn't even have to change their habits to deploy their application. Feature Branching is supported out of the box.

Qovery gives to any developer the power to clone an application and a database without having to change their habits

Let's take the example of our 3 branches with a NodeJS application and a PostgreSQL database

1 branch = 1 isolated environment

Here are the commands necessary to have a fully isolated application and database on each branch

$ pwd
~/my-nodejs-project

# Github, Bitbucket, Gitlab seamless authentication
$ qovery auth
Opening your browser, waiting for your authentication...
Authentication successful!

# Wizard to generate .qovery.yml
$ qovery init

$ git add .qovery.yml
$ git commit -m "add .qovery.yml file"

# Deploy master environment
$ git push -u origin master

# Show master environment information
$ qovery status

# Create branch staging
$ git checkout -b staging
# Deploy staging environment!
$ git push -u origin staging

# Show staging environment information
$ qovery status

# Create branch feature_1
$ git checkout -b feature_1
# Deploy feature_1 environment!
$ git push -u origin feature_1

# Show feature_1 environment information
$ qovery status

Advantages

  • Accessible to any developer
  • No setup time
  • Programming language agnostic
  • Integrated to git (no other dependencies required)
  • Compliant to Feature Branching concept

Disadvantages

  • Know how to create a Dockerfile
  • Deployment only available on AWS, GCP, and Azure
  • Only integrated to Github, Gitlab, and Bitbucket

Conclusion

In this article, we have seen that the purpose of the Feature Branch is to be able to develop a feature without being impacted by changes that can be made to other branches. However, the Feature Branch concept is difficult to apply when our application needs to access a database. Because each application (coming from several branches) has access to the same database. This is contrary to the Feature Branch isolation principle and brings serious data safety problems.

Qovery allows applications and databases to be seamlessly duplicated from one branch to another. And thus to respect the isolation principles of the Feature Branch.

Try Qovery now!

Useful links: Feature Branching and Continuous Integration from Martin Fowler - Stateless vs Stateful from StackOverflow

Share on :
Twitter icon
linkedin icon
Ready to rethink the way you do DevOps?
Qovery is a DevOps automation platform that enables organizations to deliver faster and focus on creating great products.
Book a demo

Suggested articles

DevOps
 minutes
TPUs vs. GPUs: The DevOps Guide to AI Hardware Selection

Stop guessing on AI hardware. This DevOps guide details when to use TPUs vs. GPUs for optimal performance, cost, and framework compatibility in MLOps.

Mélanie Dallé
Senior Marketing Manager
Cloud
Business
10
 minutes
The DevOps Guide to Docker Monitoring: Tools, Best Practices, and Unified Observability

Stop tool sprawl. Compare top Docker monitoring tools (Prometheus, Datadog, Qovery) and learn how unified observability simplifies K8s debugging and speeds up feature delivery.

Romaric Philogène
CEO & Co-founder
Cloud
Heroku
Internal Developer Platform
Platform Engineering
9
 minutes
The Top 8 Tools to Build a Zero-Toil PaaS on Your Cloud

Stop managing K8s complexity. Discover the top 8 platform tools (Qovery, Rancher, Dokku) that let you build a customizable, zero-maintenance PaaS on your cloud.

Morgan Perry
Co-founder
Kubernetes
 minutes
How to Deploy a Docker Container on Kubernetes: Step-by-Step Guide

Simplify Kubernetes Deployment. Learn the difficult 6-step manual process for deploying Docker containers to Kubernetes, the friction of YAML and kubectl, and how platform tools like Qovery automate the entire workflow.

Mélanie Dallé
Senior Marketing Manager
Observability
DevOps
 minutes
Observability in DevOps: What is it, Observe vs. Monitoring, Benefits

Observability in DevOps: Diagnose system failures faster. Learn how true observability differs from traditional monitoring. End context-switching, reduce MTTR, and resolve unforeseen issues quickly.

Mélanie Dallé
Senior Marketing Manager
DevOps
Cloud
8
 minutes
6 Best Practices to Automate DevSecOps in Days, Not Months

Integrate security seamlessly into your CI/CD pipeline. Learn the 6 best DevSecOps practices—from Policy as Code to continuous monitoring—and see how Qovery automates compliance and protection without slowing development.

Morgan Perry
Co-founder
Heroku
15
 minutes
Top 10 Heroku Alternatives: When Simplicity Hits the Scaling Wall

Escape rising Heroku costs & outages. Compare top alternatives that deliver PaaS simplicity on your own cloud and scale without limits.

Mélanie Dallé
Senior Marketing Manager
Product
Infrastructure Management
Deployment
 minutes
Stop tool sprawl - Welcome to Terraform/OpenTofu support

Provisioning cloud resources shouldn’t require a second stack of tools. With Qovery’s new Terraform and OpenTofu support, you can now define and deploy your infrastructure right alongside your applications. Declaratively, securely, and in one place. No external runners. No glue code. No tool sprawl.

Alessandro Carrano
Head of Product

It’s time to rethink
the way you do DevOps

Say goodbye to DevOps overhead. Qovery makes infrastructure effortless, giving you full control without the trouble.