An Introduction to CI/CD

Take away from this article:

  • How to create a pipeline.
  • How to integrate docker with jenkins.
  • How to build docker image and push to docker hub.
  • How to deploy an application inside kubernetes cluster.

So, lets start by creating an simple application wriiten in html. Below is the code of the appliction. I have installed jenkins and minikube in different servers over aws as you can see below.

ec2-instances

Application Code:

Now lets create a Dockerfile. Below code will you to create dockerfile.

Dockerfile Code:

After creating docker image lets create jenkinsfile to create pipeline job in jenkins dashboard.

Jenkinsfile Code:

Adding GitHub Webhook in jenkins:

Adding Dockerhub credentials in jenkins:

Using Git as a SCM in pipeline script to pull jenkinsfile:

After saving the job run the job as soon as you commit the code from vscode then the jenkins pipeline will run automatically. Here how its look like.

Job run successfully:

Docker image pushed:

Application-Output:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store