How to manage CI/CD efficiently with CircleCI?
Continuous integration & deployment(CI/CD) is one of the well-known standard practice in modern-day software development. In a fiercely competitive world, businesses are relying on much more frequent feature releases to target customers. Recently, I came to know about CircleCI which is one of the excellent tools for achieving CI/CD efficiently. In my experience, the following CircleCI tagline is entirely apt:
Automate your development process quickly, safely, and at scale.
In this post, I will be sharing how to build and deploy Docker images using CircleCI quickly.
Introduction to a CircleCI config file
First, enable CircleCI webhook for your public GitHub repository. CirclecCi expects
config.yml in the
.circleci sub-folder of the project root directory. Config file should follow the rule specified here. CircleCI config file consists of three basic definitions as follows:
- version — configuration file version. Commonly used versions are 2 or 2.0
- workflow — defines the complete workflow of continuous integration and deployment. Workflow can have multiple jobs.
- jobs — contains the list of steps/commands to be run.
Building and publishing Docker image
- Define simple workflow using
workflowstag for building and deployment of docker image. In workflow definition,
filterscan be used for specifying
branchesthat are used for running a job. For example:
jobscan be a single step or multiple steps. Steps execute sequentially, for example, build a Docker image and deploy to the docker registry. Below are few basic configurations required for baking docker image
setup_remote_docker, define docker environment for building docker image.
working directory, the folder where a code copied for running build commands.
- Environment variables, for saving credentials and other build parameters securely. Refer below the code snippet for the job definition
View complete config file here
Originally published at gist.github.com.