DevOps Project from absolute zero | Project setup + CI Pipelines implementation
In this blog we will set up CI build pipelines from github
-- Open the below github repository
https://github.com/dockersamples/example-voting-app
--Sign in to the azure devops and create a new project
-- Go to repos option and paste https url copied from github.
-- After successfull import, we need to make the main branch as default branch
-- Go to the branches option and select main branch as default
Creating Container registry
--Login to azure portal>container registries>create new container registry
Creating build pipelines
--Go to the pipelines option and create a new pipeline
-- Select azure repos git>select github repository name>select build and push an image to azure container registry
-- select the subscription and created container registry
-- I f we want to trigger continuously whenever any new code is commited then we need to add paths under trigger section of the code
-- change the image repository name as we are doing it for only result app give it as "resultapp"
--remove the agent and give below lines
agent pool name and we have to create VM with same name in azure portal
--Now go to the stages section and change the display name as build... as we are doing only build pipeline, remove pools
--Click on the settings button , change the command to select only build and in docker file path select result/Dockerfile and click on add button
-- Copy the stage and paste the same for push stage and change the display names, command as push in settings
--When you click on save and run we will get an error as VM with name azureagent is not created
-- Create a VM with name azureagent in the same rg
--now we need to connect to th vm connected to our azure devops
-- you can search it on google for azure devops pipeline documentation>go to agent pools configuration>self hosted linux agents and follow te steps
--Go to project settings>add pool>self hosted agent>give name and click on create
-- Click on add an agent in the agent pool and select linux
--Connect to the VM using the below commands
open terminal>do to downloads folder and
ssh -i key pair name with userame@public ip address
-- update the VM with sudo apt update and run below command
mkdir myagent && cd myagent
then wget and copy the download agent hyperling and paste
and run the below command
tar zxvf vsts-agent-linux-x64-3.234.0.tar.gz
./config.sh
--For server url go to te documentation and copy the server url
-- in place of organization name , place your organization name
https://dev.azure.com/yasmeenkhans230
it will ask for PAT token
-- generate PAT by clicking on user setting icon>pat>new token and give it in the terminal
--give agent pool name
-- go and see whether agent is added or not , it will be added, but it will be offline
-- to make it online run run command
./run.sh
-- Install docker now with the following command
sudo apt install docker.io
sudo usermod -aG docker azureuser
sudo systemctl restart docker
-- execute the ./run.sh command and run the build pipeline
if we get any permission denied error then logout and login back and run the ./run.sh command again and run the pipeline
likewise do it for workers and voting application as well