MLOPS TASK 1 : CI & CD with Manual Integration and Testing using Github Jenkins and Docker
Task Instructions :
- JOB 1 : If Developer push to dev branch then Jenkins will fetch from dev and deploy on dev-docker environment.
- JOB 2 : If Developer push to master branch then Jenkins will fetch from master and deploy on master-docker environment. Both dev-docker and master-docker environment are on different docker containers.
- JOB 3 : Manually the QA team will check (test) for the website running in dev-docker environment. If it is running fine then Jenkins will merge the dev branch to master branch and trigger #job 2.
Application Used
- Git
- GitHub
- Jenkins
- Linux
- Docker
Procedure :
Task 1 :
Step 1 : Create a local repository with web code using git.(Stage It and Commit it)
commands:
git init # to initialize repository git add . # to stage all files in the folder git commit . -m "comment" # to commit all files
Step 2 : Now we push the repository from workspace to GitHub.
git push -u origin dev # to push to dev branch on GitHub
Step 3 : Now we create a job in Jenkins named as "dev_code_deployer" which clone repository data from GitHub and create a docker container for testing environment and deploy the website on the container.
The configuration of the job 1 "dev_code_deployer" is shown in these screenshots.
Step 4 : Now we create the webhook on GitHub by tunnel the jenkins using ngrok.
Step 5 : Now we once manually build the job and check the configuration.
Hence, the Job 1 is successfully created and configured. Now we configure Job 2 for master branch similarly.
Task 2 :
Step 1 : Create file and stage, commit the files by using git.
Step 2 : Now push the master branch of local repository on GitHub.
Step 3 : Now we create Job 2 "Master_code_deployer" with following configuration.
Step 4 : Now we manually build the job and check the configuration.
Hence, the Job 2 is successfully created and configured. Now we configure Job 3 for merging dev branch with master branch after manual testing of dev branch code on dev_docker testing environment.
JOB 3 :
Now for job 3, we create a job named as "code merger", which merge the developer branch code after testing with master branch code and trigger job 2 again for deploy fresh resultant. The configuration of job 3 is as follows :
Now we manually build the job 3 and our dev branch merged and deployed over master environment.
Hence, our environment is fully setup. Now we test it with one use case.
Use Case :
We consider a website which need to be deployed, so first devloper write code and push it over GitHub. As our setup is already setup, so job 1 deploy the website on developer or testing environment, where QA team anlayse the app, if they find it good then they trigger the job build by given link :
JENKINS_URL/job/github%20Developer/build?token=TOKEN_NAME
and the code updated by merge with master branch and deployed successfullt over production (master) environment.
Practical :
Copy the webcode and paster to git repository.
Now add (stage) all the files with command
git add . # to stage files
and commit files using command :
git commit . -m "comment"
Now push code to github by " git push " command. Due to GitHub webhook the job 1 automatically trigger and website deployed over testing environment.
When QA team approve the job 3 is triggered.
The background running docker containers are shown below.
So thanks Guys. That's all. By this we can crate our environment. We will meet in my next task.
Thank You !!!!!!!!!!!!!!
Special thanks to Vimal Daga Sir. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
GitHub : https://github.com/kush95300/Mlops_Task1