Deploying Applications with CircleCI using Doppler
Tags: programming, tutorial, webdev
Published: 2021-10-08 00:14:31

##Summary

Integrating and deploying features for applications have always been hectic and there have been a lot of solutions over the years. CI/CD is one of such solutions as it seeks to make app development easier by automating most of the work and CircleCI is a modern CI/CD platform that aims to solve integration and deployment issues by providing a secure pipeline for continuous automation and monitoring of applications from integration to deployment.

##Goals

In this post, you will use a MERN stack app to learn how to integrate and deploy an application using CircleCI and we will also learn how to connect Doppler to our Circle CI pipelines. 

##What is CircleCI

According to its official [documentation](https://circleci.com/docs/2.0/about-circleci/),

*CircleCI is known as a continuous integration and continuous delivery (CI/CD) platform. 
CircleCI provides enterprise-class services, with the flexibility of a startup. 
It works where you work: macOS, Android, and Windows - SaaS or behind your firewall and automates build, test and deployment of software*.

CircleCi is a lightweight cloud-based CI/CD platform that modernizes integration and delivery practices by automating installation and deployment procedures. It can be maintained and configured without any hassles. It cuts down drastically on the cost of maintenance of a local server because it is cloud-based. And it is scalable and deploys applications faster. It doesn't require any initial set-up as it is cloud-based, and it has a beautiful and interactive UI that also undergoes frequent upgrades. 

CircleCI is also compatible with all languages and integrates with services like Docker, Slack, and Doppler.

CircleCI is open source and available on [Github](https://github.com/circleci).

##CI/CD with CircleCI

CI/CD is the fused practice of continuous integration and continuous deployment or delivery. It automates testing, building, and delivery of applications by bridging the gap between development and operation, and it works with a platform or pipeline.

CircleCI integrates and deploys by providing pipelines, and these pipelines surround the set of workflows you initiate on your projects. A Circle CI/CD pipeline automates the software delivery process, and it works in stages. And with its application level security combined with runtime isolation using containers, Integrating has never been safer. 

###Stages of CircleCI processes:
* **Building**: This is when the compilation of the application happens 
* **Testing**: This is the stage where automated tests are run to test and validate product behavior
* **Release**: This is when we deliver our applications to repositories
* **Deploy**: This is the stage where we deploy our application to production

A CircleCI CI/CD pipeline also comes with other benefits like speed, reliability and accuracy.


##Using Doppler for Secret management

[Doppler](https://doppler.com/) is a universal secret manager meaning you can use doppler to manage secrets across applications with less risk of vulnerability and ease of work. [Doppler](https://doppler.com/) makes it easy to share environment secrets for application and development with your team, and Doppler works for every language with a steadily growing list of integrations. It also eases integration with most of your cloud platforms, such as CircleCI. 


##Setting up and integrating a MERN stack app with CircleCI and Doppler

The prerequisites for following along and integrating our app in this tutorial is that:
  * We have created a project in Doppler
  * We have a CircleCI project and have access to set environment variables for that project


In this tutorial, we will set and integrate a MERN stack application with CircleCI and handle our app secrets with Doppler. 
Let's get started by first setting up and installing the Doppler CLI with the code below:
```
brew install dopplerhq/cli/doppler
```
Then we verify that we’ve installed Doppler CLI by running the command below to check the version of Doppler that we installed.
```
Doppler version 
```
The above command should show us that we have a version v3.32.0.
Next, we run the command below
```
doppler login
```

? Open the authorization page in your browser? (Y/n) 
By clicking Y, The command above will open your browser and prompt you to add your access keys
![ Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tmukwp1zlulc71tmp5hj.png)

Next, we set up our workspace which should look like the image above, then we create a project and add the project name and description and save which should look like image below:
![ Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sbg58zehgrwwhsghbuz5.png)

Next, we will navigate to the options button and click on create environment, and then we add our environment name as CircleCI and a short name as CI as shown in the image below:
![Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cu9i9bw0njoslsoomyjz.png)
Next we will import our secrets into our CircleCI config and then save it as shown in the image below:
![Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cetdbltbed7o0dsklivz.png)
After that, we then navigate to the Integrations tab, where we will now click on CircleCI as shown below:
![Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1jvcew4jmj6rn0ej7fx2.png)
Then we navigate to our project on CircleCI, where we will be given a personal API token:
![Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f50rsyc1jjnzorhkydkm.png)
We copy the token and paste it into Doppler, and then we click on connect:
![Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/le4rhzi80qnrx06i2b9o.png)
Next, we select our CircleCI project from the dropdown menu, and we config to sync by clicking on our app name in our CL environment, and then we connect on to set up integrations shown below: 
![Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s45refqrr06gke9ibe1n.png)
And then we are all set. Doppler will immediately and continuously sync our app secrets to all our project’s environment variables on CircleCI.
![Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cgenuhweobrpqfalhvq.png)

##Conclusion
We have successfully set up Doppler for our MERN stack application to secure our apps secrets, and we also integrated with CircleCI. We have shown how to reduce risks by eliminating the need for .env files. You can learn more about Doppler and CircleCI integration [here](https://docs.doppler.com/docs/circleci).