DevOps(Day-80): Project-1

TABLE OF CONTENTS

Project Description

The project aims to automate the building, testing, and deployment process of a web application using Jenkins and GitHub. The Jenkins pipeline will be triggered automatically by GitHub webhook integration when changes are made to the code repository. The pipeline will include stages such as building, testing, and deploying the application, with notifications and alerts for failed builds or deployments.

Pre-requisites

Creating AWS instance

  1. Navigate to the AWS management console and provide the server name and choose the OS.

  2. Select the instance type to configure the CPU and memory of the instance.

  3. Choose the existing or create a VPC for the server.

  4. Select the disk size for the server to be attached.

Configure Docker and Jenkins on the server

  1. Write all the commands to pre-install Docker and Jenkins on the server after its spin-up.

  2. Now create the instance.

  3. Login to the server and use systemctl command to check if docker is running.

  4. Now, use systemctl command to check if Jenkins is running.

  5. Open the port 8080 which is the default port to run Jenkins on the server.

  6. Navigate to the URL http://<publicIP>:8080

    Navigate to the path and paste the admin password for first-time login to the Jenkins server.

  7. install the suggested plugin on the server.

  8. You can change the userID and password.

  9. Now, Jenkins is ready to use. We are finally landed on the dashboard of Jenkins.

Project steps: Automating pipeline of a Webapp

  1. On the Jenkins home page select the New Item.

  2. Write the project name and select the free-style project.

  3. Navigate to GitHub and take the project URL and provide in the Jenkins configuration.

  4. To configure automation of deployment we need to install the plugin on Jenkins.

  5. Navigate to Manage Jenkins and go to plugin and the available plugins. Install the plugin now.

  6. Navigate to GitHub and select Webhook. Use the below payload URL.

    http://<publicIP>:8080/github-webhook/

  7. Generate the public key of the server.

  8. Create the SSH Key in the GitHub and provide the public key of the server.

  9. Now, generate the personal access token of GitHub to connect GitHub to Jenkins.

  10. Navigate to GitHub settings and create the token.

  11. Add the credential to Jenkins to create the key.

  12. In the Branches to build provide the main branch. Make sure to check the branch where the project currently needs to be deployed.

  13. As we have setup the webhook previously, now select the webhook settings in the project configuration section in the Jenkins dashboard.

  14. Select the execute shell in the build steps.

  15. Build the image and create the container through docker on the Jenkins pipeline.

  16. Now, build the project. Check the console output to view the status.

  17. Navigate to the URL and check for the web-application.

Thanks for reading my article. Have a nice day.

WRITTEN BY Biswaraj Sahoo -- | DevOps Engineer | Docker | Linux | Jenkins | AWS | Git | Terraform | Docker | kubernetes

Empowering communities via open source and education. Connect with me over linktree: linktr.ee/biswaraj333