Skip to content

Commit 7354d8a

Browse files
authored
Merge pull request #1 from Springjunky/SONAR
Sonar added
2 parents 2b884f0 + 25a119e commit 7354d8a

File tree

6 files changed

+72
-38
lines changed

6 files changed

+72
-38
lines changed

README.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ My personal solution is a local, docker-based CI/CD Build Environment ready in a
1717
* docker-compose version >= 1.15.0
1818

1919
## Installation
20+
### without sonar
2021
Bring up your own build environment ... just do a
2122
```
2223
git clone https://github.com/Springjunky/docker-local-build-environment.git
@@ -25,6 +26,20 @@ Bring up your own build environment ... just do a
2526
docker-compose up --build -d
2627
docker-compose logs
2728
```
29+
30+
### with sonar
31+
Warning: you need a lot of memory to use the full toolset (more than 10GB)
32+
```
33+
git clone https://github.com/Springjunky/docker-local-build-environment.git
34+
cd docker-local-build-environment
35+
sudo ./setupEnvironment.sh
36+
docker-compose -f docker-compose.yml -f docker-compose-sonar.yml up --build
37+
docker-compose logs
38+
```
39+
40+
41+
42+
2843
### The first startup takes a long time (especially gitlab), so be patient
2944

3045
open your favorite browser (_not_ at localhost, use the $(hostname)/jenkins )
@@ -121,7 +136,7 @@ It takes a long time until gitlab is ready to accept a runner registration, if i
121136
Gitlab is very very fast with new releases and sometimes the api has breaking changes. If something does not work take a look at the Jenkins Bugtracker.
122137

123138
### Sonar
124-
In future releases Sonar will be added...(You need to install some rules (Administration - System - Update Center - Available - Search: Java)
139+
You need to install some rules (Administration - System - Update Center - Available - Search: Java)
125140

126141
### Nexus
127142
Some ToDo for me described here
@@ -162,7 +177,7 @@ every ping must work, if not, check extra_hosts in compose-file
162177
* ~~install ansible~~
163178
* ~~apply a gitlab runner~~
164179
* ~~apply git-lfs~~
165-
* apply sonar
180+
* ~~apply sonar~~
166181
* apply a better registry
167182

168183

docker-compose-sonar-part.yml.template

-26
This file was deleted.

docker-compose-sonar.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
# docker-sonar configuration,
3+
# add this to your docker-compose up if you want to have sonarqube
4+
# docker-compose -f docker-xcompose.yml -f docker-compose-sonar.yml up
5+
version: "3"
6+
7+
services:
8+
postgres:
9+
image: postgres
10+
extra_hosts:
11+
- ${DC_HOSTNAME}:${DC_HOSTIP}
12+
networks:
13+
- devstacknetwork
14+
environment:
15+
- POSTGRES_USER=sonar
16+
- POSTGRES_PASSWORD=sonar
17+
volumes:
18+
- ${DC_BASE_DATA_DIR}/postgres-db/postgresql:/var/lib/postgresql
19+
# This needs explicit mapping due to
20+
# https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52
21+
- ${DC_BASE_DATA_DIR}/postgres-db/postgresql_data:/var/lib/postgresql/data
22+
23+
sonar:
24+
image: sonarqube
25+
extra_hosts:
26+
- ${DC_HOSTNAME}:${DC_HOSTIP}
27+
networks:
28+
- devstacknetwork
29+
environment:
30+
- SONARQUBE_JDBC_URL=jdbc:postgresql://postgres:5432/sonar
31+
volumes:
32+
- ${DC_BASE_DATA_DIR}/sonar/sonarqube_conf:/opt/sonarqube/conf
33+
- ${DC_BASE_DATA_DIR}/sonar/sonarqube_data:/opt/sonarqube/data
34+
- ${DC_BASE_DATA_DIR}/sonar/sonarqube_extensions:/opt/sonarqube/extensions
35+
- ${DC_BASE_DATA_DIR}/sonar/sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins

docker-compose.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ services:
2020
# SSH Bypassing into gitlab, if you want to change this edit nginx.conf also
2121
- "2222:2222" #ssh port of gitlab (ssh://git@myHOST:2222/scott/foo.git)
2222
- "5555:5555" #Gitlab Docker Registry do NOT use 5000, this is an internal PORT of the gitlab-ce Image
23+
depends_on: # start proxy after all the others
24+
- gitlab
25+
- jenkins
26+
- nexus
2327
networks:
2428
- devstacknetwork
2529

2630
# ------------------------------------------------------------------------------
27-
jenkins-fat:
31+
jenkins:
2832
build: jenkins-fat
2933
extra_hosts:
3034
- ${DC_HOSTNAME}:${DC_HOSTIP}

nginx-reverse/reverse-proxy.conf

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
# Setting all teh prefixes is a crazy ..
2+
# Setting all the prefixes is a crazy ..
3+
34
server {
45
listen 80;
56
server_name "" ;
@@ -13,7 +14,7 @@ server {
1314

1415
# Same like ENV JENKINS_OPTS=.....--prefix=/jenkins in jenkins-fat/Jenkins-Dockerfile
1516
location ^~/jenkins {
16-
proxy_pass http://jenkins-fat:8080;
17+
proxy_pass http://jenkins:8080;
1718
include /etc/nginx/conf.d/proxy-settings.conf;
1819
}
1920

@@ -22,11 +23,16 @@ server {
2223
proxy_pass http://nexus:8081;
2324
include /etc/nginx/conf.d/proxy-settings.conf;
2425
}
25-
#Future Use
26-
# # Same like sonar.web.context=/sonar in preconfig/sonar/sonar.properties
27-
# location ^~/sonar {
28-
# proxy_pass http://sonar:9000;
29-
# include /etc/nginx/conf.d/proxy-settings.conf;
30-
# }
26+
#Future Use
27+
# Same like sonar.web.context=/sonar in preconfig/sonar/sonar.properties
28+
location ^~/sonar {
29+
# prevent nginx to throw errors if sonar
30+
# is not available
31+
# 127.0.0.11 is the Docker DNS
32+
resolver 127.0.0.11 valid=05s;
33+
set $sonarvm sonar;
34+
proxy_pass http://$sonarvm:9000;
35+
include /etc/nginx/conf.d/proxy-settings.conf;
36+
}
3137

3238
}

preconfig/sonar/sonar.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# Only one Property is need
1+
# Only one Property is need (because sonar ist behind nginx)
22
sonar.web.context=/sonar

0 commit comments

Comments
 (0)