GITLAB CI CD FULL COURSE IN 3 HOURS | Gitlab CI CD From Zero To Hero

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello friends welcome back to my channel and we are back with another complete or full course so this will be a gitlab CI CD full course where you can become a hero from xero so if you're a beginner or you know if you want to have a crash course so this will be a course of approximately three hours where I'll be talking about the complete uh gitlab cicd topics so without uh no further Ado don't have to waste much time so let's get started on you know what will be covering as part of this gitlab cicd tutorial so let's talk about the agenda so we'll be talking about a cicd Basics what is continuous integration what is continuous delivery what is continuous deployment so this will be the basic concept of CI CD and we will be talking the difference you know CI versus CD verses and CD so there are two CDs continuous delivery and continuous deployment right and we'll also talk about gitlab cacd Basics and then we'll move on to to what is SSH because secured shell is you know a little bit important here because we need to create SSH key and you have to integrate with gitlab so we'll talk about how to do all those cicd SSH configurations and we'll also talk about gitlab Runners so we in gitlab cicd we have Runners so we will talk about gitlab Runner and how to set up gitlab runner on Windows and also how to install gitlab Runner or Linux so then once we have the basic setups ready then we will move on to starting about gitlab cicd so we will see how to create the CI CD pipelines the basics of that and how to set up uh you know a different kind of pipelines in gitlab we'll also see a project with Maven so how to build a maven project in gitlab cicd pipeline so in that Maven project we'll be talking about Maven life cycle you will also talk about how to use Docker in the cicd pipeline also talk about get light cacd templates we will also see you know what is a Docker registry because uh when you use Docker you know in gitlab you can use Docker Hub or you can have different kind of registry so in gitlab we have something called container registry so we will talk about that and how to use that in the gitlab cicd docker build and pushing so we'll see a complete tutorial on how to use gitlab cicd pipeline to push a Docker image to gitlab container registry then we will also see a gitlab node.js CI CD pipeline so that you know you'll see how we can deploy a node.js application using gitlab cicd as well then you know as some bonus videos so that that you know till that time it will have a cover almost all the topic which you want to understand about gitlab cicd now to give you some bonus topic we'll also have some discussion about git versus GitHub versus and gitlabs always there are confusion like what is git what is GitHub what is gitlab okay we'll also see how we can install your own gitlab on Docker or if you want to set up on gitlab instant Zone send OS so all these things you will also cover now let's get started with the basics and cicc CD versus CD and we will see how to get started with your gitlab topic and don't you know skip this topic uh watch till end of the video so that you'll have a complete overview on gitlab cicd so you don't have to use Jenkins always you can go for other Alternatives like GitHub or gitlab CA Series so you can make use of this for uh you know end to end you know your CI to CD so you will see the complete tutorial as part of this video so you know like we have used Jenkins for a lot of uh continuous integration and continuous deployment now we can also use gitlab for that so before uh now let's starting on the gitlab part this will be a completely basic tutorial where we'll be talking about CI CD we also will see about gitlab how to create project also how to make you know the basic preparation for the CI CD okay so we'll see some projects some configuration in that so to start with a CI CD if you don't know CI stand for continuous integration whereas CD stands for continuous delivery and also there is one more CD which is called continuous deployment so we have to understand these all these terminologies to you know to know more about the cicd process what we will do in gitlab okay so when CSA it's continuous integration then we have continuous delivery and continuous deployment now let's see about all these differences between C AI CD you know and other CDs so what is what this is all about so in order to start let's start with continuous integration so as you know like you know why we do all these things because we have a lot of developers now in the recent you know environments what we will do is we have developers working on a code right and we'll have the source code in our git repository and we will have you know developers working on their own local repository right and and also they every developer will have a small part developed and once they put into the main branch it should not have issues right so that is where this continuous Integrations comes into the part so in continuous integration these developers merge their changes back to the main branch as often as possible so what uh it does it means like you know uh there are Developer a b c d so everybody have their own you know future branches which they are working and what they will do is they will merge back to you know the branch which is you know available for them and then from there it will be merged to the main branch but there will be a different upload process in that but uh continuous integration what will happen is these changes are validated by creating a build and running automated unit test so when these developers want to make this you know mergers to the their Branch what uh automatically what happened is it will start a build of that application and it will do some unit tests to make sure that it does not break the actual application so the benefit of this like you know this continuous integration is all these are automated process so this helps to avoid the integration challenges and check the application is not broken whenever a new commits are done so you know as you the statement says right so these are automated continuous integration helps in the integration challenges because multiple versions of uh code comes up it will create a lot of integration issues at the end right so if you do these automated checks and the application is got not getting broken this will uh you know help them to have a proper process okay so how it will happen in a pictorial where to represent like you have a build right and from the bill you have an automated unit test or integration testing which they will do it and you know based on that it will do a merge all right so that's how it happens in The Continuous integration process now let's see about the continuous delivery okay so when we talk about continual delivery it's an extension of continuous integration okay and by which it automatically deploys all the code changes to a testing or staging environment so in the continuous integration we do all the you know integration parts to make sure that the application is not broken but we are not deploying that code into any testing or staging or production environment right it is still uh kept aside so what in continuous delivery what we do is we will automatically deploy all those changes into a testing or staging environment we don't do it to a production automatically okay but there are uh possibility like you know you can stop in the automatic process at the staging environment then the final product production you know will be with the manual intervention okay so that's a continuous delivery now the goal of continuous delivery is to have a code base that is always ready for deployment for a production Amendment what it means like once you have a continuous delivery process in place means you always you know whenever there is a change or some developer makes a code emerge or checking what you know happens is like it will do all these tests automatic process test build all these things and then at the end you will have you know a code uh completely ready to be deployed in production if you want you can just click a button and or just say yes then it will get deployed to the production so to just give it pictorial person as we did for continuous integration so you have built unit tests and then merge this would be the continuous integration part right then if you after that you can do an automated acceptance test and also you have a deployment to staging area and but after that should be a manual process the deployment to production should be a manual process so that is the difference between continuous integration and continuous delivery now if you moving on to continuous deployment so this is also you know it's a continuation of that so what the difference is every change that passes all stages of production pipeline will be released to the customer or production environment itself so what is happens like when we shown about the pipeline where we build testing uh no staging all those things are passed what will do is like it will also deploy to the production or customer environment automatically so this is a completely you know automated process there is no humor in human intervention at all in this continuous deployment so the whole process is automated so there is no human intervention this so if it's a build stage or if it's an uh unit test or it's emerging or as we said that's the continuous integration part or it can be you know or acceptance test or deploying to you know staging area and even to deploy to production all are you know in an automated stage so that is the continuous deployment so the difference as you see the you know between continuous integration delivery and deployment so this is how it will look like like the pictorial percentage and we showed it this will be for continuous integration and if it's for a continuous delivery it will be you know like this where you have the production uh activity alone in the manual phase but if you go for a continuous uh deployment it should be like completely automated so there is no humor interventions completely all the stages are into the automated phase so before I get it to the real process with the git lab and the cicd I would request like if you are new to my Channel or if you have not uh subscribed to my channel click on the Subscribe button and also like my video share and comment okay let's now talk about the gitlab tutorial so what we will do in this tutorial would be like you you understood now what is a cicd process so what we will do is we'll be creating a gitlab project and we'll upload some sample code there and we'll also see what are the some of the settings and also the requirement for a gitlab cicd pipeline configuration so we will be this will be a preparation phase so you know it will be a step-by-step tutorial so the in this phase you will be able to understand what is a gitlab project and also what are the settings uh what is the gitlab runner you know you also need to know what is the file which we have to create in a you know gitlab for CI CD to be configured all those things we will see in this tutorial so let's get started so I have my gitlab uh you know it can be your own instance which you can run it on some of your server or it can be you know the SAS instance from gitlab okay so I have shown also one of my tutorials to how to set up gitlab on Centos you can follow that and you can set up your own gitlab as well so now if you see you know you can see the projects here so if I go to my projects you can see these are the projects right and if you want to create a project click on new project okay and I'm going to use a blank project and I'm going to give a name so I'm going to give a name as test Maven project and you can give a description as well so I will type this is a test Maven Java project okay and I'm going to keep this as private if you want to keep it public you can keep that as well but since there is a testing project I want to keep it as private then I'll click on create so now once you create the project is created but we don't have any data added right so now you can see these instructions these all instructions we already see in our tutorial for git so you know already like how to clone a project how to do a commit how to add you know the contents into the staging area how to move that into the local repository right how to push that into the git repository all those things you should be knowing it right so what I'm going to do is I'm going to just clone this project first okay so I'll just use this so I have uh the git bash open so you can see you know I don't have anything inside this folder so I'm going to use uh the command which we use git clone okay so I'm just going to run that so you can see we it should have that project here so I'm going to use test Maven project okay and now you can see this name has we have a master or the rights what this means like we are inside the git project so if I go to my IT project you should have you know the project here okay but it's a blank project and what I want to do is I want to add some content so I'm just going to paste some content here okay this is a sample uh Java project okay and if I go to the git bash and git status you should be able to see like there are some untracked file right so you have to add git add and then if I see git status it should show like there are something which you need to be commit right then I will do a git commit and the message initial come in it can be any comment okay so now you have the files added so now what you need to do is you need to push that into the repository right so in order to push the repository you have to use git push and hyphen U origin Master okay so let's see what it does so you can see it's uh done the push as well so let me come back here let me refresh this page so now you can see all the contents are pushed here right so now our git repositories updated so you have all you know the files over here now if you see okay we have different options like you know set up a CI CD add kubernetes cluster so and on the left side you have the project information repositories right issues merge request cicd security deployment so the benefit of gitlab is you know it's a complete package it's not like Jenkins you know where you need to have a lot of plugins to be installed but you already have most of the features here itself but in order to do this uh gitlab cicd one thing you should have is like you should have a file called gitlab hyphen CI dot yaml okay that's the file like similar to Jenkins file you need to create a file inside this root location so that it will take you know uh that so if you go to cicd you will have you know uh options like you know how to use the sample if you want to use this templates you can have to create this file in order to start the pipeline otherwise you will not be able to do it because all the whole definitions of our stages about the you know jobs and everything should be defined here okay so that I will show you in the next tutorial how to write this one how to start some schengen's pipe sorry the gitlab pipeline using this gitlab ci.yaml file we'll start with so small pipeline then we will go with even Maven projects so we'll do step by steps about a few things which you need to do is like you know we need to also have some settings to be done so in CI CD you know if you go to the settings you have something these settings in a general pipeline or devops Runners so this Runner is something which uh we need to set up so this would be a separate tutorial where I'll be also showing how to set up Runner but you know there are uh there are also calls shared runners okay so but if you see these Runners are shared across gitlab instance and they are free to use for public open source projects and but limited to 400 cm is per private project okay so if it's a private project you can only use it for 400 CMAs but you can also set up uh you know gitlab Runner using some instructions so I will show you that as well so I would say like you know we will do that in the upcoming tutorial how to set up Runner so Runner basically you means like you know that you should have some place to run the pipeline right so if you're running a maven job you need to have a you know a setup where you have you know a system where we have Maven available and we can you have to run those build Commander right so that's the runner so we'll also see in the upcoming tutorial how to set up Runners for different scenarios whether it's a Windows Runner then we have to use Powershell kind of commands if it's a Linux we can use shell or you know if you can also use Docker so that you know we can create the docker containers and then some of the things like Maven and everything can run on the docker container itself and also something we you need to do is you know we you also need to set up an SSH for gitlab for uh you know connecting or pushing pulling you know all those things so you need to have an authentication between your system and you know for your gitlab instance that also we will see in the upcoming tutorial as a separate one how to create SSH between your gitlab and your host machine so you should not have any issues when pushing or pulling the content okay otherwise you may get into issues like permission denied issues so that also we will see it in the upcoming tutorial okay so in the CI CD section you can see like there are four section like pipeline editor job schedules right so basically pipeline is the word will be you know having all the job information let me show you a sample okay I will go to one of my project a project okay if I go to my game of life project and if I go to my pipeline you can see you know I have a few pipeline here right some of most of them has failed some of them I have canceled right and the similar way you know if I go to my other project which is for a first project right if I go to the pipeline you can see now I have a few projects passed right and you know some of them has failed and you know you you should be able to see just the jobs here so if I go to the job you should be able to see the whole thing okay and you can also see you know how the jobs works and all those features you should be able to see like finished right and all tags okay so all those things you should be able to see it uh in this CI CD section if I go to one of these past you know uh pipeline you can see I have a different stages like build test deploy right and there are different jobs so all those things we will see how to create in the upcoming tutorial but I just wanted to show you like these are some prerequis which you should know uh for uh you know creating this pipeline okay so you can see I have one gitlab.ci dot yaml file right which I'm using it so similar way you know we will create The gitlab Hyphen ci.tml file and also we'll write down the content of the file to create this build jobs so as I discussed uh previously like what we will do in the next tutorials of this CI CD tutorial will be will how to set up ssh in gitlab for uh authentication between your system and gitlab so we will see that how to do that we'll also see how to do an installation and configuration of gitlab Runner so we can do it on Windows gitlab Windows Runner as well also as only next site so we'll see both scenarios okay because in Windows we we probably mostly use the Powershell commands whereas in the Linux we can use other kind of shell and Docker those kind of commands Okay and we'll also see how to create gitlab Pipeline and run the pipeline which I showed you some samples in the upcoming tutorial so please you know keep watching for more videos on gitlab so this would be really interesting tutorial and you know like what we use for Jenkins and all those can we all will do all those kind of integration with gitlab as well this tutorial is a simple tutorial where we'll be setting up SSH for gitlab so if you don't know what is SSH ssh is also known as security shell and security shell or SSS is a network protocol that enables two computers to communicate so what we do is as part of this is you know this is a basic requirement to have your cicd set up for gitlab so you need to configure the SSH between the gitlab and your computer okay so this will allow you to have a secure way to access your computer over on secure network so that is the basic reason for SSH so how to set up SSH key in gitlab so what we will do in this tutorial is we'll create an SSH key in the Windows machine and we will copy that SSH key to the gitlab settings so that you know we can authenticate between gitlab and this computer okay so before I get into the actual process I would request you to subscribe to my channel if you haven't subscribed or you know just click on the Subscribe button or if you're new to my channel and you can like the video share and give your comments so what you want to do is like you can log into your gitlab account or if you have a own instance you can log into that and you'll be able to see your project so what you need to do is you need to go to your uh you know settings or no you should have a preference over here so you just click on preference okay so if you see settings you can click on that and you should get these options and here if you see you will have an SSH key so you can click on it and if you see what SSH key says SSH key allows you to establish a secure connection between your computer and gitlab okay and to add that you need to generate SSH key okay and then you can copy that content over here so how to generate so you can open your uh you know git uh you know shell or you can also use your command prompt okay so I'm using the git bash here so what I will do is I will just type this command SSH kitchen so it's a simple command you just run SSH kitchen and you can see it has it is creating a key pair into this location or SSH folder and I know you can just press enter if you want to give some names you can give but I'm just just keep pressing and draw on it so now you can see it has created a file so you can see a public key has been saved as ID underscore rsa.pop right so that's the key generator for this machine so I need to go to that location now so if I go to my Windows machine and go to this dot SSH folder you should be able to see this ID and score RSN ID underscore asset.pop so what you need to do is you just need to open this file okay so I will open with the notepad so you'll be getting some contents like this you just need to copy this content and go to your git lab where we have went to this SSH key it just paste this you can just uh you know give a title so gitlab desktop okay something you can give and you know if you want you can give an expiry date for this key and just you have to click on ADD keys so now we can see this uh no key has been already added so you should be you know having this setup correctly right so if you go to the SSH key now you should be able to see if one of the SSH key added here so it's a pretty simple process you just need to run that SSH key gen uh in your machine which you want to authenticate with the gitlab and you just need to copy here and just run it so just save it so you'll have this SSH key configured so that's a pretty simple process right so why we need this this will be one of requirement because when you try to get clone or get push you may see some authentication problem like permission issues which you may face so if you have this SSH configured then you will not face those problems okay so this will uh is a basic requirement we are doing it so in the upcoming tutorials when we do this uh Runners and other configuration we don't face any problems so just to retread I'm just telling like you just go here to preference go to SSH key just copy and paste the key here and how to generate you just need to run SSH kitchen if you are using a Linux machine it's also the same command you can also use putty or command prompt on Windows machine you can run it from there as well okay so I hope it's a pretty simple tutorial so this will be a continuation of gitlab cicd tutorial for beginners and in the in the previous tutorial we have seen the basics of CI CD continuous integration continuous deployment continuous delivery right and we also seen how to set up ssh in gitlab so this will a tutorial you know in this tutorial we will talk about gitlab Runner so gitlab Runner is one of a key topic which you need to understand to run cicd in gitlab okay so to give some information on gitlab Runner so gitlab Runner is an application that picks ups and executes the CI CD jobs which you run on gitlab so you can compare this to Jenkins probably if you have used Jenkins you may see Jenkins notes right where you run the jobs from Jenkins so similar way you can consider gitlab Runner is a place where you run the jobs okay so GitHub Runner is you know basically you set up with you know an application which you on the machine which you want to act as a you know host to run this job so you it's an open source uh component gitlab Runner okay and there are two type of Runner one is like a specific Runner which we can configure for specifically for the project and there are also shared Runners which comes along with the gitlab so there are some restrictions which we will talk you know what is that shared runners okay and uh the other point which you want to understand like gitlab Browner you can install this kitlab runner on any kind of operating system whether it's a Windows or Linux or it can be run even inside a Docker container so that's some basic information on gitlab Runner we will see more about on the gitlab side so let's move on and on to some more uh important information so in this tutorial what we will do is we will be setting up gitlab runner on Windows machine okay so what the steps we will be doing is we will have to download the gitlab runner binary file then we have register the runner and we have to install Runner as a service and start it so then you will be able to see the runner is configured in the gitlab so you can make use of the runner to run your CI CD jobs so before we get into the actual demo process I would request you like if you're new to my Channel or if you haven't subscribed to my channel click on the sub subscribe button to get the no more videos and also like my videos share and comment so let's get started with our actual uh demo on how this setup is done for gitlab Runner so before let me also show you some information so these are some of the project which I have within the git lab so if you don't know how to create a project please check my previous tutorial where we have shown you how to create project and how to push through git commands Okay so let me open you know a simple project which is my first gitlab project where you can see I have already run some pipeline build so if I go to settings and there is an option called CI CD so there are two CI CD one is over here which is for pipeline jobs and editor if you go to settings we have a CI CD option right so just click on that and there are quite some options here and there is a tab for runners right so you can see the runners are the process that picks up and execute the cicd job for gitlab right so how to configure it that is what we are going to see now if you expand this now you can see you know you can register as many Runners as you want right and you know there are active and post States and there are two kind of Runners which we spoke like specific Runners and shared Runners so these specific Runners are specific to this project and this shared Runners are shared across gitlab instance now here if you see this shared Runner is disabled usually by default it will be enabled I have disabled it so if you have to you know use shared Runners one thing you have to be understood is like these are free to use for public open source project limited to 400 CI minutes per month okay for a private project so 400 cm minute is allowed for your private project but if it's you know open or public project you can make use of that as well so you can see the runners you know you have different kind of Runners which is already you know in active States over here but if you see what we are going to do is like we are going to set up a specific runner in this okay so we have to make use of a Windows machine and you know you'll be able to see a runner I don't know here okay so you will be using this token for it so that's why I just showed you like we need uh this location and we need to make use of this Runner so the runners are configured specific to project okay so it's not like you just set up a runner and it's used for all project basically so you need to register it uh specifically using the project the token so you can just do that now uh the step you know I will link this documentation also into the video description where where it's talking about how to install gitlab runner for Windows so first thing what you need to do is we need to create a folder name you know in the name of gitlab so it cannot it man it's not mandatory that it has to be in that name so as for the documentation it says gitlab Runner and you need to download this binary file now if you see I have already downloaded this binary file okay and I have to rename this as gitlab runner.exe so I'm just going to rename this file Okay so let me just rename this toolkitlab runner.exe so this part is done and now we need to register the runner and also we need to start the runner as service so you need to open a command prompt as you know administrator so in the elevated stage so you just need to open a command prompt and let's go to this folder so let me go to the folder so it called CD git lab Runner okay and you can see sorry since I've used all these commands in Linux that's coming up here as well so you can see the file over here right gitlab runner.exe so in order to register the gitlab run or what you need to do is you need to run a command like gitlab runner.exe register and then it will ask you to enter some information so I'm just going to copy this and I'm going to run this command over here okay lab Runner and register so now we can see uh it's asking you to enter some details so enter the gitlab instance URL so what you need to do is you just need to copy this content and just paste it the same thing because we we are using the gitlab this is the same URL which we are going to use if you are using a whole internal hosted URL which is in the different URL you need to give that and you know you need to enter the registration tokens which will be coming from this page okay where we went to settings and CI CD and we went to uh Runners right so I'm just going to copy this and I'm going to paste this registration token and you can enter some description for this Runner so I will just put Windows machine okay and some tag so the tags means you can use this tax when you're running uh the jobs so tax will help you to make sure that you know when you run the job it can check okay this tag is mapped this Runner so you run this job on this Runner so I will put like a Powershell maybe right and the windows I'll just put some tags over here and I know you can also put some executors here so similar like you know you have a Docker you know a shell so I will just put shell here okay okay so you can see the runner is registered so now let me come here and refresh this page and let me expand the runners again now you see like we have Runner available here right so but the runner is still in a disabled or not connected stage so we have added the runner now we have to start the runner so in order to start the runner you need to follow these steps you need to install and you need to start so let's just go back to the screen and let's call the gitlab runner and you need to install it okay so now you can see it's a runtime it has already completed that and we need to start it okay so now the runner is started as well so let me go back to this CI CD screen and let me just refresh it okay let me expand the runners again now we can see the runner is active so that means the runner is ready and now you should be able to use this runner for uh no running your CI CD job so you can also see you know the tags which we have used Powershell windows so these tags will be helpful like when you create the jobs you can tell like you know this job has to be running on the machine which using these stacks so that was a pretty simple process right so it's a very pretty simple process to set up the runner and you will also see in the upcoming tutorial how to set up runner on Linux and also how to make use of Runner as a Docker container so you can create jobs where we can create images uh you know for a specific application which on Docker containers and then we can run those applications so we'll show all these things in the upcoming tutorial now here in this case now the runner is running now if you want to stop it you can use stop command and that should be done so if you refresh it back let me go back and expand the runner yeah I think we should remove it from here as well and I know we need to stop uh also the uninstall the service so you can uninstall it from here if you want to remove the runner now you can see it has been removed as well and you can just remove it from here as well so once you remove it the runner will be removed from uh the machine so it will not be running uh you know in the specific Runner if you want to run another cicd job on your share Runners you should you need to keep this enabled shared runner for this project okay so these are some settings which you need to be aware about the runner for gitlab so basically you can as I said you can compare Runner as a place where the job has to be running so in general to Jenkins you should use like some nodes you know slaves machines which you will use it to run the jobs the same setup I I would say like when we are talking about runner in gitlab so if you have seen uh the previous tutorial we spoke about gitlab Runner right so how to set up gitlab runner on Windows and in this tutorial we are going to see how to set up gitlab runner on a Linux send device machine okay so if you already know how to set up gitlab Runner you can just skip it so I will be continuing with the next tutorial so you can go to that directly so just to give a recap for those who don't know what is a gitlab runner so gitlab Runner is an application that picks ups and executes the CI CD job for gitlab so it's more like a slave machine which we use it in Jenkins or Nords which we call it in Jenkins right where the jobs will be running so it's an open source software gitlab Runner is an open source software so you can use it and install it and there are two kind of Runners which I showed you like there is something called specific Runners and shared Runners right so the specific Runners are specific to the project which we set up like now what we are doing uh using a Linux machine uh their shared Runners is coming from the gitlab itself so when you run a CI CD job it can take the shared Runner as well and you know you can run this install the gitlab or not different operating system like Windows okay what we are doing now for Linux or you can even run inside a Docker container so to give you uh details on gitlab Runner installation on Linux so what we will be doing is we'll be downloading the gitlab runner binary file so there are different ways but we'll be using the binary files and we'll create a gitlab user and then install the runner we'll also run installer analysis service and then start it and then we'll register the runner so once you register you'll be able to see the active status of the runner on the gitlab job so that will be the overall process so we'll get into the demo directly now so before I get into the demo I would request you like you know if you are new to my Channel or if you haven't subscribed to my channel I would say click on the Subscribe button and also press on the Bell icon so you'll be notified when I submit new videos okay so also I would request like you click on the like share and comment so that you know more and more people will be benefited by these tutorials so get to get started you know to the demo I will I have few projects in gitlab so I have showed you like in the previous tutorial for gitlab runner on windows so where you can see is once you go to the project you have CI CD and you also have a CI CD here so this CI CD is for more of the creating pipeline you have to go to settings and go to the CI CD and you will be having something called Runners right so if you expand the runner you have two options one is specific Runner and shared Runner so I have disabled my shared Runner so that you know these jobs which is running or the CI CD job on this project it will not be running on the shared Runner so the shared Runners uh no it's uh used to get it's completely free for open source project or there is a limit like 400 CI minutes for uh you know private project so these options we will be using like the talker and everything to register and I'll be following this uh documentation for installing on uh you know Linux machine so there are different ways I said you can use multiple ways to install it using uh the uh you know RPM package or you know dot Dev package or in there you can also use a binary file so what we are going to use is we are going to use binary file then we have to give some permissions we have to create a user CI user then install a service and start the runner and then you need to register so in order to register the runner you have to run some command and you I will just show you all those things so let me get started so I have this machine okay which is a Linux and device machine and this Android machine I also have a Docker installs why because in this machine I'm going to set up this Runner and also the benefit is like you know since I have a Docker install when I create uh the gitlab images or gitlab you know uh pipeline I'll be specific specifying some images so that you know you can create containers on this machine okay so for example I want to run Maven build I'll be setting up an image for Maven and I'll run that a cicd pipeline so I don't have to set up Maven here in the send OS machine it will create a maven image and then it will create it will use the main image and it will create a container for the maven it and it will do those activities so we will see all those things that's why I have a Docker also set up on this machine so let me get started with the commands so the first thing is like we need to download the gitlab runner so as I said I'm using the binary file so you just need to run this command which is already available in that documentation which I will link into this video description so you can just have a look there so it's almost like a 53.6 megabyte file so let's just wait for that to be downloaded okay so the download is completed and it's downloaded under this location slash userlocal bin gitlab Runner so if you go to slash user slash local slash bins and you should be able to see the gitlab runner and now we need to give the permissions for that so let me just run that command to give the permission so you need to run the CH mode and you need to give that location for the file so now if you see this has been made green so because it has got a complete permission now so the next step is like we are going to create a user called gitlab Runner so then you know we'll see how to make use of that to register and install the runner okay so that is done so next step is like we need to install this gitlab Runner as a service so what we are going to do is we are going to run this command gitlab Runner install uh Slash and you're going to use this user to run it and the directory should be here so that we need to make some changes in this command because if you run the uh without you know this dot slash it will not detect the gitlab on rexe uh it's not in the Axis or it's the gitlab runner executable okay so uh you know you have to use this command okay so then you have to run it so if you run it so it will create a QV disk output okay and the next step is we need to start the runner right so you need to again run this commands you know gitlab Runner and start so if you run it then the gitlab runner is started as well so next step is like we need to register the runner okay so for registering the runner you need to run another command so it's pretty simple command it's almost the same as start but you need need to change it to register so you're going to call this gitlab Runner executable and then you are going to run the register so once you run the register you'll be getting uh some prompt where you need to enter some information so since we are using the gitlab as the you know for you know the instance URL if you are using your own URLs you have to give that so I'm just going to run a gitlab Dot com and I'm going to run it now we need to enter As registration token and this registration token is under the settings you know where we showed CI CD and you need to expand the runner and you need to copy this uh registration token and you need to enter that then you can give some description uh for this Runner so I will just make it as Linux and then you can give some tags so I'll again you Linux and docker okay so the tags will be useful for you when you run you know some pipeline where you can mention this pipeline has to be running on this tagged uh runners okay so now you need to run some executor executors here so I'm going to use Docker as well here and I'm going to use shell okay so let me run that okay so I think there's some problem with this executor so let me just run with shell yep so it's added so we are done uh from that part so let me clear it and let me go back here and I'm going to refresh this Runner okay and I'm going to expand the runner now you can see we have this Runner added right on the screen because I know it's online now so now once you create uh you know this pipeline job uh it will be able to run it on this uh runner you can add multiple Runners as well okay so but uh I I know in this case I'm adding only the Linux one right now so last tutorial I've showed you how to set up Windows Runner as well so and that's the overall process we wanted to do like we just want to set up the runners so we will be making use of this runners in the upcoming tutorial so the whole agenda of this tutorial is step by step process how you complete the CI CD or using gitlab so now we are done with the runners registrations and setting up so now next tutorial will be doing how to create uh the jobs cic job how to write The gitlab Hyphen ci.tml file where we'll be creating stages and also the jobs and now in this tutorial we will start with the CI CD pipeline how to create pipeline okay so what we will do in this tutorials we'll just have a re-look on the basics of cic so I'll just give a quick recap on that then we will see how to create uh your own CI CD pipeline in gitlab so when we say about a CI CD pipeline we will talk about a gitlab hyphen CI dot EML file and also jobs what are the jobs in a pipeline and also different kind of stages so there are more about the cicd pipeline like Taro tax there are artifacts there are a lot of things which we can do but we'll start simply a simple project with the job stages and how you know pipeline will look like then we will add up in the uh section by one by one okay so to get started with the cicd uh Basics so if you have seen my previous tutorial we spoke about uh this concept right so CI CD stands for continuous integration CI stands for continuous integration and CD can be continuous delivery or it can be continuous deployment right so well I have explained you what it means so if you see like continuous integration it have a build and then a test and the merge right so for example we have different kind of developers is working on a project and they have their own feature branches they are working on their code and they will commit their changes on the code so it can start an automatic build job to integrate those change edges then it can do a small unit test and if it passes it can merge those chord changes so that would be the continuous integration and all should be automated then if you talk about continuous delivery so this will be the different phases or how it look like in continuous delivery like after you your continuous integration we will have an acceptance test which will be an automated one and we'll be also deploying our application to a staging area so the difference is like we are stopping the automated process still staging area and you know we are not having the automated process to deploy to production so the deployment to production will be a manual step like we need to confirm from Orange so that it can be deployed to the production so this will be the continuous delivery process now when we talk about continuous deployment the whole process will be automated so what means like as soon as you make some changes in your application the whole process will be automated and the new version will be deployed into the production so that's a basic information of cicd if you have not seen my previous tutorial I would say like have a look on that I will link the video or description also the link for that video so you can have it in the video description so now let's get started to the actual demo on that so before I get into the actual demo on the project and how to create the CI CD pipeline I would request you like click on the Subscribe button if you have not done yet or you're new to my channel and also I would request you to like my videos share and comment so we are in the gitlab page okay so there are a few projects I'm not going to use those projects you know I can see I have some Maven project Java project node project we will see all those things in the upcoming tutorials so you know for this tutorial I'm just going to create a new project okay it's going to be a simple blank project and I'm just going to call it I'm just going to call this test gitlab cicd okay and I'm going to keep this as private because you know I'm doing this for all this testing and learning so you know to show you do all this testing and making those changes which I don't want to make it a public for everyone because it's just a sample project so I will create the project okay so once you create the project you can see we are inside the project and we spoke about in the previous tutorial like what is the CI CD section for in the settings we have a CI CD where we spoke about Runners right and we have different kind of Runners shared and specific Runners and in this tutorial I'm not going to use a specific Runner I'm going to use the shared Runner so I'm going to keep this enabled but we will be seeing how to make use of the specific Runner also in the upcoming tutorial like you know we'll add our own Docker Runners we'll also add our Runners to run Maven builds so our Windows Runners for running powers and scripts all those things we will see but this is a beginning tutorial so I want to keep it with the share Runner now what I will go to I'll go to the project so in order to have a gitlab a CI CD what the basic requirement is like we need to have a file called gitlab hyphen CI dot yml it's not y a ml it's just yml okay so you have to be very clear about that so this is a you know blank project there is nothing but if you you know it can be any project any gitlab project we need to have this uh gitlab hyphen ca.tml files or I will create this file first so you can see this will be the syntax or the name gitlab hyphen CI dot yaml so if you put yaml it will not work and you also have different options to use templates so different application templates you can use like C plus plus share for you know a Docker there are different templates you can use whichever is used for example npm it will give you some templates like how you're using node uh deploy and all those things so I'm not going to use any of this I'll just delete it okay so I'm not going to apply any template now the basic uh thing in cicd pipeline is like you will have jobs right and you'll have stages as well so what we of those we will just write some jobs so I'm going to use job one okay and the basic requirement for a job is like you need to have a script so I will run a script and I'm going to Echo it as this is a first sample job okay so that's the basic requirement you should have uh you know this will be your job name and this will be your script under which whatever is there it will be running so let me commit this change now you can see it's valid if I go to cicd and pipeline you should see like there is running right and if I click on it you can see there is job one right which is running if I click on the job one it will show you like you know the process which is running and it says job succeeded so now if I go back to the pipelines again now you can see it's passed right and if I click on it you can see the job name is job one but you can see here it's called test right so this is a stage so by default if you don't give any name uh for any jobs under which uh you know stage it should be it should be running on the test stage let's go back to the editor okay you can go back to the editor I'll just copy this whole content now I'll run it put the job too so I will make this a sample job one and this sample job two okay so now you have we have job one and we have job two and both runs uh this content is under script so let me Commit This so as soon as you make the commit it will check the gitlab configuration it will start the pipeline okay so with any changes you make it in the gitlab project it will start the pipeline so if I go back to the pipeline it's running if I click on it now you can see there are two jobs but both are clustered under the same stage and it's running a CD parallel right so you can run two project parallels so it's not like you know this job will complete and this will run it on the after it so now there will be scenarios right where you have a build a process to be running first then after the build you have to run the test then maybe after a test you have to run that deploy so if you don't Define the stages all the jobs will run fairly so that may not be the actual requirement you need right so let's go back to the editor so what you can do is I will go to the top and I will put like stages okay and I'll put as build as one stage okay I'll put build that stage and then I will put test as another Stitch and then I will put deploy okay so now we have three stages defined okay now what we can do is we can you know segregate or we can attach our jobs into the stages so I will put stage here and I will put this will be under stage build okay so this should be on the stage build okay so stage build I will change the job into build job okay and I will change the com content to build job okay so this will be the stage one okay now I can put the stage two here should be test so I will map this job to test so I will change this visibility test job okay so the job name will be build job here this will be collaborate to the stage Bill and this would be a test job which will be clubbed into the test bill I will just copy this same content See this is a very simple pipeline okay because we are just trying to understand what is uh stage what is a you know job what is the script right so don't worry about the content and the script that we can change it based on our new projects right sure let's change this to deploy job okay and I'm going to put this to deploy so and let me change this would be test job and this should be deploy job okay so now what we did is like we defined three stages okay build test and deploy and we are mapping our jobs into each stage right so this will be a build stage this should be under test stage and it should be deployed stage now let me Commit This again it's checking the you know gitlab configuration if there is any syntax issues it will show you like it's not a right one let's go back to the pipeline now you can see it's running and if I expand it now you can see you know we have three stages one is build another one is test another one is deployed right so once the Deep build job is completed the test job is started and you know once the test job is completed it will start the deploy job so that's how it will be now because of different stages so let's see what is there so if you go inside you can see it's completed if I go back you can see deploy job is running now once the desktop is completed right so it's going in the face ways like you know it uh complete one job at a time and then it will go to the next uh stage right so now what will as we said you know what is the case like I have a two different uh tasks which need to be running on the same test so let's go back to our editor now inside the test you know I want to put one more job okay so I will just copy this content and I'll just make this as test job one and this will last test job too okay so now what happened this this job one and job to both are mapped to the stage test okay what it means like these two things will be clubbed under the same stage and it can run parallely so let's uh commit the change go back to our pipeline still updating yes it's running now so if I go back to the pipeline now do you see like under test we have two jobs test job one and test job two both are running parallely but this deploy has not started yet so that is the uh you know the stages and jobs in gitlab so this is a very useful and that's how you should write your code you have to understand what has to run or no serial and parallel so you can Define your jobs like this should be my first job I should be you know come completed first in the build section then it has to move to the test and it has to move to the deploy now you can see all the job has completed right so you know it has used you know the whole job to running it's used our share Runners so you can see it as using these Runners which is from gitlab Runner and it's using some Docker image so what we will see in the upcoming tutorial like how to make use of you know the runners from our uh system like we can make use of our Windows machine or we can use make use of Linux where we have Docker and we can run you know Docker images for Maven or node.js or those applications I have planned for all those things in the upcoming tutorial we'll create a pipeline for different kind of builds so now you see like we have pipeline section here we have editor where we were trying to edit the content of our gitlab.yaml file we have jobs which will be listing here like how many jobs we have run we have schedules we where we can create schedules as well of the pipeline so that's uh that's details which I know I wanted to show you in this tutorial I hope you understood like what is you know stages what is you know jobs and what is the script what we are running inside the script sure that's a simple uh tutorial to give you the basics of CI CD pipeline in gitlab so we will see more complex things in the upcoming tutorial so in this tutorial we are going to learn about gitlab cicd4maven project so what we will need as a requirement for this project like you know if you're new to CI CDMA project what we need to have it you need to have a gitlab account so if you don't know how to create please check my previous tutorial and you'll also need a Java project which will be used to build using Maven and you also need a gitlab runner so you can use a specific Runner or you can use shared runners in gitlab so in this tutorial we'll focus on shared Runner so you you may not have to do a setup of grunner yourself but we will see that in the upcoming tutorial as well but if you don't know how to set up gitlab Runner you can check my previous tutorial which I will link into this video description and you also need to have an understanding on Maven life cycle which I will also show you in the upcoming slides so you know you need to have understanding like what are the different life cycle of Maven so when you build the pipeline you need to give stage you want to deploy so also we will write the gitlab CI pipeline file which is will be like dot gitlab hyphen ci.tml file we will see how to write the complete CI AML file so so what we'll do in this gitlab cicd Maven no project we'll be also using Docker so we don't set up Maven to install on some Runner and do that so what we will do is we will use the docker specific Runner and we will you know create a maven build in Docker containers so to give some information about Maven life cycle so these are some life cycle stages in Maven like validate initiate I know there are a few like compile you know tests test compile package you know verify install deploy so there are different you know stages in you know Maven life cycle so you can Define which stages you want in your pipeline so we will see what we will do in our our tutorial so what we will do is we will do you know using a maven image so we are going to use Docker image and we will create create the four stages one will be for build one will be for test and one will for package and one will be for deploy so this will be four stages we will be creating in our Pipeline and we will see how we know we can run those pipelines so the maven can build and the whole Source will be created so also what we will also see in this tutorial like you know how to Cache so we'll also see how caching mechanism happen in gitlab so we will cache dot M2 repository which were the maven files will be stored and also the target folder where once you build our package your application or install it you will have a you know jar or War file which will be saved under the target folder so this caching will help us to increase your speeding up the whole process of your pipeline so we will see all those things in the no actual demo so before I get into the actual demo process I would request you like if you are new to my Channel or if you have not subscribed to my channel click on the Subscribe button also like my videos share and comment so I'm in gitlab and you can see I have a Java project okay so there is a source file and you have you know a palm.xml so you know if you don't know how to set up all those things then you have to learn uh pump uh no dog XML how does that return how the Java project works so but you can use this project you know for your uh testing so I will give this link into the video description so you can go and have a look there so now we don't have this dot gitlab hyphen ci.aml file which we will create so before that I just want to show you a basic uh you know gitlab.hyphen ci.tml file which we are going to use so we are going to start with image and we are going to use the maven image for this tutorial so because this is a Java project and we are going to build your project using Maven so rather than using installing my event on your machine and you know using that Runner I'm going to use a Docker container so you're going to use Maven image to create a container and as I mentioned in the previous slides I'm going to have a four stages so we have spoke about stages and job in gitlab ch pipeline right so we are going to Define four stages and each job so will be mapped to some stage so you know you can have multiple jobs also in the same stage so here I'm going to use build job and I'm going to use the stages build and what this tag refers is like this tag is to inform galap CI to run this job on a runner which is having a tag Docker so in Runners you can have when you create Runners you can tag them with some keywords like Docker or Maven or you know shell so you can Define this job has to be running on this uh you know Runner so I'm defining it as a Docker so I want some Runners which have a Docker install so I'm going to you tag it like that and you know I'm going to give a message that this is not a mandatory but just for information I put like a maven compile starter and the build stage I'm going to run my mbn compile so MBM is the maven command and the compile is the life cycle stage so that's what I show you like different life cycle is there so build I'm going to compile it and in the test job I'm going to use test stage and again the tag is Docker and the script I'm going to run mvn test so here I'm going to run the test lifecycle of Maven and the package you know I'm going to use package Stitch and here I'm going to run a mvn package so when you do a npn package you will have a jar file which will be created and it'll be saved under your repository Target folder okay so in order to deploy you need to have some kind of method like you need to deploy it to your art Factory or some location so in our case we are are not going to see that deployment side so because of that I just created a job as deploy and I'm just going to print the message along so we will see about this how to deploy your you know jar file or Maven things into your artifactory upholstery or something in the upcoming tutorial so this one I want to start as a basic where you can create different life cycle as a stages of uh now in order to enhance this one I have also updated some other uh you know parameter as well so I'm going to do is I'm going to set a variable called the maven or pts and this will be the local repository which will be the rm2 repository right so I want to back up this repository so because of that I have to set this variable and I'm going to use cache so cache means I'm going to Cache this uh path into you know some repository since we are running shared Runners it will be saved under some Google cloud or some default gitlab repositories so we are going to set uh the path will just be cached is dot M2 repository and also the target where your jar file will be saved so the benefit as I mentioned like it will speed up the process so it can call up this repository in the next job so once you run the build if there are this can be used for other job another job as well so the rest of the part is going to be same so what we have added is we have added the cache and also we have added uh the variables for that so if you don't have this variable set where it is mentioned as local repo is M2 repository this uh caching will not work so let me just copy this okay and I will create a new file here and I'm going to call this as a Dot gitlab and you see whatever we are going to put you can also see the you know uh template if you search for maven so let's search for Maven so you can also select some template from here so you can see the default uh gitlab template you see okay it give you some variables set here right so it's using some image I'm using latest image you can see it also has cached M2 repository it's using some stage called verify sorry stage for test and it's going to do the you know life cycle like mbn verify and I think it's deployed you can see it's deploying uh something uh to some location so it's using you know to gitlab some repositories so you can read through that as well but in our case we are going to delete this okay and we are going to apply this pipeline CI pipeline in a job uh we just written okay so there are different stages and different jobs so let's just commit that so let me go and commit so once you commit you should have you know a pipeline started so you can see the pipeline I started so you can just click on it and you can check if you click on the job it should be showing the details while it's running so now it's preparing the docker you know environment you can see this tag called Docker so this is running on a you know Runner which is having tagged with docker you can see that this job has completed so if I go to the top foreign compiled right so that's a message so you can see it has done the complete process of mbn compile and you can also see it has created a cache for M2 repository and if you see Target also it has created right so and it's saved under some Google storage.google API right so that's how it is done uh for the first stage let's see for how it's happening so you can see the other stages are running now so let's so now the test job is also completed so let's go to the package job now we can see it's uh waiting for the package job to run maybe we can just go back to our Pipeline and let me go to the test job it's passed right so you can click on that now if you go to the top you can see now you know the first steps it's doing like it's uh downloading the cache so the first uh in stage you know what a job we have created a cache for uh M2 repository and also the Target right so it is copying those things now for this job so you can run a seats around the NBN test and you know you can see it has done the whole process here you can see build success right so that's all you know for that job so let's see what it happens for whole pipeline now so you can see we are in the deploy stage the package is also passed so you can check the package job you can see it has updated that as well so you can see building jar right so it has created the jar file and it's under the target folder so you can see this one is also completed I can see the whole uh pipeline is passed so we can see whole job we can see uh build test package deploy all jobs are completed so we have four jobs right it's all running on Docker right and it's running on different uh actually Runners right I think so so let's see it's also to show you like how much time it has taken to run and you know so that's all I think uh from this pipeline section so if you want to edit you can go to editor and you can make some edit here for the ca file you can see the jobs alone here you can see the schedules we don't have a schedule test cases right so you can see all this information from here so uh just to give you a recap like you know this is the let me go to the editor so this will be your gitlab hyphen ci.dml file so you can if you are looking for a pipeline file for a maven project using Docker containers this would be the best if you don't want to use Docker container you can remove this section because I'm setting a default image Maven and you can build this but you should have Maven and other components installed on your Runner okay so that should be the whole process so in this tutorial we are going to talk about gitlab container registry so you may be wondering what is a gitlab container registry I would recommend you to check my previous tutorial where we have spoke about what is a Docker registry so Docker registry what that this means like it's a place where we will store our Docker images and we will distribute it so the classic example is a Hoster registry which is our Docker Hub right so I hope everybody has worked on Docker will be knowing what is a Docker Hub or uh from where we download our images right and in my previous tutorial we have also shown how to set up a local registry so you can set up your own registry on your machine using uh registry containers and you can store your images in that and you can use that too distribute it to other Docker machines right so we have seen that also if you have not seen just look into the my previous tutorial and I will link that into this video description as well so when we spoke about host registry we thought like Dr Hub is one of our foster registry where we can download images and in this tutorial we will see how we can use gitlab container registry as a Hoster registry so you can save your you know images into the gitlab controller registry and then you can use it for Distributing to other Docker machines or you can pull it or you can you know use those images to create containers so that's what we are going to talk about in this tutorial so this complete tutorial we will see like a few steps how to make use of this gitlab container registry so we will see where we you will be able to see how to enable that if you don't have that in your gitlab project and also we will talk about how to log into gitlab container registry using Docker command so there are different ways you can use username password or you can use personalized token so we will see how to create those things and also we will talk about how to build uh Docker images and push you to the container registry or you can use existing images and you can tag it to the registry and you can push it to the docker container registry in gitlab and we'll also see like there are options in gitlab where you can configure you know housekeeping settings like you know this container registry images you know if you don't want to keep it for more time because it may use not much of space of your gitlab so my understanding is that gitlab gives around like 10 GP of space I'm not exactly sure but it's a free you know the gitlab container registry is free for an open for all and but I think there is some software you know settings like you can have 10 GB of image size or something like that so we will see like you know all these things in the actual demo so before I get into the demo I would request you like if you're new to my Channel or if you haven't subscribed to my channel click on the Subscribe button also like my videos share and comment let's get into the actual uh demo so if you have seen like uh you know gitlab we have created a lot of projects before so similar like you know every project if you create in gitlab for example this is a new project I just created for this uh tutorial so it's an example project so whenever you go to your project on the left side you will see all this uh settings where we have seen the CI CD for creating pipeline similar way you will have something called packages and repository so we are not going to talk about package here we are going to only talk about container registry so if you click on that so you should be able to see if you have any you know container registry uploaded here and the image is available so for now we don't have an image available here so this container registry is associated with all projects okay so whenever you can the benefit is like in the project if you have any content like you need to build those uh application as an image or something you can default use this container registry upload your image then pull it push it pull it all those things you can do it easily so now in case if you don't see this uh you know container registry option you go to settings and you have packages and registries so here if you see um not here yeah I was in the wrong place so this is more of your housekeeping so what you need to do is like if you don't see the container registry go to your project settings and general and you will have the option for visibility project features and permission you expand this so here if you you'll be able to see what kind of project what all settings are enabled so if you scroll down you can see for container registry so if this option is not enabled uh you know then you will not be able to see the container registry over here so that you can check by default it should be enabled so in case you know if you are using a locally hosted uh you know gitlab or something then you'll have to ask your administrator to make those changes okay so now let's coming back to our project so if you see we don't have any registry available now right now let's talk about how to create a image in Docker and and how to push that to this machine you know gitlab are container registry so as I said you know the benefit of this like when we use our gitlab cicd pipeline for example a node.js application you have your Docker file you can use that to build uh you know a new image node which you can you know you don't have to push it to a Docker Hub you can push it directly to the gitlab itself then you can use that to your next stage and it can continue like that so let's start with a simple uh you know image I have a image for Alpine okay so rather than creating a new image from a Docker file let me show you like I let me tag this image or re-tag it so I'm using Docker tag and I'm going to tag Alpine okay through uh our Docker uh collab registry name okay so how that registry name should be you'll have to give you know in Docker Hub you don't have to specifically give any name for your container registry because by default if you give a name of a Docker image it will go and check in the docker Hub but this is not a Docker Hub this is a gitlab image registry so we have to specifically mention our registry name as we have shown in the our local registry now if you come to this container registry itself which show you uh default commands like how to log into our container registry so this should be registry.itlab.com right and then after that it should be your uh you know ID or your uh no gitlab account then it should have your project name okay and after that you should you can give your uh you know image name as well if you don't want it you can give it like this as well so what I will do is I will copy this okay and I also will give a name as Alpine gitlab and I will call the tag as test okay so this should be the whole um you know location where you're going to tag this so usually you know in gitlab all Docker Hub also if you are pushing to your uh your you know Docker Hub account you should give your account name right so similarly you can consider this is your account name and this will be your image name and the tag so let's run this so you can see now you have the image created here right so it should be this one okay so let me clear out the screen now what we need to do is if you use a Docker login by default this will go to your uh Docker hub login so if you just give Docker login it will uh log into your Docker Hub so you need to specifically mention I want to log into the gitlab Container register so for that as the command mentioned here you need to mention registry dot gitlab.com so you can just run that Docker login gitlab registry.com then you can run it it will authenticate with you know existing credential since I already had my login before it's logging in automatically let me remove those accounts first so I have just removed this um uh my previous cached login details and I'm just going to run the docker login again now if you see when I run it's asking for a username so you can give a username so I don't want to log in with the username and password okay so you can type your gitlab username and then it'll ask you for password you can type that and you can log in with that so rather than using that what I want to do is I want to use the access token so what you need to do is you need to go to your gitlab page okay not on the project you need to go to your gitlab you need to click click on edit profile okay then on the left side you'll have a option called access talker so here you can give a token name okay if you see I already have a token here okay which is already created and I have given I expired it so a similar way what you can do is you can give a token name so let me type test and you can give an expiry date so I will give it for today itself and when you create a token what you need to be very careful is if you want to use that for your Docker container registry uh sorry the gitlab container registry you should have this permission given like retro registry and write registry then only you can push the images to The Container registry and you can read it okay so this settings is not rated for this action for uh if you are using this token for other purpose like read repository write repository you need to give the desired permission as well so once you create a token you need to be very careful that you just need to copy this value okay because once you refresh you should you will not be able to get this value again so as soon as you see this you need to copy this and keep it somewhere safe otherwise if you reverse this page or if you just come out of this page and you have lost that token you can only see there is a token available and you can revoke this token but you will not be able to get that token ID you know once you refresh this page so just make sure that once you create a token you keep that okay so we have created the token now what I want to do is I want to log in with the token so for logging in that you need to use this command so you have to use Docker login and uh the registry gitlab.com and hyphen you for and give your account name so in my case this is my gitlab account and you have to give a hyphen p and then you have to paste that token so let me paste my token and I will enter it so it will log in so I just surrounded a token and it will log into the page okay so now you can see it has successfully logged in so you can use this method and don't share this token with anyone I will be reworking this token as soon as we completed this tutorial so don't uh share that so it's for your own uh purpose to push images and uh read images so now what we have is we have a Docker image in this uh no we just tagged right so now what we need to do is we need to push this uh Docker image to our container registry right so Docker push and you need to paste this uh and the tag so let me run that so now you can see it's pushing uh the uh image to The Container registry so let's just wait for this to be completed depending upon the size of your image it may take some time okay I think it's already done so I'll just go here and I'll just reverse this container registry now you can see we already uh got this registry uploaded here right and you have this uh test as attack so now what you can do is you can just click on this one to copy you know the image so let me clear out the screen let me remove the uh this image first so I will remove Docker RMI I'm gonna force it this uh if there is something used or I'll just run this so it's done so if I go to Docker images you don't see that image anymore right so you come here you click this one and you use Docker pool and paste this so you have this whole location of your image with the tag so you just run this so it's pulling the no image from the gitlab container registry now 5c Docker images you can see the image is back right so that's a pretty simple now right so you just have to you know uh push the image to The gitlab Container registry it's similar to like what a Docker Hub now let's see you know how the same thing we can do it with the docker file as well so let me remove this uh Image First remove this one okay so that is done now if I see I have a file called Docker file okay so this file is a simple Alpine file which is installing a MySQL client and it's just creating an entry point that's all so what you can do is uh rather than tagging the existing image you are creating your own image using your app for application using a Docker file what you need to do is you need to use Docker build and you need to give the hyphen G tag and the similar way how we have given the whole name of the gitlab container registry with the image name and the tag and the location of the docker file so I'm going to give this a name the it's the same gitlab.com and this uh my account and the project name and Alpine gitlab is the image the same name I'm going to give and but I'm going to tag as test one and I'm going to give the location which is in the current folder so I'm going to give a thought okay so let me run it now you can see it's trying to create the image so it will use the Alpine latest image so it's pulling that Alpine image first then it's you know create the container sorry it will create the image for using the docker file so let's wait for this to complete okay so let me see now we can see we have a new image for tag test one right now if you want to push this again we need to log in since I already logged into the gitlab Container registry I don't need to login again I will use Docker push and this should be one and it should be test one okay so let's push that so you can see it's starter pushing the new image as well so that image is also pushed now if I go back to your container registry and if you refresh it you can see there is one more tag right so if you go to your container registry you have one registry or another but there are two tags so you can create multiple tags like if you want to create uh you know test images you want to have development images you want to have production images so you can have different tags based on that and if you want to delete this you know images you just delete it from here okay and it should be gone now you can see one is gone and if I delete this one as well you can delete it and if you want delete the whole container registry this repository you can just delete from here as well okay so just delete that the whole control registry as well so that is also done now the other purpose which I wanted to show you like if you go to the settings where I show you in the initial time like you know when we are searching for how to enable a container so we go into this setting but if you see this option is for a cleanup image stack so there are cases like if you are using your default gitlabs uicd pipeline Whenever there is a change in the pipeline uh changing the project it will keep building your images again again so that will add up more space into the gitlab and that will use a lot of space in the register so in order to save space you can have these settings enabled so cleanup image stack currently is disabled you can enable it and you can do some routine uh cleanup activities like you can run it every day and you can keep some settings like I want to keep only the five tags so I don't want the old images to be kept so I can keep something like yeah I let's keep only the latest five images or you know you can keep other options like you know remove these Stacks which are more than 90 days or you know seven days so you can keep this setting so by default you know if there are more images getting created it will clean up automatically in the gitlab cleanup housing you know housing housekeeping activities itself so that's another option I wanted to show you sure that is also very beneficial you can go to settings and package and repository you should be able to see that right and we also seen like settings in general and visibility like if you don't see the um container registry you need to enable that over here okay so that is all uh I think we covered all the topics for that now if you want to log out from the container registry just log out okay so now it's uh logging off so as a show like once you log in it will save those in the cache so that is under the json.config file so now that you can delete it if you have or have those configurations saved that there as well and in this tutorial we are going to see how we can make use of gitlab cicd pipeline to push the docker image to container registry so in our previous tutorial of gitlab we have spoke about uh gitlab container registry so we have seen how we can create our Docker images and push it to the gitlab container register rather than using Docker Hub right so now in this topic what we are going to do is we are going to automate that so we'll have a gitlab cicd pipeline to create our Docker image and it will be push the container registry so what will be like you have a you know commit or you know you will have your app in the gitlab repository so for this we are going to use a node.js applications and one you'll have a gitlab cicd pipeline which will use that repository and we will build the image here and we will doing the build on a Docker gitlab Runner so we'll be using a gitlab runner we are going to use to stay Pages here one using the shared Runner and we will also see how we can use a specific Runner which we will install it on a Linux machine and which will have a Docker also and we will see how we can run this uh you know job on a specific Runner using Docker container and also we will see how that can be pushed into our gitlab container registry so in running this Docker container you know in a gitlab runner there is also concept like Docker in Docker so we are going to use that as well in this topic so we can easily run you know our job so we'll use this Docker in Docker Concept in the shared Runner so that you know it can create a Docker container and we will run the docker commands inside that and you know we will create our Docker image and it will be pushed to our gitlab container registry so the whole process we are going to use a node.js application because you will know how to build your Docker image for node.js using this and in the upcoming tutorial we will use this concept into using the deployment of of our node.js application as well so one of the key parameter what you need to understand in this topic is like authenticating with the container registry so you know like in Docker Hub you use Docker login and we need to give our username and password for uh Docker Hub right similar way like in the gitlab container registry there are a few different ways in the previous tutorial we have seen how we can create our personal token right and using that username and password you can log in you know username and the personal token you can log into the Container registry so in uh you know this tutorial we will see different ways but the easiest way is like using the CI CD variable called CI registry user so this is a default variable in gitlab which can be easily used and because you know in every project it will create a CA registry user and a specific password for that and the CI registry is the respective you know repository or container registry for that project so you can just use this default variable so by default it will use that and login so that will applicable for that job alone so we'll use that and also there is another option called CI job token so that also use you know at default a variable like a CI job user and the ca job token and CA registry is the the container registry for that project so this is the one which we spoke like a personal token this one also we can use we can create a personal token for that you know your uh account and you can use that you can use the username and you can use that personal token to log into the CR registry which is the container registry so we will use the first option which is the ca registry user and CA registry password to log into the Container registry and pushing into that so you know before I get into the actual demo I would request you like if you have not subscribed to my Channel or if you are new to my channel kindly click on the Subscribe button and also like my videos share and comment so let's get started so I'm in uh in one of my project called node app test okay and I have the files so you know the node.js you'll have package.json we'll have some files so here in my case it's index.js and you know I have a Docker file which is written uh for uh to build our node.js application so these things I'm not going to explain these are already covered in my previous tutorials so if you are not sure how to write Docker file for your node.js application please have a look on my previous tutorials okay and we also have Docker ignore so you know ignore some of the files and this test is for testing you know the node.js application so what we want to do is we want to containerize or you know dockerize this application and we want to push that into your container registry so for each project you know that there is a container registry which can store your uh you know images right so like a Docker Hub so you can can use this for pushing your you know image and which can be used for deployment as well so what we are going to do is we are going to you know create a no pipeline first so for that you need to create a gitlab hyphen C8 or yaml file and let me show you how to write the pipeline let me open the visual studio code so I already written this uh pipeline code so now if you see I'm using an image called Docker okay so I'm using a Docker image because I don't want to use uh install Docker on a Linux machine and then use that so in gitlab you know a shared Runner it is easy like you just used some of the runner which have a Docker and I'm going to use the image for a Docker itself and I'm going to define a service called not Docker in Docker so that you know we can run all these commands inside the docker image or Docker container okay so the stage that I'm going to have only single stage called build and you know if you the promise like if you split these stages into different stages at the each stage will not run on the same container so then it will not happen correctly so it's it has to be combined all together so that the whole thing can run on the same container and it can finish and it can push it and it can lock out okay so this is a variable I'm just going to set it's not mandatory you can set it directly here itself the name so I'm just setting a container registry name sorry container image name so it's going to be the registry because it has to be this one because you know like when we pushing to The Container registry you need to give your account gitlab slash and your account name slash right and the image name so then only it will can push otherwise it you know like you know Docker Hub also you have to give your username slash and image right so we'll see what will get the outputs and the latest you know I we are I'm hardcoding a latest one you can have you use like test or you can use anything you can also use some variable here so every time when you build a image it can change the values okay so that we will see in the you know tutorial for how to deploy your node.js application this is more of about I want to show you how to create a you know image and then push it so Docker login we spoke like we'll use this variables like uh see a registry user and password and the ca registry is for the container registry name so these are a standard variables in gitlab which you can easily use okay and this one is the variable I have just set it and we are going to run it a Docker file on the home location and we are going to push it the image Docker push which will pushing to the ca you know registry which is the container registry and we'll log out so that should be the overall process so let me just copy it is so I have copied this content into the gitlab hyphen ci.yaml so you can see we are copying those content okay so it's a pretty simple I will give this link so you can make use of you know this link as well so so that's all I know for this uh gitlab hyphen ciml doll you can just go to your pipelines and since I already submitted I'll just run the pipeline so it can start the you know Pipeline on the master Branch okay so you can see it started building so you can see it's running Docker with the image Docker right so let's wait this may take uh some uh time because depending upon the image for node.js it's almost like 1GB of image it has to build the docker image then it has to push it to the container registry as well right so it has to go through the whole process so you let's wait so you can see it's trying to pull the image right so it's trying to build the image so it has already logged in uh with our CR registry user password right now it's building the image using you know the docker files you can see it's running the docker file commands so you can see now it has completed the image creation right and you can see it's a registry.gitlab.com and uh account and the image name and latest right now it's pushing uh to the dock container registry and then it's logging out so it's a whole uh process is completed now if you go to your container registry you should have uh the image over here right you can see it's the latest tag so that's a simple process regarding the you know building the image and pushing into the Container registry now what we have done is here we have used the runner which is a shared Runner right so that that's why it was running on this Runner so I'm just going to disable this and I'm going to create a specific Runner now okay so for that I'm using this machine which in on this I have already Docker installed okay and uh you know I need to install the gitlab runner on on this machine so in order to run the gitlab runner on the Linux machine I already shared this tutorial like how to set up gitlab runner on a Linux machine so these are the some commands so if you just run this it will download the runner then we have to install it so I'm just quickly going through it so if you want to have a detailed tutorial on that just have a look on my tutorial for that but anyhow I will give all these links in the video description so you can use this to download and install the runner so that's downloaded so allow you have to run this command okay so these are so you need to add the gitlab runner so you go to this folder where you'll be able to see the gitlab runner so let's install the gitlab runner okay so it's installed let's start the runner as well okay now we have started Runner now we need to register the runner so in order to register you need to run gitlab runner register and it will ask you to enter the gitlab URL so we need to run gitlab.com if you're running your own instance you have to you know enter based on that you need to go to your project and you need to copy this token you need to run the token and you need to give a description I'm going to call this as my Linux Runner and you need to give a tax and tag is something which is very important because we'll use this tag in our pipeline now because otherwise the pipeline will not know on which Runner it has to run so I'm going to use Docker and shell here okay and now we need to have the executor so you know like every uh you know Runner have an Executor so here we are going to use the shell executor okay so we are not using Docker uh plus machine or Docker because this is a shell uh X hero which we are using so we can see uh the runner is configured properly now if I go back here and refresh and if I go back to the runners you should be able to see the runner is up and green right so before we do that we also need to enable our Docker so I'm going to use systemctl status Docker you can see it's not running so I'm going to start so if I check again now we have this Docker running right and also what we need to do is our gitlab runner need access for our Docker uh no socks so let me also add the gitlab runner as uh you know the permission for the docker group so basically when you install Docker you'll have a group called Docker okay if you don't have it you need to create that and you need to add our gitlab runner into the group otherwise you know when you run the docker commands it will give you a message like it's not able to access the docker you know so and let me also use restart docker so Docker is running so I think we are uh ready with our Docker uh no gitlab Runner so now it's time for going back to our uh you know pipeline so if you see I will return a different kind of pipeline here so we can run the same you know this pipeline as well this will also run on this machine but I just want to show you like we can do it in a separate stages as well because now we are running on a shared Runner which is our specific Runner so all this job will run on the same machine it's not like you know shared Runner like each job will run on on different machines so because of this you can run you know in different stages as well and I will show you like each stage what it happens so now if you see we have uh stages called login build right push logout and I'm setting a variable like container image test and you know in the login job so they should be running on the stage login and we are using the tag as Docker so that you know when you run this pipeline it will detect the runner which is tagged with Docker which is will be our specific Runner so if you don't tag it then it will not run it will be on pending stage because it will not be able to find the runner which it can run okay so now this command with the same command which we are using to log in and the build we are using the same command again to build okay so this time the image will be like with test uh you know not as a latest and uh pushing the docker I'm not running uh the push command so if you use the push what will happen is it will push to the docker container registry but because of you know the size of the image and also it takes a lot of time because of the network connectivity to push it to the container registry I'm just keeping this state but in your case you can put it so you can put this part over here just copy Docker push and put it here uh you know just like this you can just change this to Docker push so it will push the image to The Container registry but I'm just keeping that one alone so I'm just putting a echo thing and the last stage will be Docker logout so I'll copy this content okay so let me go back to our editor and I'll just change the pipeline okay so let me change this to this pipeline script so we have a different Pipeline and let me commit and you can see the pipeline is uh startups or let's wait so you can see the pipeline has started it has four stages now okay the login job let me see it has failed somehow yep the problem here it is now it has failed because it's not able to fetch and the git command not found so what you need to do is uh you need to use a yam install git because you need to have git to run the whole process because it has to download the you know or clone the repository to this machine so git is also required so you need to install git so let me wait for the installation to be completed so git is installed now so let me also show you like if you if I go to docker images we don't have an image at all so now what will happen is when we run the uh you know pipeline it will download the node base image it will build the image and you should be able to see a image with a new tag okay so let's run this uh again so let me go back to the pipeline and let me run the pipeline again so let's see the status it's running so now you see the first job is completed it has logged into the Container registry so it succeeded right so let's go back to the job so we have let's go back to the pipeline let's see what's the second stage okay unfortunately it has failed this stage as well so let's see so I'm not sure why it has fill let me run it again so we'll wait for this time and see so looks like this time it's running so you can see that it started building the container so basically you know I found some issue with the kit so it's trying to you know get fetch rather than using it clone so I had to make a small change in the setting for that as well so I'll show you once this is completed so it's trying to pull the node uh image so we should be able to see once this is pulled the image is also available in our gitlab runner now it started the building uh the image so if I go back to the runner and if I see Docker images you can see node is pulled and it's building the other image so we'll see this none will be changed soon so I will just wait for the building to be completed on the job good looks likes our job is completed and you can see it has created a you know image called registry Dot gitlab.com and my account and also the you know node app test you know so let's see what we have it here so now you see we can see this uh image right and the tag is test so that's what we built here so let's go back to our pipeline now you can see this whole pipeline is completed because we had a push job and we had a logout job as well so the push job as I mentioned I did not put the option to push it to the container registry so if you put it the container registry it will push it to container registry as well okay so it may take a Time based on the how much size of your image it has to push from your specific Runner to The Container registry so the process is same you can just use the two method one is this one you can use Docker in Docker or you can use a shared Runner where you don't have to use dockering Docker you can use you know simple method of different job if you want to split or you can use this same method as well in here as well okay so you can use that as well it will also work you can combine you know without Docker and Docker as well here so this is one of the way you can use our shared Runner so I wanted to show you like how you can use air Runner as well in this tutorial this will be a continuation of our gitlab cicd tutorial for beginners so if you have seen my previous tutorial we have gone through multiple lectures on gitlab cicd like how to you know setup Runners how to build the gitlab you know pipeline to build your image and push it to gitlab container registry so this will be a continuation of that and in this tutorial what we will see is like you know how to set up your gitlab cicd pipeline for a node.js application so when we talk about cicd pipelum it it will be end-to-end pipeline starting from how to build your application test it release it and then even for the deployment into actual production environment so that would be our complete pipeline for this so uh let's discuss on a tutorial we like how our pipeline would look like okay so for example if you're a developer you will have your code you know put it into your gitlab so we show you like a sample node.js project which I'll be putting into the gitlab you know our repository and from gitlab you know we will use our CI CD pipeline so whenever you make a changes in your application it will build your pipeline so we will write the complete pipeline code so I will show you and I will share that as well in in the link so you can download that and you know what we'll do like we already seen in our previous tutorial how to build our image using Docker build Command right so we'll be using a gitlab runner for that and basically it's it is going to be node.js application and we are going to use a Docker in Docker concept which we already discussed and how that will make use of you know uh the docker in Docker concept to build your image and pushing into the Container registry so we'll push that into the gitlab Container registry so till this point you're already aware in our previous tutorial so what we will do from here is like we will have a test so so we will test our node.js application so we create the image so we will once we create the image we will test our node.js applications so once we test it if it pass the test then we will deploy our application to our Docker container so that means using our image we will run our application as a container so these are all will be uh no a pipeline script so once you click uh or make some changes in your code this will automatically happen and your application will be running as a no Docker container so we will see all those things so let's discuss little bit more like what will be the each individual step which we'll be doing it in as part of our continuous deployment of our node.js application so what as I said what we will do is first we will have a node.js application in our gitlab repository so we will commit that so I already have it so I will show you so you can make use of your application for that and we will build the docker image for your node.js application and you know once we build it we will push the docker image to your gitlab container registry and this image we will mark it as a test image okay so it's not the actual release image so we can name it something test or some uh you know variables then we will mark this image as a test image then we will run a test on the node.js application using this test image if the image you know this application is passing the test then we will rename or you know we will tag the test image as a release image and push that into the Container registry again so then we will have two images one for test and once the release because once the test is passed then that will convert into a release image so once we have the release image means like we have a standard or application which can be deployed into your you know production environment then we will use Docker commands to deploy our application as a Docker container using this release image so that will have four stages in our pipeline one will be for build one will be for test and one will be for release and one for deploy so there will be four stages and there will be four jobs running so I'll show you the complete pipeline script how to write that and I will also share that so you can make use of that and once we deploy it we I'll show you like where the container uh the container will be running because we'll have our own uh server running for running this container and rest of other action we will use our you know shared runner for that so before I get to the actual demo of the process I would request you like if you are new to my Channel or if you haven't clicked on the Subscribe button please click on the Subscribe button also click on the Bell icon so also like my video share and comment so let's get started so if you see I have a node.js application so if you see the index.js it's pretty simple and there are two routes one for slash builds so there is no home page which I have put so it's uh if you go to your application and slash well you get a response like response hello world and if it's good slash ready should be like the sense running on the port uh 3000 and if you see there is also uh one uh test uh running so because if you see I have a test.js and that will check the test so you know it's using a super test and the mocha so it's all defined in our package.json so if you see the package.json you have a npm start for index.js and npm test for running this test.js file right so that's how the whole configuration is there and you can also check the docker file we also have a Docker file now if you see the docker file you know this also we have discussed in our a lot of tutorials like how to write your Docker file for your node.js so you have a base image and we are recopying uh making the default directory and we are copying the packet.json to this file and we are installing the npm and we are copying the rest of the other files and then we are exposing the port and we are starting the index.js so that's the overall uh you know npm file Docker file as well so if you don't know you have to check my previous tutorial on that so that's the overall uh you know uh application what we have it and we have this gitlab dot the ml file so before that let me show you uh let me show you the we have a to one Runner setup so if you see there is a runner which is active this Runner we will use it for running our Docker container rest of things will have in our shared runners okay so that's how it will be so now this is the machine which I have set up as a runner and if you see uh Docker PS5 and hey I don't have any containers running so the deployment will happen on this machine so once we run the whole pipeline the deployment will have a container running and we should be able to access our application using the IP address or the host name for this machine okay so let's talk about the whole CI CD pipeline dot yaml file which will use it in the gitlabs or where we'll have this dot gitlab dot uh CCI hyphen ci.aml file okay so what we will do is like let's go through the end-to-end process so you can write you know you or use the same method to build your and deploy your application Edition so now if you see we are starting with the base image which is a Docker image this is because we are using Docker in Docker concept and we are defining the service right and as I said we have four stages one for build one for test and one for release and one for deploy and we are setting this variable so we are using a test image as I told like we'll have two image one for test and one for release so the test image we are using the variable like a container registry name and tag you know commit reference slack and if you see the release image we are using the same container registry image no and the latest so that's how we will use it uh you know as variable if you want to use a different variable that's also fine okay but this is a default variable from gitlab which will use the registry you know values for for that and we already spoke about these variables for example uh we spoke about like uh to log into your gitlab container registry you need to have a user ID and password for authentication right so rather than using a hardcore password we are using the registry variables right for the container registry variable this is a CA registry user and a password and this year registry and this will be you know created uh you know in every job so you don't have to make an order of this because this will takes default from your job so we we spoke about different ways you can do it so this is one of the way you can write your script so why we are giving this before script means this happens on before every job so otherwise if you want run it within job you'll have to put it inside the job now if you see the first job is for us is built and we are also defining the stage as build okay so the stage comes from here which stage it is and the script uh is like we are going to build our application so we are going to build and we are going to name it as a test image and we are using the docker file from our source location and we are going to push the test image using Docker push right so we can see this Docker push contains so this will be pushing our image to our gitlab container registry for this uh you know project so now once this is done we are going to test our application so we are going to use a job as test and you can name it anything but uh no just I'm using test and the stage will be test and you know the commands watch we have to do is now we have to make use of this test image so I'm going to pull this testimony image then I'm going to run the command Docker run and the image and I'm going to call the variables which is our argument so I'm going to use npm test because this I already defined in my application what npm test will do right we have I have already shown you like there is a test dot in JS file and we have already defined the what test inside the package.json right so if this is passing this test phase then it will go to release image so I'm going to call this job as release image and I'm going to put it under the stage release and in this stage what we will do is we will pull the test image and we are going to tag it uh as you know release image because now it has passed the test if he has failed the test it will stop bro stop it there itself now we are going to you know rename or tag the test Images release image and I'm going to push it to the container registry again so now we'll have a release image available in the container registry which is ready for deploy and in the deployment job I'm going to put it on the stage deploy and I'm going to give the tag because my gitlab Runner or the local server which is tagged on the local Docker where we will be running this commands to in run our application so if you have given a different tags you can use that okay because you you run the shared Runners will not be able to get our application we will it will finish this job but you know to access our application I'm using my local server now here you know what we are going to do is we are going to pull the our release image and I'm going to run the docker run command uh with the hyphen D detach mode and hyphen P which is the port which I'm mapping into the port 3000 for application from the host and also from the image now uh now uh the container image which I'm going to use is the release image which is already tested and pushed it to our gitlab registry so this is the overall process so it'll be four stages where we are going to run our applications now if I go back to my you know gitlab project now if you see I already run it once and I have four stages all are passed okay so let me let me run it again so let me go back to the editor so I don't have any changes to be done so I will go just run the pipeline again so now we can see the pipeline has started so it's starting with the build space so if you go to the build you should be able to see what it does it's using the docker in Docker image right so it uses that concept the whole process makes some time depending upon the image it has to pull because if you see it's pulling and building our image you can see you know it is pulling the image and it's uh logging into the Container registry then it's building our image then it will be pushed so you can see it's doing the whole process so as step by step so it may take some time based on how much times it takes you know to build the image and pushing into the Container registry now we can see this job has succeeded and it has pushed the you know uh image the docker container registry so let me go back to the pipeline let's see it's running it's running the second uh stage now so we can go to the test and it will use the image which we push to container registry to run that test as you can see the npm test has been also job succeeded so what it has done it is has pulled the test image and it has run the docker run in PM test so let's go back to our Pipeline and we have our third stage running so which should be for release image so let's go back and check that as you can see the third stage is also succeeded so what it has done is it has retaged the test image as release image and it has pushed to the container registry so let's go back to our final stage which should be on deploying it so that should be our final stage where it has to deploy our application so now we can see it's going to run it on our machine so you can see that is also succeeded so we can see whole uh process is done and let me go back to this machine so if I go back to Docker hyphen PS yep now you can see we have our email you know container running and if I go back to Docker images you should be able to see our latest image over here just four minutes ago right so our container is also running of our application so what we can do is we just need to access this machine uh no access this application using our IP address and the port 3000 so let me use this IP address and let me go to a browser if I if I go to the IP address with the port 3000 and slash wheel you can see the response we are getting hello world right and we have one more route which is uh Slash ready and if I go if you see we got getting uh it works so our application is running fine now and because it's running it as a Docker container now right so you can see Docker hyphen PS it's running using our image which we deployed into our application Docker container registry so that's the overall uh cacd deployment process so if you see the pipeline file which we have created it's not that complicated it's pretty simple but you need to understand the concept what we have done so how to build your image how to push that to container registry how to test your application then if you want to build it as a release image and then how to deploy it as a Docker container so this is the way we are doing uh is a Docker container if you want to know like how to build your application without as a Docker that is also possible you can test your application you can then copy the contents into a you know a server and then you can run it from there as well so that is also possible if you want that to be you know created as a video I will do that as well you can give your feedback on the video or in the YouTube so you can give a comment section you can give your request then I can create a video based on that as well since most of our application now running as a Docker I thought this will be helpful for you guys so we'll be starting uh this session which will be basics of kids so we'll be talking more about uh get GitHub gitlab so what is you know the difference between gate GitHub gitlab uh those things okay so let's start with you know get GitHub and gitlab because there are a lot of uh misconception between you know GitHub gitlab and git so some people think all are same you know some uh doesn't know what's the difference so let's talk about that and first then we will get into more about uh you know the uh in depth of what is git how git works so to start with uh if you have any confusion or if you don't know what is git so git is an open source distributed Version Control software okay and uh why git is used is because that helps you to make or track the changes on a file and that change can be stored into a remote Repository what does it means like you know if you have a software development or if you are making a file a core and you know if you want to keep a track of the changes like who has changed what has been changed when has been changed git is the best option for that there are other tools as well so but the git is one of the tool for Version Control and uh very popular one so that is one of the good option for you okay now you may think you know then what is GitHub or gitlab right so whereas uh GitHub is a repository hosting service okay for hosting these git repositories so what does it means like you know you have uh repositories for git from your local machine you can store it on a uh remote repository which you can be on cloud or it can be your own hosted servers okay the GitHub offers both a free service and paid service and one of the benefit of GitHub is like you know when storing these repositories on GitHub you can easily collaborate with other GitHub users on your project and that that will help like you know some of the features are developed by some other persons and you know you can have multiple persons working on the same repository and you know that help you to easily develop some you know features for your project or your code okay now what is a gitlab so gitlab is also a repository hosting service similar to GitHub okay so it's not a difference like GitHub or gitlab is uh have a major difference both are repository hosting service but from you know different way of doing it okay and the benefit or you know the feature in git lab is gitlab is more focused on devops or CI CD features okay which does not have it on GitHub but GitHub is more popular because it have more repositories more users to collaborate gitlab is not to that extent but you have more features on devops CI CD how to automate your build test deploy to your projects so that is a benefit of gitlab oh so I will get in depth on you know the topics but before that I have a request like kindly click on the Subscribe button support uh me to get you know more you know support from yarn okay and I also would like to request you to like this video share and comment okay so that will help for uh you know giving a thumbs up from your end like a motivation for me and other people you know who can get support uh from watching these videos okay now so let's get into a little bit more uh on this so what we discussed uh just in our recap so what is the difference between git GitHub and gitlab so in simple word git is a version control system or software which will be installed locally on your machine whereas GitHub is a popular git repository hosting service and it's a collaboration platform and whereas gitlab it's a repository hosting service again just similar to GitHub with more CI CDR devops features okay now in order to understand the reason why we have to use git or GitHub or gitlab you need to understand a little bit of the software development life cycle so in software development life cycle you have different phases like requirement design coding or building you know the that's the main place where you will have the major core or the products is developed then you will have testing and then it goes to the deployment or going to the market right so what happens is in this process most the developers assignment simultaneously do the part of the code right and they make the modification on the code and that will make get into some conflict with each other and that's create you know a lot of bugs in the software so that is the word with this repository managers like GitHub or gitlab becomes very useful useful okay okay so we will see why it's useful okay I'll go to the next slides where I'll be talking about how normally a developer use the code and what is the benefit of using GitHub or gitlab or other tools like bitbucket or SVN subversion like that okay so let's see you know why git and git for developer so because if you are Developer or if you are an operational team or devops team you should know like how git is used by actual development team okay so now you have a product or you are doing a core okay uh like Java application or any other application where you'll be writing the code and there may be developer one who will be doing a part of it or developer 2 and there are multiple developers who are working on that code and you know what happens is because this core you know everybody is trying to develop this code from their own part they have versions of their own like developer one will have his own version they will have uh her own version and the three will have his own versions so the problem here is like you know now do you have uh different versions and you know there will be a conflict now uh to merge all these things and you know bring up the all actual product because all of these people have their own uh code on their local machine okay because uh you know they don't they are keeping all the core on their machine but they are trying to make all the changes from their perspective so that is the problem without a source code or Version Control uh you know software so that is why now we'll see how this GitHub or gitlab helps us so using GitHub gate GitHub and gitlab because git is a locally installed software which will help the track of these changes on the local machine as well okay so now again to consider you have uh you know a code or product and you have a developer one right and developer 2 and also developer 3. so and again as we mentioned they have their own versions if they try to uh you know make the changes on the core but the difference is like now the source score or the actual base of the product is now stored on a remote repository which is a GitHub gitlab bit bucket or subversion and from that uh remote repository what we usually do is we'll have a master Branch where where the actual code will be there and you will have a branch now from that Branch these developers will use that code and they will start editing or making their versions and you know they will uh may keep start making the changes but before that uh in the git process what we usually do is you we will clone the master Branch into the locally on your machine and once you clone it uh we will talk about these all these command the git clone or git initiation uh how to create the repositories you know I'm not going to go on that topic here okay because I want to talk about more of uh Basics and the concept in this tutorial so once you clone or you know once you create your uh you know git or upholstery on you locally on the machine what will have it will have two parts one is the local repository and the other one is a working directory so once you start making the changes all the changes happens in the working directory so for example this developer 3 he's making the changes in the core which has been cloned from the master brand which happens in the working directory and from the working directory whatever the changes is in the staging area so then you know you have to commit those changes that will go to the local repository so once you make the changes in the local repository you can push those changes into the master Branch so the master Branch you will get the actual code from the developer tree so it has created a new version in the master brand so previous one maybe V1 I would have a V2 so you know the developer 2 can check out that uh no version and she can start working or you know or she may have the old version and she would have a different version she developed which she can push it back to the master branch and it does not mean that always it has to be a master Branch what usually happens in the organization is like from the master brand you will create Feature Feature branches and the developers will uh you know make the changes from the feature Branch you will create the local repository you will make the changes and you will push those back to the feature Branch so every developer will have their own feature branch and from the future Branch it has to merge into the master branch which will have a approval process and that will be how it has been done okay so that's the overall process will happen in the git so this will benefit is like you know you will have a complete picture of what changes has been done each versions then you can merge you know uh each versions together you to get the overall uh product so there you you can have the conflicts to be fixed and you know you'll have multiple versions if you want to go back to the previous versions all those things can be achieved using the git GitHub and gitlab options okay so git is more of a local machine uh software so where you'll have this you know commands which you will run it from local machine to push it to the GitHub Market lab or it can be subversion or bitbucket or any tools which you prefer to use it but this topic we are talking more about GitHub git that's why I'm talking more about git here okay so this tutorial we are going to talk about gitlab so this will be a gitlab tutorial for beginners and this will be you know a separate tutorial not a continuation of my previous gitlab CI tutorial where we spoke about glass cicd so this is a separate tutorial because a lot of people has asked me like how they can set up a gitlab uh quickly you know on Docker so what we are going to see in this tutorial is like if you know Docker or if you have already worked with Docker how easily you can you know set up a gitlab instance on Docker so you don't have to use the SAS version of gitlab you can I have your own uh gitlab instance where you can use it on Docker and you can create your gitlab repositories you can upload your code you can create private public repositories you can use it for CI CD and all those process you can do using your own gitlab instance so if you see one of my previous tutorial we have shown how to set up gitlab on a normal centers like you can do a basic installation also but this will be much easier you know to start a gitlab instant using Docker quickly and so before we get started on the actual setup on Docker using the commands and all those things those who don't know what is gitlab so basically you know if you want to understand gitlab probably you also need to know git right so I'm sure if you're a developer an operational guy who has used on using version controlling of your core definitely you have used git or subversion or some kind of version controlling system right so git is an open source version controlling system which is commonly used right so where you will have you know this uh you know use your code right you can use local repositories you can have working stage then you can upload it to remote repository right so yeah I have a separate tutorial on get it's like how the whole overall process like how you can clone the git repositories how you can create on the remote repositories how you can commit your code changes how we can push it so all those things have been covered on my previous tutorial which I can link into this video description so you can check on what is git difference between git GitHub gitlab and all those things so whereas you know gitlab is you know it's it's uh not not just a repository for git because uh previously you know it may started with like a general git repository where you can upload your code into a remote repository so that how it was a gitlab but now gitlab has been more developed into a complete devops software so if you go to you know gitlab.com there itself you should see like it's a complete devops platform they're not just talking like gitlab as a git remote repository so now gitlab is a complete software where you can use not only to just manage your code you can plan your CI CD pipeline you can you know do a testing stage you can package it you have gitlab you know package you can store your Docker images to The gitlab Container registry you can then you know you push it you can release the packages you have monitoring you have a lot of things in the gitlab itself so as per definition you can see gitlab is the devops platform delivered as a single application so it's a overall package number in a free version of gitlab sign up you may not get all benefits but you know you can go for Enterprise versions or you can use you know paid versions of gitlab some of the features then you should have the whole features so uh you know I'm not going to talk more about that so but this is what all about gitlab and you can register you know gitlab using gitlab.com you can register for a free account and you can log in and you can create your repository you can push your code and then you can create your cicd pipeline and all those things you can do it with the SAS version because this is the you know SAS version where you can use your internet you can go to gitlab.com and you can create your account now what we are going to talk about in this tutorial is like how you can create the similar kind of gitlab instance on your local machine you don't want to use the SAS version you want to have your own local instance for your Enterprise where you can you want to share with some of the people inside your own local network so you don't want to share it you know as an open application but you can use it for internet through internet as well but you need to make some configuration so it's open through the internet so what we are going to see is like how we can easily set up a gitlab instant is using the docker so if you see I have logged into one of my Docker machine where I have installed docker so you can see I have a Docker install on this machine and you know if you don't know how to set up Docker you need to refer my tutorials on Docker how to set up on syndoice or Ubuntu or windows so there are different even Mac you can set up a Docker so there are all easy installation you can use different method I will link to the send OS how to install Docker on syndoice on this video description which you can reference you can set up your Docker now what I want to do is I want to create a Docker instance on this machine so there are two ways you can do this one is like you can simply run a Docker command like Docker run and you know run the basic command so it will create a container for gitlab and we should be able to access gitlab the other ways you can use Docker compose like you can write your Docker Docker compost.dml file and then you can create your container so once you run the docker compost you should have your container running so what we are going to do is we are going to start with a basic Docker command to create the uh the instance for gitlab in Docker okay so I have already written the command now you can see what we are going to use is Docker run Docker run will create used to run your container and I'm going to use detach uh you can use slash slash detach or it can be just hyphen D to run your container on the back end so that's the detached mode so you know and you I'm going to publish some ports like you want to open the ports from the container to the localhost so there is a 443 for SSL and Port 80 for no more connection and publish 20 to 22. so but in here in this case it's some some machine the port may be used so I'm going to use a different port here for uh from a local machine from container it should be 22 and I'm going to give a name for the container which would be gitlab you can use any name and I'm going to use the parameter where I can restart always and I'm also going to use some volumes so I'm going to use Docker manage volume so it's going to be gitlab underscore config and should be you know Etc gitlab which will be the configuration for gitlab and the locks for gitlab which should be on the wall log gitlab which is also mapped to a volume and also the data which should be VAR opt gitlab and I'm also going to set some memory size so I'm going to use 2GB for this container so the basically you know depending upon the configuration you have if you give more memory it's better you know the system will be able to create the container much faster and you should have better performing container and gitlab instance so if you don't have enough memory you can set less than 2GB as well but I think it will take more time for the container to be set up and you know to access which will be a little slower so I would request you like you give 4GB or more than 2GB which would be good and I'm going to use the image for gitlab which would be gitlab iPhone C which is the Community Edition if you are having Enterprise Edition you can use ee as well so what I'm going to do uses I'm going to just copy this command and I will go to the docker machine and I will paste this command here so we have pasted the command like what we have spoke like Docker run detach mode publishing the ports name of the container restart always and I'm using the volumes and memory size and the image so I'm just running this command so basically if you don't have the image already downloaded on your machine it will download the image then it will create the container so in my case I already have the image so it will create the container directly so you can see it has given the container ID basically in your case if you don't have the image it will take some time it's almost like one one point one GP of memory size so it will take the whole memory to be you know used for the creation of the uh container so now in my case if you see like the port 443 is also allocated so maybe I have to change the ports for all those things in the local then we will use that so I will change this one also to some other ports and here here also maybe I'll change it to port 8080 so I can just change those and I will just run this command again maybe in this case you know I have a gitlab name which would be conflicting because it would have already tried to create a container so let me see so as I mentioned like you know it has given a conflict for gitlab because there is already one container running so let me use you can see there is a container this is a different one so you can see like there is a container for gitlab so I want to remove that Docker arm and I'm going to remove this container so I can use that name again so I will just copy the commands again and I will just paste that here and I will run it so now this time you can see it's trying to create the container and I think it's just created the container as well so now you can see the container is started I can see the health and it's starting so it may take some time so basically what you can do is you can use Docker logs to check the you know what is happening actually in the container because we created the container in the detached modes we want to see what is happening so you can use Docker locks hyphen f and the container ID or the container name so I will use gitlab now you can see it's uh doing a lot of process so basically it takes quite some time to create the whole gitlab instance maybe it takes 10-15 minutes for me it took around 10 to 15 minutes because as I mentioned at my system I have set only 2GB if you have more uh space more RAM I would say like if you put 4GB maybe it will take less than 10 minutes as well so I will wait for this whole process to be completed so that the gitlab instance will be up and running now once the installation is completed or the docker container is created you can see like if you access the your gitlab instance using your IP address and Port 8018 because we configure our localhost to 8080 but if you're using Port 80 just use 80 or you just run the IP address you should be able to get the gitlab instance now you see that it's the exactly the same instance whether it's a SAS version where you can use the open source gitlab.com free registration or you can create your local instant using the docker container what we are shown so once you create it you can access it using uh the IP address of the machine now in order to access this one the username should be root so the username should be root and the password the initial password you need to use the command Docker access ID gitlab which should be the name of your container and you need to grab the pass texture or you can Docker accept your container and you can go to this location Etc gitlab initial root password so there you should have the password stored for this gitlab instance for me in my case this is the password so in your case it should be different passwords so once you get that you can paste that password Here and you can log in to the instance so once you log in you know you should get the basic page where you can see projects right where you can create create new project so what we have used is like as I mentioned you need to use a Docker accept command to get the initial root password and you can get that and you can log in and once you log in you can change the password you can see currently now it's root user you can go to edit profile and you can change the password so you can see it's all completely same as what your gitlab.com this is running on my local instance so that's the only difference so you can do everything you know what you want to do with this instance now this is your own instance running on locally on your Docker container you can create your projects you can push your code you can create your gitlab cicd so all those things you know I have have a complete playlist for gitlab cacd tutorial and you know you can follow those things you to create your application deployment through you know using Docker Hub or gitlab container registry to save gave your Docker images you then you can push it as a Docker container so different ways you can do it so that's the most you know easiest way to create your uh Docker instance using Docker container now what we can do is now what we have seen is like using a normal Docker run Command right now I also have put the details like how you can create using a Docker compose file so it's almost a similar one but you need to put the details into a different method so here I'm going to create two one service called web and I'm going to use the same kind of content like gitlab image which is gitlab iPhone C latest and I'm going to give a container name and restart always and the ports so again here if you want to map it to a different port you need to change the ports here and you know based on what ports is not used on the machine you can use that and I'm going to map the volumes which would be config which is for ETC gitlab and logs and data and I'm also going to set the memory sizes 2GB as I mentioned you can use more than 2GB because for me now if you see it took surround 15 to 20 minutes to create a complete setup of gitlab to have it completely ready so but if you have more memories it may you know quickly complete the process and you should have your gitlab Institute ready okay so the volumes you know whatever we have used here it has to be mapped in here otherwise the docker compose file will not be working so what you can just do is you just need to copy this content and let me create a file so you can just create a file called Docker compose dot DML and you can install insert those contents what we have copied uh from there so don't worry I will give all these details in my GitHub link so I which will have a link into this video description you can just uh check those so now we have a file called dockercompose.dml so you should have uh that one ready now you know so what you can simply do is you should have Docker compose setup along with your Docker so you can just use Docker compose up and if you want to run it in detached mode just run it in detached mode so in our case we cannot run it now because I already have a gitlab container running and all these ports are used so I need to change to a different container and I have to change the ports as well but you know you can just simply run this it will do the same thing like what we have shown it will create a container and you should be able to access the gitlab using your IP address of the host and you know basically whatever Port you're mapping you need to use that when you create run the you know instance using your IP address so in its 480 means you can just run it and also one more thing is like in case if the ports are blocked you can use a firewall commands to open those ports in your local machine otherwise you should you will not be able to access the gitlab Instant using your web browser so open those ports and just reboot your firewall and I will give all those comments in the GitHub link which will be I will link into this video description so follow those so in this tutorial we have seen how to set up gitlab on Docker using Docker a normal run command and also using Docker combo so I hope it's an informative tutorial for you version or if you want your own instance of git install gitlab as you see in this tutorial if you have not subscribed to my channel kindly do so and provide your comments let's get started go to the webpage about.gitlab.com install which have the official documentation on how to set up gitlab for the installation 4GB of RAM is recommended we are going to set up gitlab incentos if you are using any other operating system choose the same and follow the instructions [Music] [Music] foreign [Music] [Music] foreign [Music] [Music] foreign [Music] [Music] foreign [Music] [Music] thank you [Music] nothing [Music] [Music] [Music] [Music] nothing [Music] foreign [Music] [Music] [Music] [Music] [Music] foreign [Music] [Music] [Music] [Music] [Music] puppy [Music] foreign [Music] [Music] [Music] thank you [Music] please [Music] foreign [Music] [Music] [Music] foreign [Music] [Music] [Music] foreign [Music] [Music] [Music] foreign [Music] [Music] [Music] nothing [Music] great the installation is completed now open the git web page using the IP address of your host machine it will direct you to the login page and will ask you to set a new password give a new password and log into the git you can check the settings and create new projects in gitlab upload your content in respective branch foreign [Music] [Music] [Music] foreign [Music] [Music] [Music] [Music] thank you foreign [Music] [Music] we will be using git in our upcoming videos on cicd we will have Jenkins pull the code from git and run the build jobs I hope this tutorial is informative for you thank you for watching kindly subscribe to my channel and like the video [Music]
Info
Channel: Thetips4you
Views: 57,378
Rating: undefined out of 5
Keywords: gitlab, gitlab ci cd tutorial, cicd and devops, cicd, gitlab runner, gitlab tutorial, gitlab ci cd docker, gitlab build pipeline, gitlab ci cd demo, gitlab ci docker, gitlab ci/cd tutorial, gitlab ci/cd docker, gitlab ci, what is gitlab, setup ci/cd pipeline gitlab, gitlab ci cd pipeline, gitlab ci cd kubernetes, gitlab ci/cd getting started, gitlab ci cd zero to hero, gitlab ci cd full course, gitlab ci cd from zero to hero, continuous integration, continuous deployment
Id: Typ9U6k6g5s
Channel Id: undefined
Length: 175min 37sec (10537 seconds)
Published: Mon Aug 15 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.