How to color-code your deployment environments

And become a productivity guru 💯

illustrations illustrations illustrations illustrations

Published on 26th April 2022 by Madeleine Smith

A feature image consisting of ‘Color coding’ as text on a background of multiple bright colors.

Background

For one of the client projects that I’m working on, we have multiple deployment environments up and running. At the last count we had five - local, development, qa, staging and production. However, with so many environments, I was finding it really difficult to differentiate between each of them as each website looks exactly the same. The only difference being a single word in the url:

A screenshot of the development environment of one of my client projects prior to color coding. Everything is blurred out except the word 'dev' in the url.
A screenshot of the production environment of one of my client projects prior to color coding. Everything is blurred out except the word 'production' in the url.
Is this dev or production? I have no idea!

I wanted to be able to immediately know which environment I was looking at. Meaning that I’d be able to tell each environment apart visually, and determine the environment if given a url by someone else. And this would also allow me to know how careful I should be - i.e. I’m can go mad on a local environment but will exert due caution on staging/production.

I took inspiration for how to solve this from my experience using Postico (a PostgreSQL client) in a previous team. Postico allows you to color-code each of your data sources - so the tab for our production connection was red and for development it was green.

I came up with the idea to change the color of the top navigation bar depending on the environment. After a bit of searching, the Stylish Chrome extension seemed to fit the bill. This extension allows you to customise a website through applying custom CSS styles over the top of existing styles.


Color-coding deployment environments using Stylish

For each of my deployment environments I created a new style by selecting the ‘Create New Style’ option:

A screenshot of the Stylish Chrome extension with two options displayed - 'Create New Style' and 'Manage All Styles'.

From there, you are taken to an ‘Add style’ page where you can specify your CSS:

A screenshot of the 'Add Style' page within the Stylish Chrome extension.

In our project, the top navigation bar has a class of navbar (super original 😛) so the CSS I added was:

Where the COLOR placeholder is the specific color I wanted to use. For each environment, I limited the rule to only act on its domain using the ‘Applies to’ dropdown.

And the result looks like this:

A screenshot of the development environment of one of my client projects after color coding. Everything is blurred out except the word 'dev' in the url.
A screenshot of the production environment of one of my client projects after color coding. Everything is blurred out except the word 'production' in the url.
Ah, much better - I can immediately tell the difference 💯

For my local environment I took a slightly different tack. As I have the two repositories (FE and BE) running locally, I just changed the CSS file in the FE repo. I probably could’ve set up a new Stylish rule for local development but that would also mean that I could be potentially changing the color of navbars of any websites that I run locally 😊


Color-coding 3rd party dependencies

On a similar vein, we are using an important third party dependency in our project - for which there exists a non-production environment (sandbox) and a production environment.

I used Stylish again to change the header bar of this site to be able to know which of our deployment environments are pointing to the sandbox dependency and which are using the production dependency.

A screenshot of the navbar of a third party dependency after color coding.
This is the sandbox version of the 3rd party dependency - for which my local (lilac), development (green) and qa (orange) environments are pointing to it. The production version of this dependency has a separate color scheme going on.

The CSS I used for the above looks like the following:


Color-coding database connections (using a JetBrains IDE)

To finish off this color-coding adventure, I wanted to color-code my database connections to match my deployment environments. I’m currently using the database management functionality in GoLand as my SQL GUI. Though I imagine all of JetBrains’s products function in much the same way:

Once a data source is added, simply right click on it and select ‘Color Settings’:

A screenshot of a menu in GoLand with the ‘Color Settings’ setting selected.

From there you can select your color, which will appear in various places - such as editor tabs and the ‘database explorer’.

And here’s what mine looks like:

A screenshot of the database explorer in GoLand with each of the connections being a different bright color.
Ow, my eyes, it burnsss… 🤭

Bonus: A Stylish rule for Pull requests

As a fun little project, I created a rule on Stylish to be able to easily determine which pull requests are mine on GitHub. Sometimes we have so many pull requests on the go at once that it’s not immediately obvious which belong to me!

A screenshot of the pull request page in GitHub with my Stylish rule active.
The Stylish rule I created to highlight my pull requests. Click here to download

I initially wanted to highlight the whole div in question though I’m not sure this is possible with straight CSS (as you can’t ascend the DOM with a selector). So instead I settled for highlighting my GitHub username - which does the trick.


In need of a back-end engineer for your project? Get in touch to hire me for contract work 💯