Skip to content

Commit ee91494

Browse files
committed
Correct the DNS-Lookup for the guest-host (leaving DNS-Space of docker compose network)
Remove Sonar ... in Future-Releases it will be optional
1 parent 70aee64 commit ee91494

10 files changed

+134
-118
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
docker-compose.yml
2+
docker-compose.yml-*
3+
*.jpi
4+
*.war

README.md

+23-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## docker-local-build-environment
22

3-
##### Tired of endless installation and configuration .... ?!
3+
##### Tired of endless installation and configuration .... ?!
44

5-
My personal solution is a local Build Environment with Jenkins, Gitlab, Sonar and Nexus; ready in a few minutes.
5+
My personal solution is a local Build Environment with Jenkins, Gitlab, (Sonar) and Nexus; ready in a few minutes.
66
Your own lokal, personal, continous build enviroment (maybe in future releases I just call it lpcbe).
77

88
### System requirements
@@ -15,23 +15,25 @@ Bring up your own build environment ... just do a
1515
```
1616
git clone https://github.com/Springjunky/docker-local-build-environment.git
1717
cd docker-local-build-environment
18-
sudo ./prepareCompose.sh
18+
sudo ./prepareCompose.sh
1919
docker-compose up --build -d
20-
docker-compose logs
20+
docker-compose logs
2121
```
2222
### The first startup takes a long time (especially gitlab), so be patient
2323

24-
open your favorite browser (_not_ at localhost, use the $(hostname)/jenkins )
24+
open your favorite browser (_not_ at localhost, use the $(hostname)/jenkins )
2525
to prevent jenkins spit out "your reverse proxy is wrong")
2626

2727
### Ready !
2828

2929
Now you are ready to go with a little CI/CD Environment:
3030
```
3131
Jenkins http://<your-host-name>/jenkins
32-
Sonar http://<your-host-name>/sonar
3332
Nexus http://<your-host-name>/nexus
3433
Gitlab http://<your-host-name>/gitlab
34+
in the next Release: Sonar http://<your-host-name>/sonar
35+
36+
3537
```
3638
#### Security
3739
... not really, its all http .. don't worry about it! It's only local communication
@@ -65,11 +67,11 @@ iptables -N EXTERNAL-ACCESS-DENY
6567
iptables -A EXTERNAL-ACCESS-DENY -j LOG --log-prefix "DCKR-EXT-ACCESS-DENY:" --log-level 6
6668
iptables -A EXTERNAL-ACCESS-DENY -j DROP
6769
68-
# Block all incomming traffic for docker
70+
# Block all incomming traffic for docker
6971
iptables -A DOCKER-USER -i $EXTERNAL_INTERFACE \
7072
-p tcp --match multiport \
7173
--dports $PORTS_TO_BLOCK \
72-
-j EXTERNAL-ACCESS-DENY
74+
-j EXTERNAL-ACCESS-DENY
7375
7476
# Restore default rule to return all the rest back to the FORWARD-Chain
7577
iptables -A DOCKER-USER -j RETURN
@@ -100,11 +102,11 @@ echo "See logs with prefix DCKR-EXT-ACCESS-DENY:"
100102

101103
### Giltab
102104

103-
* the docker-registry is at port 5555 (and secured with an openssl certificate ..thats part of
104-
prepareCompose.sh), just create a project in gitlab and click at the registry tab to show
105+
* the docker-registry is at port 5555 (and secured with an openssl certificate ..thats part of
106+
prepareCompose.sh), just create a project in gitlab and click at the registry tab to show
105107
how to login to the project registry and how to tag your images
106108
* ssh cloning and pushing is at port 2222
107-
109+
108110
#### gitlab-runner
109111
The runner is a gitlab-multirunner image with a docker-runner (concurrent=1) , based on [gitlab/gitlab-runner][2] The docker-compose section has an environment called
110112
REGISTER_MODE, it can set to KEEP or REFRESH
@@ -120,7 +122,7 @@ It takes a long time until gitlab is ready to accept a runner registration, if i
120122
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.
121123

122124
### Sonar
123-
You need to install some rules (Administration - System - Update Center - Available - Search: Java)
125+
In future releases Sonar will be added...(You need to install some rules (Administration - System - Update Center - Available - Search: Java)
124126

125127
### Nexus
126128
Some ToDo for me described here
@@ -132,23 +134,27 @@ And _yes_ docker-plugin in jenkins works (docker in docker, usefull but not reco
132134

133135
## Troubleshooting
134136

135-
In most cases a wrong DNS-Server causes trouble, to check this try the follwing.
137+
In most cases a wrong HOSTNAME:HOSTIP causes trouble, to check this try the follwing.
136138
* log into the sonarcube container (with id)
137139
```
138140
docker container ls
139-
docker container exec -it <your id> bash
141+
docker container exec -it dockerlocalbuildenvironment_jenkins-fat_1 bash
142+
apt-get update
143+
apt-get install -y --allow-unauthenticated iputils-ping
140144
ping google.de
141145
ping jenkins-fat
146+
ping gitlab
147+
ping <your local hostname>
142148
```
143-
both ping must be work
149+
every ping must work, if not, check extra_hosts in compose-file
144150

145151
* consider low memory:
146152
with an amount lower than 8GB sonar and eleastic search did not startup
147153

148154
* too many plugins to download:
149155
You can do an "pre download of the plugins", see the readme.md at jenkins-fat direcory
150156

151-
157+
Docker-Networing insider docker-compose causes the parameter
152158

153159
### My next steps
154160

@@ -157,6 +163,7 @@ both ping must be work
157163
* ~~install docker-compose~~
158164
* ~~install ansible~~
159165
* ~~apply a gitlab runner~~
166+
* apply sonar
160167
* apply git-lfs
161168

162169

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
sonar-db:
2+
image: postgres
3+
environment:
4+
- POSTGRES_USER=sonar
5+
- POSTGRES_PASSWORD=sonar
6+
volumes:
7+
- BASE_DATA_DIR/sonar-db/postgresql:/var/lib/postgresql
8+
# This needs explicit mapping due to
9+
# https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52
10+
- BASE_DATA_DIR/sonar-db/postgresql_data:/var/lib/postgresql/data
11+
networks:
12+
- devstacknetwork
13+
sonar:
14+
image: sonarqube
15+
extra_hosts:
16+
- HOSTNAME:HOSTIP
17+
18+
networks:
19+
- devstacknetwork
20+
environment:
21+
- SONARQUBE_JDBC_URL=jdbc:postgresql://sonar-db:5432/sonar
22+
volumes:
23+
- BASE_DATA_DIR/sonar/sonarqube_conf:/opt/sonarqube/conf
24+
- BASE_DATA_DIR/sonar/sonarqube_data:/opt/sonarqube/data
25+
- BASE_DATA_DIR/sonar/sonarqube_extensions:/opt/sonarqube/extensions
26+
- BASE_DATA_DIR/sonar/sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins

docker-compose.yml.template

+30-47
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#####################################
2-
# Don't touch this file is generated
2+
# Don't touch this file is generated
33
# expecilly for: HOSTNAME
44
###################################
55
#
@@ -11,51 +11,34 @@ networks:
1111
devstacknetwork:
1212
driver: bridge
1313

14-
services:
14+
services:
15+
# ------------------------------------------------------------------------------
1516
ngnix:
1617
build: nginx-reverse
17-
ports:
18-
- "80:80" #http://
18+
ports:
19+
- "80:80" #http://
1920
# SSH Bypassing into gitlab, if you want to change this edit nginx.conf also
2021
- "2222:2222" #ssh port of gitlab (ssh://git@myhostname:2222/scott/foo.git)
2122
- "5555:5555" #Gitlab Docker Registry do NOT use 5000, this is an internal PORT of the gitlab-ce Image
2223
networks:
2324
- devstacknetwork
25+
26+
# ------------------------------------------------------------------------------
2427
jenkins-fat:
2528
build: jenkins-fat
26-
dns: DNS_SERVER
29+
extra_hosts:
30+
- HOSTNAME:HOSTIP
2731
networks:
2832
- devstacknetwork
2933
volumes:
30-
- BASE_DATA_DIR/jenkins:/var/jenkins_home
34+
- BASE_DATA_DIR/jenkins:/var/jenkins_home
3135
- /var/run/docker.sock:/var/run/docker.sock
32-
sonar-db:
33-
image: postgres
34-
environment:
35-
- POSTGRES_USER=sonar
36-
- POSTGRES_PASSWORD=sonar
37-
volumes:
38-
- BASE_DATA_DIR/sonar-db/postgresql:/var/lib/postgresql
39-
# This needs explicit mapping due to
40-
# https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52
41-
- BASE_DATA_DIR/sonar-db/postgresql_data:/var/lib/postgresql/data
42-
networks:
43-
- devstacknetwork
44-
sonar:
45-
image: sonarqube
46-
dns: DNS_SERVER
47-
networks:
48-
- devstacknetwork
49-
environment:
50-
- SONARQUBE_JDBC_URL=jdbc:postgresql://sonar-db:5432/sonar
51-
volumes:
52-
- BASE_DATA_DIR/sonar/sonarqube_conf:/opt/sonarqube/conf
53-
- BASE_DATA_DIR/sonar/sonarqube_data:/opt/sonarqube/data
54-
- BASE_DATA_DIR/sonar/sonarqube_extensions:/opt/sonarqube/extensions
55-
- BASE_DATA_DIR/sonar/sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
36+
37+
# ------------------------------------------------------------------------------
5638
gitlab:
5739
image: 'gitlab/gitlab-ce:latest'
58-
dns: DNS_SERVER
40+
extra_hosts:
41+
- HOSTNAME:HOSTIP
5942
networks:
6043
- devstacknetwork
6144
environment:
@@ -79,29 +62,29 @@ services:
7962
- BASE_DATA_DIR/gitlab/config:/etc/gitlab
8063
- BASE_DATA_DIR/gitlab/logs:/var/log/gitlab
8164
- BASE_DATA_DIR/gitlab/data:/var/opt/gitlab
82-
65+
# ------------------------------------------------------------------------------
66+
nexus:
67+
image: sonatype/nexus3
68+
extra_hosts:
69+
- HOSTNAME:HOSTIP
70+
networks:
71+
- devstacknetwork
72+
environment:
73+
- NEXUS_CONTEXT=nexus
74+
volumes:
75+
- BASE_DATA_DIR/nexus:/nexus-data
76+
77+
# ------------------------------------------------------------------------------
8378
gitlabrunner:
8479
build: gitlabrunner
85-
dns: DNS_SERVER
86-
networks:
87-
- devstacknetwork
80+
network_mode: "host"
81+
extra_hosts:
82+
- HOSTNAME:HOSTIP
8883
environment:
89-
- DOCKER_DNS=DNS_SERVER
9084
- GITLAB_URL=http://HOSTNAME/gitlab
9185
- REGISTER_TOKEN=s3cretToken4Runner
9286
- REGISTER_MODE=FRESH #KEEP register a new runner an keep it. FRESH unregister all runners and always install a new (pipeline-history lost!)
9387
- REGISTER_TRYS=60 # every 10 seconds a try to register the runner..gitlab takes a long time to startup
9488
volumes:
9589
- BASE_DATA_DIR/gitlab-runner/config:/etc/gitlab-runner
9690
- /var/run/docker.sock:/var/run/docker.sock
97-
nexus:
98-
image: sonatype/nexus3
99-
dns: DNS_SERVER
100-
networks:
101-
- devstacknetwork
102-
environment:
103-
- NEXUS_CONTEXT=nexus
104-
volumes:
105-
- BASE_DATA_DIR/nexus:/nexus-data
106-
107-

gitlabrunner/entrypointAutoregister

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ if test $REGISTER_MODE = "FRESH" -o $RUNNER_IS_PRESENT -ne 0 ; then
3838
gitlab-runner register -n --url=${GITLAB_URL} --registration-token=${REGISTER_TOKEN} \
3939
--executor=docker --name=docker-multi-runner \
4040
--run-untagged=true --locked=false --docker-image=docker:latest \
41-
--docker-privileged
41+
--docker-privileged \
42+
--docker-extra-hosts="jarvis:192.168.34.98"
4243
REGISTERED=$?
4344
if [ $REGISTERED -ne 0 ] ; then
4445
echo "${GITLAB_URL} not ready $TRYS trys left, next try in 10 second for ${GITLAB_URL}"
@@ -52,9 +53,10 @@ if test $REGISTER_MODE = "FRESH" -o $RUNNER_IS_PRESENT -ne 0 ; then
5253
gitlab-runner verify --delete
5354
sleep 1
5455
gitlab-runner register -n --url=${GITLAB_URL} --registration-token=${REGISTER_TOKEN} \
55-
--executor=docker --name=docker--multi-runner \
56+
--executor=docker --name=docker-multi-runner \
5657
--run-untagged=true --locked=false --docker-image=docker:latest \
57-
--docker-privileged
58+
--docker-privileged \
59+
--docker-extra-hosts="jarvis:192.168.34.98"
5860
fi
5961
done
6062
fi

jenkins-fat/Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,25 @@ COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groov
9393
# jenkins version being bundled in this docker image
9494
# This is the latest stable version
9595
ARG JENKINS_VERSION
96-
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.73.2}
96+
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.89.2}
9797

9898
#### jenkins.war checksum, download will be validated using it
99-
ARG JENKINS_SHA=1489e498f682e8b61ce4cf8124de200f264b087c
99+
ARG JENKINS_SHA=cf7be0af90e310a3232bcf1d6c80902788d5ebae
100100

101101
ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war
102102

103103
# could use ADD but this one does not check Last-Modified header neither does it allow to control checksum
104104
# see https://github.com/docker/docker/issues/8331
105-
RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war && echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha1sum -c -
105+
# RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war && echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha1sum -c -
106106

107107
#------------------ Optional lokal caching of files
108108
# Download jenkins with yout favorite browser and put the war in the current dir.
109-
#COPY jenkins-war-2.73.2.war /usr/share/jenkins/jenkins.war
109+
COPY jenkins-war-2.89.2.war /usr/share/jenkins/jenkins.war
110110
###### # Copy all Cached plugins ...
111111
# to preLoad all Plugins listed in active-plugins.txt use the command
112112
# ./preDownload.sh $(cat active-plugins.txt)
113113
# this will download all the plugins in th Folder Plugins
114-
# COPY Plugins/* /usr/share/jenkins/ref/plugins/
114+
COPY Plugins/* /usr/share/jenkins/ref/plugins/
115115
#------------------ Optional lokal caching of files end block
116116

117117
ENV JENKINS_UC https://updates.jenkins.io

jenkins-fat/active-plugins.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ace-editor
21
analysis-collector
2+
ace-editor
33
analysis-core
44
ansible
55
ansicolor
@@ -77,11 +77,9 @@ jquery-ui
7777
jsch
7878
junit
7979
lastfailureversioncolumn
80-
lastsuccessdescriptioncolumn
8180
lastsuccessversioncolumn
8281
ldap
8382
m2release
84-
m2-repo-reaper
8583
mailer
8684
mapdb-api
8785
matrix-auth

jenkins-fat/preDownload.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ do
44
then
55
echo "Already downloaded ${datei} "
66
else
7-
wget -P Plugins https://updates.jenkins.io/2.73/latest/${datei}.hpi
7+
wget -P Plugins https://updates.jenkins.io/2.89/latest/${datei}.hpi
88
mv Plugins/${datei}.hpi Plugins/${datei}.jpi
99
echo
1010
fi

0 commit comments

Comments
 (0)