1. Introduction
Hello! We are a writer team from Definer Inc.
In this issue, you are wondering about the use of the importance of CI/CD.
Let's take a look at the actual screens and resources to explain in detail.
2. Purpose/Use Cases
This article provides a collection of information and practices that you may find helpful when you want to understand CI/CD.
3. What is CI/CD?
CI/CD stands for Continuous Integration / Continuous Delivery.
CI/CD does not refer to a specific technology, but rather to a software development methodology that automates testing and deployment.
CI/CD enables early detection of bugs and automation of manual tasks to improve work efficiency.
What is CI (Continuous Integration)?
Integration in this case refers to build (the process of creating an executable file based on source code) and testing.
Automated builds and tests continuously check the behavior and quality of the program, allowing for quick modifications.
What is Continuous Delivery (CD)?
In this case, delivery is used in the sense of publication or delivery.
In other words, making the application available to users.
Continuous delivery allows for faster development spans.
Here are some specific use cases where implementing CI/CD can be highly beneficial:
Frequent Code Changes:
When a development team is frequently making code changes, manually building, testing, and deploying each update can be time-consuming and error-prone. CI/CD automates this process, ensuring that changes are quickly and consistently deployed to production.
Multiple Developers and Teams:
In projects with multiple developers or development teams working on different components, CI/CD helps maintain a shared codebase and reduces integration challenges. It ensures that changes from various contributors are continuously integrated and validated.
Large and Complex Projects:
In complex software projects, CI/CD can help identify integration issues and bugs early in the development cycle. Frequent automated testing ensures that the codebase remains stable and functional, even as the project grows.
High-Quality Software Releases:
CI/CD encourages the use of automated testing, which improves the overall quality of software releases. Automated tests help catch bugs, regressions, and compatibility issues quickly, leading to more reliable software.
Rapid Deployment:
CI/CD enables faster and more frequent deployment of new features and bug fixes. This agility is essential in competitive markets, allowing companies to respond quickly to customer needs and stay ahead of the competition.
Microservices Architecture:
In a microservices-based architecture, where numerous independent services work together, CI/CD ensures smooth integration between these services, reducing deployment complexities.
Cloud and DevOps Environments:
CI/CD is often a crucial practice in cloud-based and DevOps environments. It complements cloud services and accelerates the deployment of cloud-native applications.
Scaling Infrastructure:
For applications that need to scale dynamically based on demand, CI/CD can automate the process of deploying and managing additional resources to handle increased traffic.
Reducing Deployment Risks:
Manual deployments increase the risk of errors and downtime. CI/CD minimizes these risks by automating the process and allowing for fast rollbacks in case of issues.
Automating Configuration Management:
CI/CD tools can manage configuration files and environment setup, ensuring consistency across different deployment environments.
CI/CD can be broadly divided into cloud and on-premise delivery:
Cloud-based
Cloud-based CI/CD services include CircleCI, GitHub Actions, Azure Pipeline, and AWS CodePipeline, which we also use.
Cloud services are not as scalable as on-premise services, but the advantage is that they can be used immediately at a low cost, without the need to prepare servers on your own.
Cloud-based CI/CD solutions are especially beneficial for organizations that want to avoid managing and maintaining on-premises infrastructure and prefer a more scalable and pay-as-you-go model.
The applications of cloud-based CI/CD are vast and diverse, spanning across various industries and development scenarios. The flexibility and scalability of cloud-based CI/CD make it an indispensable practice for modern software development and deployment.
Here are some more common use cases:
- Mobile App Development
- Microservices Architecture
- IoT Device Firmware Updates
- E-commerce Platform Updates
On-premises
On-premises CI/CD refers to setting up and maintaining the CI/CD pipeline within the organization's own data center or physical infrastructure.
The on-premises approach provides more control over the infrastructure, data, and security but may require higher upfront costs and ongoing maintenance.
Jenkins is a well-known on-premises CI/CD service.
While the on-premises type is highly scalable, it is also costly because it requires the client to build and operate the system on their own.
Here are some specific scenarios where on-premises CI/CD is commonly used:
- Data Security and Compliance
- Legacy Systems and Infrastructure
- Air-Gapped Environments
- Data Sensitivity and Intellectual Property Protection
- Latency and Performance Requirements
- Regulatory Restrictions
4. Benefits of CI/CD
The following are some of the advantages of CI/CD
Reduction of development man-hours
CI/CD automates build, test, and deployment, which used to be handled manually, and reduces man-hours required for development.
In addition, the probability of finding bugs at an early stage is increased, which reduces the number of major rework, which also contributes to the reduction of man-hours.
Accelerated Development
Automation of build, test, and deployment through CI/CD allows engineers to concentrate on their core work of coding.
In addition, the cycle of releasing services to the market is accelerated, enabling development that is more in line with customer requests.
Quality Improvement
Test automation is expected to improve program quality by reducing human error.
Another important aspect of quality assurance is that since tests are executed frequently and on a mechanical basis, the probability of finding and fixing bugs at an early stage is increased.
5. GitHub & GitHub Actions
GitHub Actions is a powerful continuous integration and continuous deployment (CI/CD) platform provided by GitHub. It allows developers to automate various tasks, workflows, and processes directly within their GitHub repositories. With GitHub Actions, you can set up automated build, test, and deployment pipelines to streamline your development workflow and improve collaboration among team members.
Let's walk through a simple example of setting up a CI/CD workflow using GitHub Actions for a Node.js web application, we will build and push a Docker image to Docker Hub.
(1) Prepare the secrets
Go to your GitHub repository's Settings > Secrets and add two secrets:
DOCKER_USERNAME
: Your Docker Hub username.DOCKER_PASSWORD
: Your Docker Hub password or access token.
.github/workflows/
directory in the repository, create a file named push-docker-image.yml
This file will define the workflow to build and push the Docker image: name: Push Docker Image
on:
push:
branches:
- main
jobs:
push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${your-docker-username}/${your-docker-repo}:latest
Workflow Explanation:
Make sure to replace
(3) Run the workflow
Commit and push the changes to your main branch. This will trigger the GitHub Actions workflow.
You can check your workflows in GitHub "Actions" tab.
- The
on
section specifies that the workflow will run when there is a push event to the main branch. - The
push
job is responsible for building and pushing the Docker image. It checks out the code and sets up Docker Buildx, which is a Docker CLI plugin that extends the capabilities of the Docker build command. - The
docker/login-action
is used to log in to Docker Hub using the credentials you set as GitHub Secrets. - The
docker/build-push-action
is used to build the Docker image from the Dockerfile in the current directory (context: .
) and push it to Docker Hub with the specified tags (your-docker-username/your-docker-repo:latest
).
Make sure to replace
your-docker-username
and your-docker-repo
with your actual Docker Hub username and repository name.(3) Run the workflow
Commit and push the changes to your main branch. This will trigger the GitHub Actions workflow.
You can check your workflows in GitHub "Actions" tab.
6. GitHub & CircleCI
CircleCI is a popular CI/CD platform that automates the software development process. It allows developers to build, test, and deploy applications efficiently. With customizable workflows, seamless integration with version control systems, and a wide range of supported languages and frameworks, CircleCI enables secure and scalable development, making it accessible and beneficial for teams of all sizes.
GitHub and CircleCI are complementary tools that work together to streamline the software development process, providing continuous integration and continuous delivery (CI/CD) capabilities.
Let's walk through an example of setting up a CI/CD pipeline using GitHub and CircleCI to build a Docker image and push it to Docker Hub.
(1) Prepare the secrets
Go to your GitHub repository's Settings > Secrets and add two secrets:
DOCKER_USERNAME
: Your Docker Hub username.DOCKER_PASSWORD
: Your Docker Hub password or access token.
.circleci/
directory in root repository, then inside it, create a file named config.yml
. This file will define the CI/CD pipeline.
version: 2.1
jobs:
build:
docker:
- image: circleci/node:14
working_directory: ~/my-nodejs-app
steps:
- checkout
- setup_remote_docker:
version: 20.10.8
- run:
name: Build Docker Image
command: |
docker build -t $DOCKER_USERNAME/my-nodejs-app:latest .
- run:
name: Push Docker Image to Docker Hub
command: |
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
docker push $DOCKER_USERNAME/my-nodejs-app:latest
workflows:
version: 2
build-and-deploy:
jobs:
- build:
filters:
branches:
only: main
Workflow Explanation:
(3) Run workflow
Commit and push the CircleCI configuration
Login to CircleCI and see your pipelines.
- The
config.yml
file defines the CI/CD pipeline using CircleCI's configuration syntax. It sets up a Docker environment with Node.js 14 and runs the build and push steps inside the container. - The
build
job uses Docker to build the Docker image from theDockerfile
in the current directory (~/my-nodejs-app
) and tags it with your Docker Hub username and thelatest
tag. - The
setup_remote_docker
step sets up the connection to the Docker daemon in the CircleCI environment so that the build step can run Docker commands. - The
run
steps use Docker to build the image and push it to Docker Hub using the credentials provided as GitHub Secrets. - The
workflows
section specifies a workflow namedbuild-and-deploy
, which runs thebuild
job only when changes are pushed to the main branch.
(3) Run workflow
Commit and push the CircleCI configuration
.circleci/config.yml
file to the main branch on GitHub. This will trigger CircleCI to run the CI/CD pipeline automatically.Login to CircleCI and see your pipelines.
7. Cited/Referenced Articles
Troubleshooting CI-CD, Azure DevOps, and GitHub Issues ...
What is CI/CD? Explaining the advantages, disadvantages, and pipeline applications.
How CircleCI Orb was the best - Sansan Tech Blog
What is CI/CD - Continuous Integration/Continuous Delivery|Red Hat
What is CI/CD | Nifcra
Understanding all the super important rules in GitLab's CI/CD | DevelopersIO
8. About the proprietary solution "PrismScaler"
・PrismScaler is a web service that enables the construction of multi-cloud infrastructures such as AWS, Azure, and GCP in just three steps, without requiring development and operation.
・PrismScaler is a web service that enables multi-cloud infrastructure construction such as AWS, Azure, GCP, etc. in just 3 steps without development and operation.
・The solution is designed for a wide range of usage scenarios such as cloud infrastructure construction/cloud migration, cloud maintenance and operation, and cost optimization, and can easily realize more than several hundred high-quality general-purpose cloud infrastructures by appropriately combining IaaS and PaaS.
9. Contact us
This article provides useful introductory information free of charge. For consultation and inquiries, please contact "Definer Inc".
10. Regarding Definer
・Definer Inc. provides one-stop solutions from upstream to downstream of IT.
・We are committed to providing integrated support for advanced IT technologies such as AI and cloud IT infrastructure, from consulting to requirement definition/design development/implementation, and maintenance and operation.
・We are committed to providing integrated support for advanced IT technologies such as AI and cloud IT infrastructure, from consulting to requirement definition, design development, implementation, maintenance, and operation.
・PrismScaler is a high-quality, rapid, "auto-configuration," "auto-monitoring," "problem detection," and "configuration visualization" for multi-cloud/IT infrastructure such as AWS, Azure, and GCP.