diff --git a/README.md b/README.md index 225ae66..995bce6 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ My personal solution is a local, docker-based CI/CD Build Environment ready in a * docker-compose version >= 1.15.0 ## Installation +### without sonar Bring up your own build environment ... just do a ``` git clone https://github.com/Springjunky/docker-local-build-environment.git @@ -25,6 +26,20 @@ Bring up your own build environment ... just do a docker-compose up --build -d docker-compose logs ``` + +### with sonar +Warning: you need a lot of memory to use the full toolset (more than 10GB) +``` + git clone https://github.com/Springjunky/docker-local-build-environment.git + cd docker-local-build-environment + sudo ./setupEnvironment.sh + docker-compose -f docker-compose.yml -f docker-compose-sonar.yml up --build + docker-compose logs +``` + + + + ### The first startup takes a long time (especially gitlab), so be patient 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 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. ### Sonar -In future releases Sonar will be added...(You need to install some rules (Administration - System - Update Center - Available - Search: Java) +You need to install some rules (Administration - System - Update Center - Available - Search: Java) ### Nexus Some ToDo for me described here @@ -162,7 +177,7 @@ every ping must work, if not, check extra_hosts in compose-file * ~~install ansible~~ * ~~apply a gitlab runner~~ * ~~apply git-lfs~~ -* apply sonar +* ~~apply sonar~~ * apply a better registry diff --git a/docker-compose-sonar-part.yml.template b/docker-compose-sonar-part.yml.template deleted file mode 100644 index e35990b..0000000 --- a/docker-compose-sonar-part.yml.template +++ /dev/null @@ -1,26 +0,0 @@ - sonar-db: - image: postgres - environment: - - POSTGRES_USER=sonar - - POSTGRES_PASSWORD=sonar - volumes: - - BASE_DATA_DIR/sonar-db/postgresql:/var/lib/postgresql - # This needs explicit mapping due to - # https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52 - - BASE_DATA_DIR/sonar-db/postgresql_data:/var/lib/postgresql/data - networks: - - devstacknetwork - sonar: - image: sonarqube - extra_hosts: - - HOSTNAME:HOSTIP - - networks: - - devstacknetwork - environment: - - SONARQUBE_JDBC_URL=jdbc:postgresql://sonar-db:5432/sonar - volumes: - - BASE_DATA_DIR/sonar/sonarqube_conf:/opt/sonarqube/conf - - BASE_DATA_DIR/sonar/sonarqube_data:/opt/sonarqube/data - - BASE_DATA_DIR/sonar/sonarqube_extensions:/opt/sonarqube/extensions - - BASE_DATA_DIR/sonar/sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins diff --git a/docker-compose-sonar.yml b/docker-compose-sonar.yml new file mode 100644 index 0000000..0179a49 --- /dev/null +++ b/docker-compose-sonar.yml @@ -0,0 +1,35 @@ + +# docker-sonar configuration, +# add this to your docker-compose up if you want to have sonarqube +# docker-compose -f docker-xcompose.yml -f docker-compose-sonar.yml up +version: "3" + +services: + postgres: + image: postgres + extra_hosts: + - ${DC_HOSTNAME}:${DC_HOSTIP} + networks: + - devstacknetwork + environment: + - POSTGRES_USER=sonar + - POSTGRES_PASSWORD=sonar + volumes: + - ${DC_BASE_DATA_DIR}/postgres-db/postgresql:/var/lib/postgresql + # This needs explicit mapping due to + # https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52 + - ${DC_BASE_DATA_DIR}/postgres-db/postgresql_data:/var/lib/postgresql/data + + sonar: + image: sonarqube + extra_hosts: + - ${DC_HOSTNAME}:${DC_HOSTIP} + networks: + - devstacknetwork + environment: + - SONARQUBE_JDBC_URL=jdbc:postgresql://postgres:5432/sonar + volumes: + - ${DC_BASE_DATA_DIR}/sonar/sonarqube_conf:/opt/sonarqube/conf + - ${DC_BASE_DATA_DIR}/sonar/sonarqube_data:/opt/sonarqube/data + - ${DC_BASE_DATA_DIR}/sonar/sonarqube_extensions:/opt/sonarqube/extensions + - ${DC_BASE_DATA_DIR}/sonar/sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins diff --git a/docker-compose.yml b/docker-compose.yml index 43a764a..8a44470 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,11 +20,15 @@ services: # SSH Bypassing into gitlab, if you want to change this edit nginx.conf also - "2222:2222" #ssh port of gitlab (ssh://git@myHOST:2222/scott/foo.git) - "5555:5555" #Gitlab Docker Registry do NOT use 5000, this is an internal PORT of the gitlab-ce Image + depends_on: # start proxy after all the others + - gitlab + - jenkins + - nexus networks: - devstacknetwork # ------------------------------------------------------------------------------ - jenkins-fat: + jenkins: build: jenkins-fat extra_hosts: - ${DC_HOSTNAME}:${DC_HOSTIP} diff --git a/nginx-reverse/reverse-proxy.conf b/nginx-reverse/reverse-proxy.conf index 9a7dc63..8bc3e6c 100644 --- a/nginx-reverse/reverse-proxy.conf +++ b/nginx-reverse/reverse-proxy.conf @@ -1,5 +1,6 @@ -# Setting all teh prefixes is a crazy .. +# Setting all the prefixes is a crazy .. + server { listen 80; server_name "" ; @@ -13,7 +14,7 @@ server { # Same like ENV JENKINS_OPTS=.....--prefix=/jenkins in jenkins-fat/Jenkins-Dockerfile location ^~/jenkins { - proxy_pass http://jenkins-fat:8080; + proxy_pass http://jenkins:8080; include /etc/nginx/conf.d/proxy-settings.conf; } @@ -22,11 +23,16 @@ server { proxy_pass http://nexus:8081; include /etc/nginx/conf.d/proxy-settings.conf; } -#Future Use -# # Same like sonar.web.context=/sonar in preconfig/sonar/sonar.properties -# location ^~/sonar { -# proxy_pass http://sonar:9000; -# include /etc/nginx/conf.d/proxy-settings.conf; -# } +#Future Use + # Same like sonar.web.context=/sonar in preconfig/sonar/sonar.properties + location ^~/sonar { + # prevent nginx to throw errors if sonar + # is not available + # 127.0.0.11 is the Docker DNS + resolver 127.0.0.11 valid=05s; + set $sonarvm sonar; + proxy_pass http://$sonarvm:9000; + include /etc/nginx/conf.d/proxy-settings.conf; + } } diff --git a/preconfig/sonar/sonar.properties b/preconfig/sonar/sonar.properties index 5b0101b..4110e12 100644 --- a/preconfig/sonar/sonar.properties +++ b/preconfig/sonar/sonar.properties @@ -1,2 +1,2 @@ -# Only one Property is need +# Only one Property is need (because sonar ist behind nginx) sonar.web.context=/sonar