You are currently viewing Jenkins Nexus SonarQube Docker-Compose: Build The DevOps environment – Cool 4 components!
Could You Please Share This Post? I Appreciate It And Thank YOU! :) Have A Nice Day!
4.8
(1331)

This is another my post in which I present how to build DevOps env (Jenkins Nexus SonarQube Docker-Compose) in a simple way how to set up the environment using the benefits of Docker-Compose.

Jenkins Nexus SonarQube Docker-Compose

This time we will focus on an example where we will configure an environment consisting of:

Jenkins

The leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project.

SonarQube + PostgreSQL

SonarQube is an automatic code review tool to detect bugs, vulnerabilities, and code smells in your code. It can integrate with your existing workflow to enable continuous code inspection across your project branches and pull requests.

PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance. –

Nexus

The free artifact repository with universal format support. Single source of truth for all of your components, binaries, and build artifacts. Efficiently distribute parts and containers to developers. Deployed at more than 100,000 organisations globally.

docker-compose.yml

version: "3"
services:
  jenkins:
    image: jenkinsci/blueocean
    container_name: jenkins
    environment:
      - DOCKER_HOST=tcp://localhost:2375
      - JENKINS_UC=http://updates.jenkins.io
      - JENKINS_UC_EXPERIMENTAL=http://updates.jenkins.io/experimental
      - JENKINS_INCREMENTALS_REPO_MIRROR=http://repo.jenkins-ci.org/incrementals
    user: root
    ports:
      - "8080:8080"
      - "8443:8443"
      - "50000:50000"  
    expose:
      - "8080"
    volumes:
      - jenkins-data:/var/jenkins_home
      - jenkins-home:/home


  nexus:
    image: sonatype/nexus3
    container_name: nexus
    volumes:
      - "nexus-data:/nexus-data"
    ports:
      - "8081:8081"
    expose:
      - "8081"

  sonarqube:
    image: sonarqube
    container_name: sonarqube
    ports:
      - "9000:9000"
    environment:
      - sonar.jdbc.url=jdbc:postgresql://db:5432/sonar
    volumes:
      - sonarqube_conf:/opt/sonarqube/conf
      - sonarqube_data:/opt/sonarqube/data
      - sonarqube_extensions:/opt/sonarqube/extensions

  db:
    image: postgres
    environment:
      - POSTGRES_USER=sonar
      - POSTGRES_PASSWORD=sonar
    volumes:
      - postgresql:/var/lib/postgresql
      # This needs explicit mapping due to https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52
      - postgresql_data:/var/lib/postgresql/data

volumes:
  nexus-data: {}
  jenkins-data: {}
  jenkins-home: {}
  sonarqube_conf: {}
  sonarqube_data: {}
  sonarqube_extensions: {}
  postgresql: {}
  postgresql_data: {}

Check Container Status

Before we start the further part of the configuration, check that all containers are in “UP” status.

docker-compose ps
          Name                        Command               State                                    Ports                                  
--------------------------------------------------------------------------------------------------------------------------------------------
jenkins                    /sbin/tini -- /usr/local/b ...   Up      0.0.0.0:50000->50000/tcp, 0.0.0.0:8080->8080/tcp, 0.0.0.0:8443->8443/tcp
jenkins_nexus_sonar_db_1   docker-entrypoint.sh postgres    Up      5432/tcp                                                                
nexus                      sh -c ${SONATYPE_DIR}/star ...   Up      0.0.0.0:8081->8081/tcp                                                  
sonarqube                  ./bin/run.sh                     Up      0.0.0.0:9000->9000/tcp 

Jenkins – First Run

The Jenkins user interface is available at: http://localhost:8080

At the first start we will be asked to enter the administrator password, which is saved in the file: /var/jenkins_home/secrets/initialAdminPassword, which is located on the container file system with Jenkins. To open the contents of this file we must “enter” this container using SSH. To do this, run the following command from the terminal:

# docker exec -it <docker_container_name>  /bin/bash
docker exec -it jenkins /bin/bash

Once inside the container, run the command below. The string is our administrator password.

cat /var/jenkins_home/secrets/initialAdminPassword
1367d1e351194e839abb21682498e63d

Plugins Installation

Następnie zainstaluj sugerowane wtyczki. Jest to zbiór podstawowych rozszerzeń, które można traktować jako pakiet startowy.

And than:

Creating an Administrator Account

The next step is to create an administrator account.

After creating the admin account, we can fully use Jenkins.

Nexus – First Run

The Nexus user interface is available at: http://localhost:8081

When you try to log in for the first time, we will receive information that the admin user password has been generated and is located under the path: /nexus-data/admin.password. Let’s check the password!

Using the command below we will enter to the Nexus container.

docker exec -it nexus /bin/bash

cat /nexus-data/admin.password
05feffa3-f8e3-49ed-b765-002d6b90d2a5

We paste the above password into the login form. Then we will be asked to set your password, which I encourage.

SonarQube – First Run

The SonarQube user interface is available at: http://localhost:9000

Click the “Log-in” button in the upper right corner. The default administrator user is admin and the password is also admin.

Summary

As you can see, creating an environment with docker-compose is really easy. In a few minutes we can create and start using tools.

To sum up, below is a list of URLs to: Jenkins, Nexus and SonarQube.

Could You Please Share This Post? 
I appreciate It And Thank YOU! :)
Have A Nice Day!

BigData-ETL: image 7YOU MIGHT ALSO LIKE

How useful was this post?

Click on a star to rate it!

Average rating 4.8 / 5. Vote count: 1331

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?