Learn how to setup continuous integration for all 5 Parts Unlimited MRP microservices and Front end webserver utilizing CircleCI. This builds and unit tests the code, creates 6 docker images, and pushes the images to a private docker Azure container registry.

Prerequisites

  1. A personal GitHub account
  2. A personal CircleCI account

    Note: Signup using your personal GitHub account and be sure to allow CircleCI access to your personal repository.

  3. An existing Kubernetes cluster and docker private registry This is covered in tasks 1-2 of the Deploy to AKS with K8s using Helm HOL

Tasks Overview

  1. Fork the GitHub repository
  2. Configure CircleCI
  3. Trigger a CircleCI Build

Task 1. Fork the GitHub

Step 1. Fork the repository to your personal GitHub repository.

Task 2. Configure CircleCI

Step 1. Configure CircleCI to build the forked project.

Go to Projects - your-GitHub-repo - Setup project - PartsUnlimitedMRPmicro - and then click “Start building”

Note: The build will fail with the error message below due to a bug with CircleCI. This will be automatically resolved in Task 3 below.

Build-agent version 0.0.4533-8b7c530 (2017-11-10T23:59:33+0000)
Configuration errors: 1 error occurred:

* Cannot find a job named `build` to run in the `jobs:` section of your configuration file.
If you expected a workflow to run, check your config contains a top-level key called 'workflows:'

Step 2. Add ENV variables for Azure Container Registry

In the CircleCI dashboard, go to Settings - Environment variables and then add the following environment variables:

  • DOCKER_USER - the ACR admin username
  • DOCKER_PASS - the ACR admin password
  • REGISTRY_NAME - the ACR base URL i.e. pumrpmicro.azurecr.io
  • REGISTRY_NAMEIMAGE - this is the same as REGISTRY_NAME and is present as a separate variable so this same code can be used to push these images to docker hub on the root repository.

Task 3. Trigger CircleCI Build

Go to the .circleci/config.yaml file in the root of the repository and make a single insignificant change to the file and git push it to your forked repository. For instance add a # comment character on a new line.

Now go to the workflow section and see all of the successful completed jobs. The code has been built, unit tested, docker images built, and pushed to ACR.

Now all of these images could be deployed to any Kubernetes cluster from ACR using the helm chart in the repository under /deploy/helm/partsunlimitedmrp.

Note: In a production environment each of these 6 projects would be broken into 6 GitHub repositories and each have their own pipeline. All code has been combine into a single repository for ease of management as an example demo project.

Conclusion

This lab walked through how to completely automate from check-in of code to build and test all the microservices and push the docker images to Azure Container Registry. Next, consider completing the HOL on Fluentd, Prometheus monitoring, or Open Tracing.