Skip to content

jsperatan/ibm-assignment-pipelines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

IBM Assignments - DevOps, CI/CD Pipelines

Components

  • Docker
  • Jenkins Server (http://54.254.172.152:8080/) - Address subjected to change as I am currently using the Free Tier AWS which may occassionally go OOM. Please contact me if URL is not accessible. Credentials are sent separately
  • Docker-in-Docker (DinD)
  • Docker Hub Account and Repository

Pipeline Summary

  1. Pull source code from Github repository
  2. Build Docker image and tag it accordingly
  3. Run the Docker image so that it can be used for additional testing
  4. Sleep for 10 seconds just to make sure application is ready to accept connections
  5. Test REST endpoints
  6. Login to Docker Hub
  7. Push Docker image to Docker Hub
  8. Clean up - Stop and remove running container, remove images and logout from Docker Hub

Setting Up

  1. Launch AWS EC2 Instance for hosting Jenkins server
  2. Run Jenkins as Docker Container
  3. Running DinD - Execute the following command from the Jenkins server host: sudo docker run --name jenkins-docker --rm --detach --privileged --network jenkins --network-alias docker --env DOCKER_TLS_CERTDIR=/certs --volume jenkins-docker-certs:/certs/client --volume jenkins-data:/var/jenkins_home --expose 5656 --publish 2376:2376 --publish 5656:5656 docker:dind --storage-driver overlay2
    • I have added an additional step to test the REST endpoint before pushing the images to Docker Hub. Due to this, it is required to also expose port 5656 from the DinD container so that it can be reached from the Jenkin server container
  4. Access Jenkins UI (http://54.254.172.152:8080/) and login using the given credentials

Creating CI/CD Pipelines

  1. From the Jenkins Dashboard, select "New Item" from the sidebar
  2. Enter the item name and select "Pipeline". Click "OK" to confirm

image

  1. From the "Configure" page, select "Advanced Project Options" from the sidebar. Under the "Pipeline" tab, copy the content from the Jenkinsfile into the script box
    • While the recommended approach would be to reference the Jenkinsfile instead of inputing the content within the script field, I opted for this approach due to the simplicity of the pipeline configuration. May improve this in future if there is a need to

image

Adding Docker Hub Credentials

  1. Login to your Docker Hub account
  2. Select your profile and open "Account Settings"
  3. From the "Account Settings" page, open "Personal access tokens" under the "Security" Tab
  4. Enter a description for the access token and enable "Read & Write" permissions
  5. Copy the displayed access token
  6. Navigate to the "Home" page of the Jenkins server. Under the sidebar, select "Manage Jenkins"
  7. Select "Credentials". Under the "Credentials" tab, select "System"

image

  1. Select "Global credentials (unrestricted)"
  2. Enter your Docker Hub username into the "Username" field and paste the newly created access token into the "Password" field. Save the credential

image

Running Pipelines

  1. From the Jenkin Dashboard, select the newly created Pipeline
  2. From the sidebar, select "Build Now"
  3. Monitor build status from the "Build History" tab

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published