How to Install SonarQube in Azure Linux VM | Setup SonarQube with Docker Compose in Linux VM

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in this video we are going to learn how to set up sonar Cube on a VM running in Azure Cloud so we are going to pick up Ubuntu as an example where we are going to configure sonar Cube and we are going to use Docker compose in order to install sonar Cube all right so let's look at the agenda so what we are going to do we are going to set up a brand new virtual machine running in Azure cloud and then we will open up port number 22 and then port number 9000 in the security firewall rule because port number 9000 is the default port number for sonar Cube and then port number 22 for SSH into it and then we will install Docker compose because we are going to use Docker compose to configure a sonar Cube and then we will create a Docker compose file that is going to have two different containers one is for sonar Cube and then another one is for postgresql and then we will execute Docker compose up command in order to set up the containers and then we will just verify the log file just to make sure that everything is working fine and then we will login into sonar Cube dashboard just to make sure that sonar cube is up and running it's pretty straightforward awesome so let's get started guys so this is my website coachdevops.com I will be posting the link uh right below the video as well so before we get started so why don't we take a look at this honor Cube architecture so basically sonar Cube contains three major components so one is called cacd scanner right so this is the one which is going to scan the source code and then it will find out box in the source code and then the second comment is called sonar Cube server so this is nothing but the UI the UI component and then the third compound is called database server so this is where you know we will be storing the analysis reports or all the rules and everything will be stored in the database server the database server can be anything it can be Oracle it can be postgres equal or it can be MSS SQL all right so let's login into Azure portal let's create a VM first create Azure virtual machine I do have a separate video on how to spin up a VM so I'm going to go real fast I'm going to use my existing Resource Group so let me give a name sonar VM okay I'm going to use Ubuntu server 18.04 gen 2. okay and we need to have at least 4 GB memory let me see what I'm actually stating here if I look at the prerequisites yeah so at least you know we need to have 4GB Ram okay I think this is fine and we are going to use I'm going to use my existing SSH keys but if you don't have one you can create new one it's not a problem you'll be using this option this this drop down but I already have my key so I'm going to go ahead with my key existing key perfect and then this is the default port number okay and go to the networking section so let's select this option okay so whenever I delete the VM I also want to make sure that the public IP address as well as NSC also deleted okay so that's pretty much over there let's go ahead and then click on review and create and we will open up port number 9000 right after we create the VM click on create the VM is created let's go to Virtual Machine sonar VM so let's connect to the VM right now go to connect click on SSH so we are going to copy this URL so I'm going to SSH minus I so this was the key that was the key we have used and just copy this one so this is the username and this is a public IP address that's it say yes perfect so now I am logged inside uh so on our qvm perfect so before we do anything let's just make sure uh we also open up port number 9000 as well so go to add in Portal and we are going to add port number 9000 TCP that's the protocol so that's pretty much over there okay and then add okay okay very good the rule has been added so let's start the installation um so so before we start the installation right I just wanted to uh show you how you should approach the installation right let's go to Google and then let's type sonar Cube download so when you go here it will take you to the sonar Cube websites as you can see here uh there are like different editions available but of course we are going to go ahead and then install a download Community Edition okay so you can directly click on this uh you know this is going to download the zip file but we are not going to use this approach okay why because this has lot of manual steps like you know you need to download the zip extract the zip and you need to configure a database as well you need to install Java a lot of manual steps okay so we are going to avoid that so let's actually go to the documentation let's try to find out if there is any better approach okay so let's go to the setup and upgrade and click on install the server so when you see here as you can see here you see here so this is one of the options right which which I was just talking about we are not going to go with this approach okay like you know downloading the as if file and extracting and then if you scroll down a little bit further uh again solar cube is based on Java so we need to have Java installed but if we are going to use Docker you don't have to worry about that you know the image has everything so the second option is you know you can set up sonar Cube from the Dockery page but again if you look at here right there are a lot of manual steps here you need to create a volume run the container this is the sonar Cube Contender and then you also need to run postgres SQL container as well lot of manual steps right so we are going to avoid that as well so what we are going to do we are going to use Docker compose okay so Docker compost is nothing but um you know you can run multi-container base you can run multi-container applications using Docker compose so you just have to create the docker compose file and then you just execute Docker composer boom right all your containers will be up and running so if you look at the uh compose file uh so we have two containers right so this is one container so this is the docker image Docker image uh for sonar cube right so we are going to download the community addition and then the second container if you see here so that's a postgresql postgres equal 12 version okay and then this is nothing but the username and password in order for sonar Cube to connect to postgresql and that's again mentioned over here okay and this is the database schema this is the database schema which is sonar okay Yeah so basically we are going to create this file and then we are going to execute a Docker compose up that's it right so your sonar Cube should be up and running all right so that is the uh you know reason behind installation okay all right but before we do again uh if you go back to the documentation uh if you click on prerequisites uh if you scroll down further scroll down further where do you look for the Linux platform nodes there you go you Seeger so if you are setting up on Linux machine we need to make sure that this part is taken care okay so I have already captured that as part of my prerequisites so before we start the installation we need to take care of that so let's let's get started all right so let me copy this and I'm going to go all the way to the end of the file copy these two entries perfect and then come out of it so we have to restart the VM but you can avoid that by executing this command perfect so we are able to see what we supposed to see perfect so let's move on to the next step so now we are going to go ahead and then perform through the APD update uh but before the let's change the host name actually the host name to sonar Cube so logged in again so everything is good so let's go ahead and perform update and then we will also go ahead and then install Docker compose as well so like I said you know Docker composes a utility for uh running multi-controller based applications perfect so let's quickly check the docker compose version okay very good so that's the version so I think it doesn't matter so we are good so darker compose is installed so let's create the docker compose file so like I said you know I have picked up the sample uh the actual file from there and then I have I made minor changes so so if you see here um you know I have added this one so when you add like this whenever you restart the VM your sonar Cube will be up and running okay so that's what that that is for so I have just added that I have added that over here okay format is kind of messed up so let me quickly fix this perfect so so this is the file okay let me save this file so now what I'm going to do I'm going to go ahead of the next good Docker compose up and I'm going to run on the detached mode so we don't have to worry about you know having the control over the console perfect so it is in the process of you know downloading the docker image okay so now it is downloading uh sonar Cube Docker image okay perfect uh let me quickly check the docker images here there you go guys so these two images are there so perfect I think right now uh containers should be coming up so why don't we quickly check the log files I'm going to go ahead and then check the logs there you go so as you can see here it is in the process of coming up and if you also check the log as well there you go you see here so that's the MySQL postgresql entries right it says that server started very good so now let's go all the way down here perfect and of course you can see in the log itself that it is creating a data source added the connection right so it is very much you know connecting to postgresql so that's the connection string perfect so this also confirms that sonar cube is operational very good so let me press Ctrl C so came out of it so now let's quickly access the sonar Cube so the default port number for sonar cube is port number 9000 so let's copy the public IP address of the VM and go to browser let's access this there you go guys so it is in the process of coming up so the default username and password for sonar cube is admin admin so let me enter that so it will immediately ask you to change the password so let me go ahead and then uh provide the password so we need to change it let's change it I'm going to admin123 wonderful wow there you go guys you see here so that is our sonar cube right now guys so that is the sonar Cube running on VM running in Azure cloud thank you guys so that's all I have for this video maybe in the next video what we will do is we will integrate sonar cube with Azure devops so so we will try this particular lab so we will integrate sonar cube with Azure devops okay and then we will try to you know pick up a project and then you know try to set up cacd Pipeline and then we will run some code analysis awesome guys so looking forward to see you guys in the next video thank you
Info
Channel: DevOps Coach
Views: 3,344
Rating: undefined out of 5
Keywords: SonarQube Setup on Azure, SonarQube Tutorials
Id: Vy84daqSxFs
Channel Id: undefined
Length: 15min 2sec (902 seconds)
Published: Tue Feb 14 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.