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
56
57
+
# Sonar only
58
+
docker-compose -f docker-compose.yml -f docker-compose-sonar.yml up --build
41
59
60
+
# Sonar AND Keycloak
61
+
docker-compose -f docker-compose.yml -f docker-compose-sonar.yml -f docker-compose-keycloak.yml up --build
42
62
63
+
# Keycloak only
64
+
docker-compose -f docker-compose.yml -f docker-compose-keycloak.yml up --build
65
+
66
+
docker-compose logs
67
+
```
43
68
### The first startup takes a long time (especially gitlab), so be patient
44
-
45
69
open your favorite browser (_not_ at localhost, use the $(hostname)/jenkins )
46
70
to prevent jenkins spit out "your reverse proxy is wrong")
47
71
@@ -53,76 +77,38 @@ Now you are ready to go with a little CI/CD Environment:
53
77
Nexus http://<your-host-name>/nexus
54
78
Gitlab http://<your-host-name>/gitlab
55
79
Sonar http://<your-host-name>/sonar
80
+
Keycloak http://<your-host-name>/auth
81
+
Postgres: At standard listenport 5432 for your jdbc-connection-string
82
+
stream-passthrough to postgres-container.
56
83
```
84
+
57
85
#### Security
58
86
... not really, its all http .. don't worry about it! It's only local communication
59
87
60
88
##### 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
-
89
+
See Readme in folder security-paranoia if you want to have some hints how to configure your firewall.
104
90
105
91
### Logins and Passwords
106
-
107
92
|Image | User | Password |
108
93
|---|---|---|
109
94
|Jenkins| admin| admin |
110
95
|Nexus | admin | admin123 |
111
96
|Gitlab | root | gitlab4me |
97
+
|Sonar | admin | admin |
98
+
|Keycloak|admin|admin|
99
+
|Postgres|postgres|admin|
112
100
113
101
## The Tools
114
102
### Jenkins
115
-
116
103
* MAVEN_HOME is /opt/maven
117
104
* JAVA_HOME is /usr/lib/jvm/java-8-openjdk-amd64
118
105
* 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
106
You need to be logged as a jenkins-user to use Blue Ocean
120
107
121
108
### Giltab
122
-
123
109
* 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
110
+
setupEnvironment.sh), just create a project in gitlab and click at the registry tab to show
111
+
how to login to the project registry and how to tag your images and upload them.
126
112
* ssh cloning and pushing is at port 2222
127
113
128
114
#### gitlab-runner
@@ -138,34 +124,54 @@ Gitlab is very very fast with new releases and sometimes the api has breaking ch
138
124
### Sonar
139
125
You need to install some rules (Administration - System - Update Center - Available - Search: Java)
140
126
127
+
### Keycloak
128
+
There is a testproject in folder spring-boot-keycloak-sample, it is a standard Spring-Boot which you can start with
129
+
```
130
+
mv spring-boot:run
131
+
```
132
+
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 )
133
+
_tl;dr_
134
+
* login as user:admin, password:admin
135
+
* create realm "springboot"
136
+
* create client "product-app" as openid-connect client with Valid Redirect URI's http://<your host>:8081/*
137
+
* create role "user"
138
+
* create user "testuser" and map the role "user" to testuser (tab Role Mappings)
139
+
141
140
### Nexus
142
141
Some ToDo for me described here
143
142
[Unsecure docker-registry in Nexus][1]
144
143
use GitLab as a secured registry
145
-
146
144
..
147
145
And _yes_ docker-plugin in jenkins works (docker in docker, usefull but not recommended)
146
+
### Postgres
147
+
You can use any tool to connect to the database at locahost:5432 this is a pass through to the container so any
148
+
JDBC-Connection should work
148
149
149
150
## Troubleshooting
150
-
151
-
In most cases a wrong HOSTNAME:HOSTIP causes trouble, to check this try the follwing.
151
+
##### check Hostname and IP
152
+
In most cases a wrong HOSTNAME:HOSTIP causes trouble, to check this try the following.
0 commit comments