I'm going to describe how to build up this statck end end flow in this example. Here, I've chosen Ubuntu as the operating system.
Requirements
SERVER | IP ADDRES |
---|---|
ubuntu | 192.168.0.10 |
dependencies
all the appliction are should running as a container. so you need to install the docker daemon and docker-compose binary in your local machine. If your not installed in your execution machine please installit first. please follow below the instaructions.
If you are utilising a cloud virtual computer, take note. You must permit all port traffic. If you'd like to restrict access, we can do that later.
docker installation commands
echo -e "\e[1;31mdocker installation"
sudo apt update
sudo apt install curl git -y
sudo apt-get install ca-certificates curl gnupg lsb-release -y
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
sudo apt update -y
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
sudo systemctl start docker
sudo systemctl status docker
docker compose installtion
echo -e "\e[1;31mdocker-compose installation"
sudo curl -SL https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version
Avoid permission issue you can switch the root user.
sudo -i
copy the source repository to your virtual machine
git clone https://github.com/FourTimes/java-docker-ansible.git
cd java-docker-ansible
sonar installation
sudo sysctl vm.max_map_count=262144
cd sonar
bash sonar-installation.sh
once execute the command you can validate the docker container status. It should be up and running.
sudo docker ps
Note It should return, up and running status
sonar login console
open your browser with http://192.168.0.10:9000
default credentials
- username is admin
- password is admin
it will request to change the default password.
1
2
Create the sonar project click Manually
3
Give the project name and other details. finally you should CLICK the generate the button
4
SELECT continue
5
SELECT others next Linux
copy the sonar project credenatials and Save it some we can you use the application integration
6
SELECT project icon
jenkins installtion
cd ..
cd jenkins
sudo bash jenkins-installation.sh
once execute the command you can validate the docker container status. It should be up and running.
jenkins console access
open your browser with http://192.168.0.10:8080 Once load the jenkins web pages It should ask default password.
how to find the jenkins default password
sudo docker exec -ti jenkins-sonarqube-1 bash
cat /var/jenkins_home/secrets/initialAdminPassword
exit
copy the password and login to jenkins
1
SELECT first option
2
It will install the plugin nased on the inital setup
3
Create the initial admin user setup
4
Configure the instance configuration
5
Jenkins login page console
6
after login you can see the page look like this
create the virtual machine deployment process
Create the ssh-keys for key less authetication
sudo docker exec -ti jenkins-sonarqube-1 bash
ssh-keygen
cat /root/.ssh/id_rsa.pub
exit
login into terget machine
ssh [email protected]
vim ~/.ssh/authorized_keys # paste the id_rsa.pub key from top of the command
exit
Note: If this is not executable you cannot connect from ansible server or jenkins to target machine. Here jenkins server act as ansible server.