A basic template for a Doppler microservice based on .NET with CI, CD, Code Formatting, Authentication, and other common practices in Doppler teams.
For the moment, it is only a kind of example. In the future, it could be converted into a Yeoman or dotnet new scaffolding template 🤷♂️.
We base our CI/CD process on Jenkins, Docker Hub, and Docker Swarm.
Jenkins generates the images based on .doppler-ci (a symlink to Jenkisfile). We refer to these generated images in a Docker Swarm using an auto-redeploy approach. The Doppler Swarm repository stores the configuration of our Docker Swarm.
You can find a detailed description of our Git flow and the relation with Docker Hub in Doppler-Forms repository, but basically, it is the following:
-
Pull Requests generates images with tags like
pr-177
(pr-{pull request id}
) and (pr-{pull request id}-{commit id}
). -
Merging in
main
(ormaster
in some repositories) generates images with tags likemain
andmain-60737d6
(main-{commit id}
). In general, these images are deployed automatically into the QA environment. -
Resetting the branch
INT
generates images with tags likeINT
andINT-60737d6
(INT-{commit id}
). In general, these images are deployed automatically into the INT environment. -
Tagging with the format
v#.#.#
generates images with tags likev1
,v1.3
,v1.3.0
,v1.3.0_982c388
. In general, our Production environment refers to images with tags likev1
(only the mayor), so, depends on that, these images could be deployed automatically to the Production environment.
The source of truth related to the build process is .doppler-ci (a symlink to Jenkisfile). It basically runs docker build, so, you can reproduce jenkins' build process running docker build .
or sh ./verify-w-docker.sh
.
If you prefer to run these commands without docker, you can read Dockerfile and follow the steps manually.
-
Base conventions for a .NET/C# project.
-
Normalize to Linux line endings by default for all files (See .editorconfig and .gitattributes).
-
Ignore from git and docker files with the convention that denotes secrets (See .gitignore and .dockerignore).
-
Prettier validation for all supported files.
-
Editor Config validation using
dotnet-format
andeclint
. -
Launch and debug settings for VS Code (.vscode) and Visual Studio (launchSettings.json).
-
Custom color for VS Code (using Peacock, see settings.json).
-
Format validation, build and test run in CI process.
-
Generation of the docker images following Doppler convention and publish them to Docker Hub (See build-n-publish.sh).
-
Generation of
version.txt
file with the image version inwwwroot
. Also, expose it using static files middleware. -
demo.http to easily add manual tests for the exposed API with VS Code REST Client.
-
Exposing only HTTP (not HTTPS) because that is the responsibility of our reverse proxy.
-
Allow overriding project settings based on our Doppler conventions.
-
Expose Swagger (with support for segment prefix).
-
Including an example of a self-hosting integration test.