ci-infra-demo

Repository that contains configuration to quickly deploy following tools with docker-compose:

  1. nginx

  2. jenkins

  3. nexus

  4. sonarqube

Initial conditions

2 VMs with docker and docker-compose installed and static IP addresses

Docker installation

  1. Install docker

    1. /etc/docker/daemon.json example

      {
        "storage-driver": "overlay2",
        "insecure-registries": [
        ],
        "log-driver": "json-file",
        "log-opts": {
          "max-size": "100m",
          "max-file": "3"
        }
      }
    2. To start docker after VM reboot

      systemctl enable docker
  2. Install docker-compose

  3. To be able run sonarqube execute following commands on the VM where sonarcube will be placed

    sysctl -w vm.max_map_count=262144
    sysctl -w fs.file-max=65536
    ulimit -n 65536
    ulimit -u 4096

Deploying infra

First VM will host only nexus, second is for all other components

First VM

  1. Execute

    mkdir poc
    cd poc
    mkdir -p volumes/nexus/nexus-data
    mkdir volumes/nexus/sonatype-work
    chmod -R 777 volumes
  2. Place vm1.yaml to poc dir

  3. Execute

    docker-compose -f vm1.yaml up -d
  4. Verify installation

    docker ps
  5. Navigate to <vm1_ip>:8081/nexus and login. Initial admin password can be seen by command

    cat volumes/nexus/sonatype-work/nexus3/admin.password
  6. To create any kind of registry - maven/docker/npm and so on - navigate to Server administration and configuration → Repositories → Create repository, but we will use default maven-releases repository that is already in nexus

Second VM

  1. Execute

    mkdir poc
    cd poc
    mkdir -p volumes/jenkins
    mkdir -p volumes/sonarqube/conf
    mkdir volumes/sonarqube/data
    mkdir volumes/sonarqube/extensions
    mkdir volumes/sonarqube/logs
    mkdir volumes/sonarqube/bundled-plugins
    mkdir volumes/postgresql
    chmod -R 777 volumes
  2. Place vm2.yaml and nginx.conf to poc dir

  3. Change ip addresses in nginx.conf to yours

  4. Execute

    docker-compose -f vm2.yaml up -d
  5. Verify installation

    docker ps
  6. All tools should be accessible

    1. <vm2_ip>/nexus

    2. <vm2_ip>/sonarqube

    3. <vm2_ip>/jenkins

  7. Default credentials for sonarqube are admin/admin

  8. In sonarqube navigate to Administration → Marketplace and install java and jacoco plugins

  9. Initial jenkins configuration

    1. Following instructions, enter initial admin password that can be displayed using command

      cat volumes/jenkins/secrets/initialAdminPassword
    2. Following instructions, install default plugins and create first admin user

    3. Navigate to 'configure jenkins → manage plugins' and install Multibranch Scan Webhook Trigger plugin

    4. Create jenkins secrets (left panel in main menu)

      1. username/password for sonarqube with id sonarqube

      2. username/password for nexus with id nexus

      3. ssh key for git, public key should be added in your github profile settings

    5. Using the same job multibranch configuration, as in deployed jenkins, create the same job, but in configuration specify your git credentials and fork repository from https://github.com/TolikT/springboot-sample

    6. ip addresses in gradle.properties of springboot-sample repository should be changed to yours