Docker Image deployment to App Service in multiple environments | Multi stage docker deployment

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends my name is vini tarora and you are watching azure devops series in our last session we have seen that how to create an image and how to push it to container registry and how to deploy it to a web service right now in this session we are going to see that how we can deploy these images these how we can push these images as per our different environment because we may have the different environment we may say as stages for example let me show you we may have the development environment we may have the qa environment and we may have the production environment the development environment will have the different app service qa environment will have a different app service and production will have definitely different app service now we need to deploy these deploy our code we need to deploy our we need to push our images there as per the branch so in our code repository till now we have seen that we had only one repository that was master or main branch and here what we are going to do we are going to have the two branches one is the dab branch and one is the master branch or main branch right now as per the our branch name we will deploy it to the specific environment let me explain you from here as well uh here we will have the two app service one app service with the devops service one will be the q app service we will deploy our code we will uh we will create our image right we will build our maze from the different branches and as per the branches we will tag it right and when the question will come to deploy it we will see okay from which branch this particular image has been built and as per that we will deploy it right if the source branch is ma dab then we will deploy it to the dav app service if the source branch is qa then we will deploy it to the q app service so here we are going to cover three things one we will tag the image as per our branch name we will create one more environment that is a qa app service we are going to create and we are going to see that how we will deploy it as per our branch name so let's start before starting let me just request you that if you are not subscribed to my channel please subscribe and if you like this video please like thank you okay let's proceed so let's jump directly to the portal so this is our app service that we created in our last session right this is our container registry even acr in this content registry let me show you the repositories here we have the repository name as amaze this is uh vin even techno slash docker hello world flask this is the repository name and there further we have the tags let me show you the code of azure devops as well that how we have done it so first of all we have created task that is built on image inside the build animates we have tagged it as image build repository name and then build id right so as a first step we are going to tag it as per the branch name okay so how we will do that let me show you we have a uh s we have a existing an a variable name that for example here we have the build.repositoryname so we have the system variable n let me show you that what is that that is a branch.source name right so what i will do uh i will copy this see the the content which is coming after colon this is the tag right so let me add right and build.build id instead of build.build id let me add build.sourcebranch name so as per the branch name this will tag it right okay so now this particular this this particular pipeline will create an image as per this image name repository name ms hyphen repository name then branch name then hyphen build id okay now let me replicate this to push an image as well okay okay i have copied it here as well now this is my deployment section where i am going to deploy it so let me update this as well so now this is done okay let me save it let me show you the content registry once again so here we don't have tags right sorry here we have the text but we don't have the tag as per our branch name right let me show you the uh tags as well the branch as well so this is my repository here i have the two branch main branch and dive branch okay so here what i'm going to do i'm going to run it now i'm going to queue it with main branch run okay let's see what will happen now this is building and this may take some time okay so uh this pipeline has been completed and we have got an image right and this is the image name vinewin techno slash docker hello world flask then main hyphen 55 this is the build id and this is a branch name now let me jump to here this one let me refresh it this is the repository in the portal so now you can see we have a new tag that is main hyphen 55 55 is the build id and main is the branch name okay in a similar way what we will do we will build it with div branch as well so once we will build it with dive branch we will have the tag as dav hyphen 56 okay so this is the first step that we have seen now as a second step i have i was updating you here so here we have seen that uh we are going to create one more app service till now we had the only one app service that is uh this right even docker dev now i am going to create one more that will be even docker qa okay let me create it resource group is this let me a win docker dab dab is already exist i'm going to attach qa now this will be docker container this will be linux based and location is india central india okay so i have already created an linux plan so that will come here i have chosen this by default now let me click on docker so here in the docker i what i need to do i need to provide my image so what i will do i will click here as an image source as your container registry and here the registry name will come as the avenue cr image name is coming as the same now i need to select a tag the tag that i am going to select is this the latest tag main 55 right and now let me just create it okay so our next app service is ready that is even docker qa let me browse it if you want to know the logs we can simply go here and can browse it that what exactly is happening here in the site the log stream and here you can see this is ready hello world this is flask here version 209 right and this is the log that you can over okay our app service has been started okay so this was the second step now as a third step i need to deploy it right and how i am going to deploy it let me jump to the azure devops here i have the pipeline let me edit this pipeline so till now we have seen that okay these are the third task in which we need to deploy right and here we need to choose the app service name here the app service name we have chosen the docker dab now what i need to do i need to replicate it what i am going to do i am clone this task right and after cloning what i am going to do i am going to rename the first one as even deploy even docker dab and the second as even docker qa okay so this was the part of renaming now what i need to do i need to uh i will go to the first task and there i will check this even docker qa and the second task sorry i will choose it even dab itself in the second one i will choose it as a even docker qa so now whatever it will do it will deploy the same image to both of these but we don't want this we are looking to have this condition that i was showing here if branch name is dev then deployed to dav app service if branch name is main then deployed to qa app service right so what i need to do i just need to add a condition here i will go here i will choose the control option inside the control option what i will do i will choose this condition here as a custom condition and inside the custom condition i just need to paste this particular command or condition here as equal to so here what it will do it will check that if these two variables are same two values are same the first value is the variable bill dot source branch name if the branch name is tab then this will deploy this will run otherwise this will not run right so now what i need to do i need to copy this and need to do the same thing here in this particular control option here in the control option i need to choose the ah custom condition once again and here i need to update the branch name that is main okay now i need to save it so the save part is done and let's run it so what when we are going to run it uh this time let me deploy it with dive branch so we have seen already here in our container registry that we had one tag that was main dot 55 and this time we are going to do with dab so let's run it let's see what will happen okay so our pipeline has been executed and let me show you from the jobs that we have created to deploy tasks one was this div and one was with qa as you can see from here the task that was with dev has been executed but the task which was with qa has not been executed the reason behind this that the condition didn't match condition was that it should be branch name should be main and the condition for it was the branch name should be dab right because we had deployed we have built it we have created our remains with the tab run so that's why this got executed and this doesn't okay now let me go to here and let me show you here we have the two things one was with qa and one was with uh dab right so now you can see the version are same booth here right but you will not be able to identify easily although we have recently deployed this particular dev right let me sorry let me add that here right the version is same 209 we had deployed 209 but on qa so because both were the same version now there will be some situation okay you may say how we will identify okay from the dive branch because the content is same both here so our word that confusion what i am going to do i am going to do some changes in my dive branch here let me explain from here right so we have the dive branch via the master branch and once we will merge it to dab to master then this will be deployed to qa so let me just show you the dive branch here i will update the code of dav branch okay and then i will deploy it okay so this is my dev branch let me go to the server.pi and here let me just edit this here you can see uh the version is 209 let me edit this the version is now 2010 i am going to save it okay this is done now i am going to publish it once again basically the build it once again you can say here i am going to run it once again the branch name is tab okay running it now okay so this is completed once again right and this time we have the tag as dab 57 let me go here and let me just refresh this this is my qa and this is my dev let me refresh this so now you can see the version has been changed to 0 10 this is in our dev now in our qa let me refresh it this is still 209 because we have deployed it to dav only right so we have seen that how we can deploy it as per our branch name now if the situation comes we need to buy and build the image from the qa branch so what the developer will do they will merge the merged dial branch this one they will merge the dive branch to master branch via pr and once our code will be master branch then we will build it from the master branch and then our code will be deployed so i hope this session was fruitful for you and you have gained the knowledge that how we can deploy it as per our branch name okay so in our next session we are we will also see that how we can do the manual intervention when we are going to deploy the same code from queue environment to production moment right in that situation basically we are not in need to build it once again and this is the general scenario that we follow okay so uh let us conclude here and we will meet our next session thank you bye bye a good day
Info
Channel: Avin Techno
Views: 5,042
Rating: undefined out of 5
Keywords:
Id: wrQrbLZvExs
Channel Id: undefined
Length: 15min 34sec (934 seconds)
Published: Sat Aug 13 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.