Skip to content

Commit 2e92051

Browse files
author
tom
committed
Toolstack more complete
1 parent ffcd777 commit 2e92051

24 files changed

+789
-151
lines changed

README.md

+64-16
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,87 @@
11
## docker-local-build-environment
22

3-
### Tired of endless installation and configuration .... ?!
4-
5-
My personal solution is a local Build Environment with Jenkins full of plugins and sonar; ready in 60sec. with a
6-
lokal, personal, continous build enviroment (maybe in future releses I just call it lpcbe).
3+
##### Tired of endless installation and configuration .... ?!
74

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

8+
### System requirements
9+
* At least 8GB Memory with 3GB Swap and 10GB Disk-Space
10+
* docker version >= 17.06.0
11+
* docker-compose version >= 1.15.0
912

13+
## Installation
1014
Bring up your own build environment ... just do a
1115
```
12-
git clone https://github.com/Springjunky/docker-local-build-environment.git
16+
https://github.com/Springjunky/docker-local-build-environment.git
1317
cd docker-local-build-environment
14-
docker-compose up -d
18+
sudo ./prepareCompose.sh
19+
docker-compose up --build -d
1520
docker-compose logs
1621
```
17-
open your favorite browser (_not_ at localhost, use http\://\<your-fq-hostname\>/jenkins
22+
### The first startup takes a long time (especially gitlab), so be patient
23+
24+
open your favorite browser (_not_ at localhost, use the $(hostname)/jenkins )
1825
to prevent jenkins spit out "your reverse proxy is wrong")
19-
and cut and paste the jenkins first startup access-token (see logfile of compose-startup).
2026

2127
### Ready !
2228

23-
Now you are ready to go with a little continouse build environment and Sonar code-quality check.
29+
Now you are ready to go with a little CI/CD Environment:
30+
```
31+
Jenkins http://<your-host-name>/jenkins
32+
Sonar http://<your-host-name>/sonar
33+
Nexus http://<your-host-name>/nexus
34+
Gitlab http://<your-host-name>/gitlab
35+
```
36+
#### Security
37+
... not really, its all http .. don't worry about it! It's only local communication
38+
39+
### Logins and Passwords
40+
41+
|Image | User | Password |
42+
|---|---|---|
43+
|Jenkins| admin| admin |
44+
|Sonar|admin|admin|
45+
|Nexus | admin | admin123 |
46+
|Gitlab | root | choosen Password |
47+
48+
## The Tools
49+
### Jenkins
50+
51+
* MAVEN_HOME is /opt/maven
52+
* JAVA_HOME is /usr/lib/jvm/java-8-openjdk-amd64
53+
* Blue Ocean is installed and works perfect with a GitHUB Account, not GitLab ... sorry, this is Jenkins.
54+
You need to be logged in to use Blue Ocean
2455

25-
* Jenkins resides under http\://\<your-host-name\>/jenkins
26-
* Sonar resides under http\://\<your-host-name\>/sonar
56+
### Giltab
57+
58+
* the docker-registry is at port 5555 (and secured with an openssl certificate ..thats part of
59+
prepareCompose.sh), just create a project in gitlab and click at the registry tab to show
60+
how to login to the project registry and how to tag your images
61+
* ssh cloning and pushing is at port 2222
62+
63+
#### Jenkins and Gitlab
64+
65+
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.
66+
67+
### Sonar
68+
You need to install some rules (Administration - System - Update Center - Available - Serach: Java)
69+
70+
### Nexus
71+
Some ToDo for me described here
72+
[Unsecure docker-registry in Nexus][1]
73+
use GitLab as a secured registry
2774

28-
After docker ist up you only have to configure your tools in Jenkins
2975
..
3076
And _yes_ docker-plugin in jenkins works (docker in docker, usefull but not recommended)
3177

3278

3379
### My next steps
3480

35-
* Pump up the Image with latest docker, ansible, gitlab and Sonatype Nexus to get a _full_ CI/CD Environment
36-
* move the personal DNS-Server outsite the docker-compose (ENV) at this time it is hardcode in the compose-file
37-
* optimze Dockerfiles to use less number of layers during build
38-
81+
* give you some more preconfiguratiom
82+
* apply a gitlab runner
83+
* apply git-lfs
84+
85+
3986

87+
[1]: https://support.sonatype.com/hc/en-us/articles/217542177-Using-Self-Signed-Certificates-with-Nexus-Repository-Manager-and-Docker-Daemon

docker-compose.yml

+48-37
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,72 @@
1-
# This version maps
2-
# Jenkins to http://your-host/jenkins
3-
# Sonar to http://your-host/sonar
4-
# If you want to change the mapping you have to do
5-
# the following.
6-
# Jenkins: Edit Dockerfile of Jenkinst (--prefix=/jenkins) at top
7-
# Edit location in the reverse-proxy.conf
8-
# Sonar: Edit sonar.properties in directory sonar.properties
9-
# Edit location in the reverse-proxy.conf
10-
1+
#####################################
2+
# Don't touch this file is generated
3+
# expecilly for: tom-VirtualBox
4+
###################################
5+
#
6+
# Consider to Backup /home/tom/devstack-data
7+
#
118
version: "3"
129
services:
13-
1410
ngnix:
1511
build: nginx-reverse
1612
ports:
17-
- "80:80"
18-
13+
- "80:80" #http://
14+
# SSH Bypassing into gitlab, if you want to change this edit nginx.conf also
15+
- "2222:2222" #ssh port of gitlab (ssh://git@myhostname:2222/scott/foo.git)
16+
- "5555:5555" #Gitlab Docker Registry do NOT use 5000, this is an internal PORT of the gitlab-ce Image
1917
jenkins-fat:
2018
build: jenkins-fat
21-
# Change this if your lokal-DNS Server does not match, use to resolve your local host via local DNS
2219
dns: 192.168.178.1
2320
volumes:
24-
- jenkins_home:/var/jenkins_home
21+
- /home/tom/devstack-data/jenkins:/var/jenkins_home
2522
- /var/run/docker.sock:/var/run/docker.sock
2623
sonar-db:
2724
image: postgres
2825
environment:
2926
- POSTGRES_USER=sonar
3027
- POSTGRES_PASSWORD=sonar
3128
volumes:
32-
- postgresql:/var/lib/postgresql
29+
- /home/tom/devstack-data/sonar-db/postgresql:/var/lib/postgresql
3330
# This needs explicit mapping due to
3431
# https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52
35-
- postgresql_data:/var/lib/postgresql/data
36-
32+
- /home/tom/devstack-data/sonar-db/postgresql_data:/var/lib/postgresql/data
3733
sonar:
38-
build: sonarqube-custom
39-
# Change this if your lokal-DNS Server does not match, use to resolve your local host via local DNS
34+
image: sonarqube
4035
dns: 192.168.178.1
4136
environment:
4237
- SONARQUBE_JDBC_URL=jdbc:postgresql://sonar-db:5432/sonar
4338
volumes:
44-
- sonarqube_conf:/opt/sonarqube/conf
45-
- sonarqube_data:/opt/sonarqube/data
46-
- sonarqube_extensions:/opt/sonarqube/extensions
47-
- sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
48-
49-
#These are docker-volumes, reside in /var/lib/docker
50-
# ... consider host-volumes if you want to have an easy backup
51-
volumes:
52-
sonarqube_conf:
53-
sonarqube_data:
54-
sonarqube_extensions:
55-
sonarqube_bundled-plugins:
56-
postgresql:
57-
postgresql_data:
58-
jenkins_home:
59-
jenkins_home_docker:
39+
- /home/tom/devstack-data/sonar/sonarqube_conf:/opt/sonarqube/conf
40+
- /home/tom/devstack-data/sonar/sonarqube_data:/opt/sonarqube/data
41+
- /home/tom/devstack-data/sonar/sonarqube_extensions:/opt/sonarqube/extensions
42+
- /home/tom/devstack-data/sonar/sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
43+
gitlab:
44+
image: 'gitlab/gitlab-ce:latest'
45+
dns: 192.168.178.1
46+
environment:
47+
GITLAB_OMNIBUS_CONFIG: |
48+
external_url 'http://tom-VirtualBox/gitlab'
49+
gitlab_rails['gitlab_shell_ssh_port'] = 2222
50+
# docker-registry config
51+
registry_external_url 'https://tom-VirtualBox:5555'
52+
registry_nginx['listen_port'] = 5555
53+
registry_nginx['listen_https'] = true
54+
# SSL config just for the docker-registry need
55+
nginx['ssl_certificate'] = "/etc/gitlab/ssl/tom-VirtualBox.crt"
56+
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/tom-VirtualBox.key"
57+
registry_nginx['proxy_set_headers'] = {
58+
"X-Forwarded-Proto" => "https",
59+
"X-Forwarded-Ssl" => "on"
60+
}
61+
volumes:
62+
- /home/tom/devstack-data/gitlab/config:/etc/gitlab
63+
- /home/tom/devstack-data/gitlab/logs:/var/log/gitlab
64+
- /home/tom/devstack-data/gitlab/data:/var/opt/gitlab
65+
nexus:
66+
image: sonatype/nexus3
67+
dns: 192.168.178.1
68+
environment:
69+
- NEXUS_CONTEXT=nexus
70+
volumes:
71+
- /home/tom/devstack-data/nexus:/nexus-data
6072

61-

docker-compose.yml.template

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#####################################
2+
# Don't touch this file is generated
3+
# expecilly for: HOSTNAME
4+
###################################
5+
#
6+
# Consider to Backup BASE_DATA_DIR
7+
#
8+
version: "3"
9+
services:
10+
ngnix:
11+
build: nginx-reverse
12+
ports:
13+
- "80:80" #http://
14+
# SSH Bypassing into gitlab, if you want to change this edit nginx.conf also
15+
- "2222:2222" #ssh port of gitlab (ssh://git@myhostname:2222/scott/foo.git)
16+
- "5555:5555" #Gitlab Docker Registry do NOT use 5000, this is an internal PORT of the gitlab-ce Image
17+
jenkins-fat:
18+
build: jenkins-fat
19+
dns: DNS_SERVER
20+
volumes:
21+
- BASE_DATA_DIR/jenkins:/var/jenkins_home
22+
- /var/run/docker.sock:/var/run/docker.sock
23+
sonar-db:
24+
image: postgres
25+
environment:
26+
- POSTGRES_USER=sonar
27+
- POSTGRES_PASSWORD=sonar
28+
volumes:
29+
- BASE_DATA_DIR/sonar-db/postgresql:/var/lib/postgresql
30+
# This needs explicit mapping due to
31+
# https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52
32+
- BASE_DATA_DIR/sonar-db/postgresql_data:/var/lib/postgresql/data
33+
sonar:
34+
image: sonarqube
35+
dns: DNS_SERVER
36+
environment:
37+
- SONARQUBE_JDBC_URL=jdbc:postgresql://sonar-db:5432/sonar
38+
volumes:
39+
- BASE_DATA_DIR/sonar/sonarqube_conf:/opt/sonarqube/conf
40+
- BASE_DATA_DIR/sonar/sonarqube_data:/opt/sonarqube/data
41+
- BASE_DATA_DIR/sonar/sonarqube_extensions:/opt/sonarqube/extensions
42+
- BASE_DATA_DIR/sonar/sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
43+
gitlab:
44+
image: 'gitlab/gitlab-ce:latest'
45+
dns: DNS_SERVER
46+
environment:
47+
GITLAB_OMNIBUS_CONFIG: |
48+
external_url 'http://HOSTNAME/gitlab'
49+
gitlab_rails['gitlab_shell_ssh_port'] = 2222
50+
# docker-registry config
51+
registry_external_url 'https://HOSTNAME:5555'
52+
registry_nginx['listen_port'] = 5555
53+
registry_nginx['listen_https'] = true
54+
# SSL config just for the docker-registry need
55+
nginx['ssl_certificate'] = "/etc/gitlab/ssl/HOSTNAME.crt"
56+
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/HOSTNAME.key"
57+
registry_nginx['proxy_set_headers'] = {
58+
"X-Forwarded-Proto" => "https",
59+
"X-Forwarded-Ssl" => "on"
60+
}
61+
volumes:
62+
- BASE_DATA_DIR/gitlab/config:/etc/gitlab
63+
- BASE_DATA_DIR/gitlab/logs:/var/log/gitlab
64+
- BASE_DATA_DIR/gitlab/data:/var/opt/gitlab
65+
nexus:
66+
image: sonatype/nexus3
67+
dns: DNS_SERVER
68+
environment:
69+
- NEXUS_CONTEXT=nexus
70+
volumes:
71+
- BASE_DATA_DIR/nexus:/nexus-data
72+

jenkins-fat/Dockerfile

+22-21
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,33 @@ ENV JAVA_VERSION=8 \
44
JAVA_UPDATE=131 \
55
JAVA_BUILD=11 \
66
JAVA_HOME="/usr/lib/jvm/default-jvm"
7+
78
# update dpkg repositories and install tools
9+
810
RUN apt-get update
9-
RUN apt-get install -y openjdk-8-jdk
10-
RUN apt-get install -y --no-install-recommends apt-utils
11-
RUN apt-get install -y git
12-
RUN apt-get install -y wget
13-
RUN apt-get install -y curl
14-
RUN apt-get install -y graphviz
11+
#------------ Open JDK
12+
RUN apt-get install -y openjdk-8-jdk
13+
#------------ Tools f Jenkins and apt-get to use SSL Repositorys
14+
RUN apt-get install -y --no-install-recommends apt-utils git wget curl graphviz \
15+
apt-transport-https ca-certificates software-properties-common
16+
#------------ Docker
17+
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg > docker-public-key && apt-key add docker-public-key && rm docker-public-key
18+
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
19+
RUN apt-get update && apt-get install -y docker-ce
20+
#------------ Docker Compose
21+
RUN curl -o /usr/bin/docker-compose -L "https://github.com/docker/compose/releases/download/1.15.0/docker-compose-$(uname -s)-$(uname -m)" \
22+
&& chmod +x /usr/bin/docker-compose
1523

1624
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
1725

1826
# This is the line for the Jenkins prefix to set ... remember
1927
# to set the location in the reverse-proxy.conf
2028
ENV JENKINS_OPTS="--webroot=/var/cache/jenkins/war --prefix=/jenkins"
21-
29+
ENV GIT_SSL_NO_VERIFY=1
2230
#-----------------------------------------------
2331
# install Oracle Java if you want ... and
2432
# remove the line "RUN apt-get install -y openjdk-8-jdk"
33+
# and uncomment the next lines
2534
# above ... but openjdk is pretty good !
2635
#-----------------------------------------------
2736
#------------ Download
@@ -40,14 +49,11 @@ RUN wget --no-verbose -O /tmp/apache-maven-3.2.5.tar.gz http://archive.apache.or
4049
# verify checksum
4150
RUN echo "b2d88f02bd3a08a9df1f0b0126ebd8dc /tmp/apache-maven-3.2.5.tar.gz" | md5sum -c
4251
# install maven
43-
RUN tar xzf /tmp/apache-maven-3.2.5.tar.gz -C /opt/
44-
RUN ln -s /opt/apache-maven-3.2.5 /opt/maven
45-
ENV MAVEN_HOME /opt/maven
52+
RUN tar xzf /tmp/apache-maven-3.2.5.tar.gz -C /opt/ && ln -s /opt/apache-maven-3.2.5 /opt/maven
53+
ENV MAVEN_HOME /opt/maven
4654
ENV PATH $MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH
4755

48-
RUN apt-get update && apt-get install -y zip unzip
49-
RUN rm -rf /opt/java/src.zip && rm -rf /tmp/$filename
50-
RUN rm -f /tmp/apache-maven-3.2.5.tar.gz
56+
RUN apt-get update && apt-get install -y zip unzip && rm -rf /opt/java/src.zip && rm -rf /tmp/$filename && rm -f /tmp/apache-maven-3.2.5.tar.gz
5157
#------------------------------
5258
# install Jenkins
5359
#------------------------------
@@ -80,12 +86,12 @@ COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groov
8086

8187
# jenkins version being bundled in this docker image
8288
ARG JENKINS_VERSION
83-
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.71}
89+
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.79}
8490

8591
# jenkins.war checksum, download will be validated using it
86-
ARG JENKINS_SHA=71b2b5ba6d7fca261325682639ba604b7b889e7e
92+
ARG JENKINS_SHA=272e035475837b5e1c4efb84c8b65949e3f658a3
8793

88-
# Can be used to customize where jenkins.war get downloaded from http://updates.jenkins-ci.org/download/war/2.57/jenkins.war
94+
# Can be used to customize where jenkins.war get downloaded from http://updates.jenkins-ci.org/download/war/2.79/jenkins.war
8995
ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war
9096

9197
# could use ADD but this one does not check Last-Modified header neither does it allow to control checksum
@@ -108,7 +114,6 @@ COPY jenkins.sh /usr/local/bin/jenkins.sh
108114

109115
ENV JAVA_OPTIONS="-Djava.awt.headless=true -Dhudson.security.csrf.requestfield=crumb"
110116

111-
112117
ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"]
113118
#-----------------------------------------------
114119
# get all Plugins from existing Jenins
@@ -124,10 +129,6 @@ COPY install-plugins.sh /usr/local/bin/install-plugins.sh
124129
COPY plugins.txt /usr/share/jenkins/ref/
125130
RUN /usr/local/bin/plugins.sh /usr/share/jenkins/ref/plugins.txt
126131

127-
128-
129-
130-
131132
USER root
132133

133134
RUN apt-get clean

0 commit comments

Comments
 (0)