You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docker-compose -f docker-compose.yml -f docker-compose-sonar.yml up --build
37
-
docker-compose logs
38
-
```
39
-
40
55
56
+
# Sonar only
57
+
docker-compose -f docker-compose.yml -f docker-compose-sonar.yml up --build
41
58
59
+
# Sonar AND Keycloak
60
+
docker-compose -f docker-compose.yml -f docker-compose-sonar.yml -f docker-compose-keycloak.yml up --build
42
61
62
+
# Keycloak only
63
+
docker-compose -f docker-compose.yml -f docker-compose-keycloak.yml up --build
64
+
65
+
docker-compose logs
66
+
```
43
67
### The first startup takes a long time (especially gitlab), so be patient
44
-
45
68
open your favorite browser (_not_ at localhost, use the $(hostname)/jenkins )
46
69
to prevent jenkins spit out "your reverse proxy is wrong")
47
70
@@ -52,77 +75,39 @@ Now you are ready to go with a little CI/CD Environment:
52
75
Jenkins http://<your-host-name>/jenkins
53
76
Nexus http://<your-host-name>/nexus
54
77
Gitlab http://<your-host-name>/gitlab
55
-
in the next Release: Sonar http://<your-host-name>/sonar
78
+
Sonar http://<your-host-name>/sonar
79
+
Keycloak http://<your-host-name>/auth
80
+
Postgres: At standard listenport 5432 for your jdbc-connection-string
81
+
stream-passthrough to postgres-container.
56
82
```
83
+
57
84
#### Security
58
85
... not really, its all http .. don't worry about it! It's only local communication
59
86
60
87
##### security paranoia
61
-
All the exposed ports are reachable from outer world because docker creates and deletes dynamically iptables FORWARD rules with default policy ACCEPT on startup/shutdown containers wich have exported ports.
62
-
63
-
To deny acccess from outer world the DOCKER-USER Chain (since docker 17.06) ist the medium of choice for your own rules (this is the first target in the FORWARD-Chain and never touched by docker).
64
-
65
-
A little Script to deny all access from outer world to your local build environment could be the following (exposed port from nginx are 80,5555,2222)
66
-
```
67
-
#!/bin/bash
68
-
if [ $# -lt 1 ] ; then
69
-
echo "Need your external interface as one parameter"
70
-
echo "Common names are eth0, enp...,"
71
-
echo "List of your names"
72
-
ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d'
73
-
exit
74
-
fi
75
-
76
-
PORTS_TO_BLOCK="80,5555,2222"
77
-
EXTERNAL_INTERFACE=$1
78
-
79
-
# Flush and delete custom Chains
80
-
iptables -F DOCKER-USER
81
-
iptables -F EXTERNAL-ACCESS-DENY
82
-
iptables -X EXTERNAL-ACCESS-DENY
83
-
84
-
# Create a log-and-drop Chain
85
-
iptables -N EXTERNAL-ACCESS-DENY
86
-
iptables -A EXTERNAL-ACCESS-DENY -j LOG --log-prefix "DCKR-EXT-ACCESS-DENY:" --log-level 6
87
-
iptables -A EXTERNAL-ACCESS-DENY -j DROP
88
-
89
-
# Block all incomming traffic for docker
90
-
iptables -A DOCKER-USER -i $EXTERNAL_INTERFACE \
91
-
-p tcp --match multiport \
92
-
--dports $PORTS_TO_BLOCK \
93
-
-j EXTERNAL-ACCESS-DENY
94
-
95
-
# Restore default rule to return all the rest back to the FORWARD-Chain
96
-
iptables -A DOCKER-USER -j RETURN
97
-
98
-
echo "Rules created "
99
-
iptables -v -L DOCKER-USER
100
-
iptables -v -L EXTERNAL-ACCESS-DENY
101
-
echo "See logs with prefix DCKR-EXT-ACCESS-DENY:"
102
-
```
103
-
88
+
See Readme in folder security-paranoia if you want to have some hints how to configure your firewall.
104
89
105
90
### Logins and Passwords
106
-
107
91
|Image | User | Password |
108
92
|---|---|---|
109
93
|Jenkins| admin| admin |
110
94
|Nexus | admin | admin123 |
111
95
|Gitlab | root | gitlab4me |
96
+
|Sonar | admin | admin |
97
+
|Keycloak|admin|admin|
98
+
|Postgres|postgres|admin|
112
99
113
100
## The Tools
114
101
### Jenkins
115
-
116
102
* MAVEN_HOME is /opt/maven
117
103
* JAVA_HOME is /usr/lib/jvm/java-8-openjdk-amd64
118
104
* Blue Ocean is installed if you choose (M)uch mor plugins and works perfect with a GitHUB Account, not GitLab ... sorry, this is Jenkins.
119
105
You need to be logged as a jenkins-user to use Blue Ocean
120
106
121
107
### Giltab
122
-
123
108
* the docker-registry from GitLab is at port 5555 (and secured with an openssl certificate ..thats part of
124
-
prepareEnvironment.sh), just create a project in gitlab and click at the registry tab to show
125
-
how to login to the project registry and how to tag your images
109
+
setupEnvironment.sh), just create a project in gitlab and click at the registry tab to show
110
+
how to login to the project registry and how to tag your images and upload them.
126
111
* ssh cloning and pushing is at port 2222
127
112
128
113
#### gitlab-runner
@@ -138,34 +123,54 @@ Gitlab is very very fast with new releases and sometimes the api has breaking ch
138
123
### Sonar
139
124
You need to install some rules (Administration - System - Update Center - Available - Search: Java)
140
125
126
+
### Keycloak
127
+
There is a testproject in folder spring-boot-keycloak-sample, it is a standard Spring-Boot which you can start with
128
+
```
129
+
mv spring-boot:run
130
+
```
131
+
Use your browser and navigate to the "landing-page" at http://<yourhost>:8081 the "My products" link will redirect you to Keycloak (must be setup with settings from [this tutorial][3], but use your *REAL* hostname, not _localhost_ as Valid Redirect URI's )
132
+
_tl;dr_
133
+
* login as user:admin, password:admin
134
+
* create realm "springboot"
135
+
* create client "product-app" as openid-connect client with Valid Redirect URI's http://<yourhost>:8081/*
136
+
* create role "user"
137
+
* create user "testuser" and map the role "user" to testuser (tab Role Mappings)
138
+
141
139
### Nexus
142
140
Some ToDo for me described here
143
141
[Unsecure docker-registry in Nexus][1]
144
142
use GitLab as a secured registry
145
-
146
143
..
147
144
And _yes_ docker-plugin in jenkins works (docker in docker, usefull but not recommended)
145
+
### Postgres
146
+
You can use any tool to connect to the database at locahost:5432 this is a pass through to the container so any
147
+
JDBC-Connection should work
148
148
149
149
## Troubleshooting
150
-
151
-
In most cases a wrong HOSTNAME:HOSTIP causes trouble, to check this try the follwing.
150
+
##### check Hostname and IP
151
+
In most cases a wrong HOSTNAME:HOSTIP causes trouble, to check this try the following.
0 commit comments