What is the difference between deployment environment and code branch?

Viewed 371

Intro

I'm working on an application that has different deployment environments:

  • DEV (development)
  • UAT (user acceptance testing)
  • PROD (production)

I understand that development for a new release happens in DEV, is pushed to UAT for testing and then pushed to PROD for actual usage. Different environments are used to makes sure that developers can play around and make errors without disturbing actual users of the application.

However I'm a bit confused about what happens when a "hotfix" (=bug that needs to be fixed urgently) is required. A colleague told me that in this case the code of the PROD environment is "branched" and pushed to DEV. When the bug is fixed on dev, the branch is pushed further to UAT and finally PROD again. Even if there were already some developments for a next release in DEV, then still this work would not be lost as the "hotfix" is done on a different "branch".

Question

Is the following understanding, relating to the difference between deployment environments and code branches, correct?

  • A code branch is just a copy of a codebase that starts living a separate life until it is merged with the main code branch again.
  • A deployment environment is an environment that has code, a database for the code to interact with and computing power to execute the code.

The difference is thus mainly that the deployment environment has a database and computation power on top of the pure "code".

1 Answers

you're almost correct. a branch -often a git branch- is a fork/copy from the codebase at a certain point in time. in your case, your branch "hotfix" is a copy from "master" branch. you modify the code as needed, then merge it back into "master".

a deployment environment is where an instance of codebase -specific branch- runs. it differs in terms of the physical machine capabilities, and configuration variables.

database credentials (URL, username, and password) are a good example, as each deployment should deal with its own data. external APIs' keys and access tokens should be kept as environment variables, while inside the codebase you attempt to read it from the environment.

that way, if your app creates an order -> calls a payment gateway API -> sends an email to the customer -> etc, in development you will be calling a sandbox API, not taking the action of payment and sending email for real. and developers do not know the real credential or access keys for other services.

12factors app will give you more satisfying knowledge.

Related