@@ -18,9 +18,13 @@ services:
18
18
interval : 3s
19
19
timeout : 10s
20
20
retries : 5
21
+ volumes :
22
+ - type : bind
23
+ source : ../postgres
24
+ target : /etc/postgresql/
21
25
22
26
db-init :
23
- image : hashicorp/boundary:0.6.2
27
+ image : hashicorp/boundary:latest-89196f2ce
24
28
command : ["database", "init", "-config", "/boundary/controller.hcl"]
25
29
volumes :
26
30
- " ${PWD}/:/boundary/"
@@ -31,35 +35,183 @@ services:
31
35
condition : service_healthy
32
36
33
37
controller :
34
- image : hashicorp/boundary:0.6.2
38
+ image : hashicorp/boundary:latest-89196f2ce
39
+ cap_add :
40
+ - IPC_LOCK
35
41
# command: ["server", "-config", "/boundary/controller.hcl"]
36
42
entrypoint : sh -c "sleep 3 && exec boundary server -config /boundary/controller.hcl"
37
43
volumes :
38
44
- " ${PWD}/:/boundary/"
45
+ - " ../auditlogs/:/logs/"
39
46
hostname : boundary
40
47
ports :
41
48
- " 9200:9200"
42
49
- " 9201:9201"
50
+ - " 9202:9202"
51
+ - " 9203:9203"
43
52
environment :
44
53
- BOUNDARY_PG_URL=postgresql://postgres:postgres@db/boundary?sslmode=disable
54
+ - SKIP_CHOWN=true
45
55
depends_on :
46
56
- db-init
47
57
networks :
48
58
- default
49
59
- worker
60
+ healthcheck :
61
+ test : ["CMD", "curl", "-f", "http://boundary:9200"]
62
+ interval : 3s
63
+ timeout : 5s
64
+ retries : 5
50
65
51
66
worker :
52
- image : hashicorp/boundary:0.6.2
67
+ image : hashicorp/boundary:latest-89196f2ce
53
68
command : ["server", "-config", "/boundary/worker.hcl"]
54
69
volumes :
55
70
- " ${PWD}/:/boundary/"
71
+ - " ../auditlogs/:/logs/"
56
72
hostname : worker
57
73
ports :
58
- - " 9202 :9202"
74
+ - " 9204 :9202"
59
75
environment :
60
76
- HOSTNAME=worker
61
77
depends_on :
62
78
- controller
63
79
networks :
64
80
- default
65
- - worker
81
+ - worker
82
+
83
+ # Filebeat, Elastic, Kibana for visualizing audit events
84
+ # Based on: https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-compose-file
85
+ setup-elastic :
86
+ image : docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
87
+ volumes :
88
+ - certs:/usr/share/elasticsearch/config/certs
89
+ user : " 0"
90
+ command : >
91
+ bash -c '
92
+ if [ x${ELASTIC_PASSWORD} == x ]; then
93
+ echo "Set the ELASTIC_PASSWORD environment variable in the .env file";
94
+ exit 1;
95
+ elif [ x${KIBANA_PASSWORD} == x ]; then
96
+ echo "Set the KIBANA_PASSWORD environment variable in the .env file";
97
+ exit 1;
98
+ fi;
99
+ if [ ! -f certs/ca.zip ]; then
100
+ echo "Creating CA";
101
+ bin/elasticsearch-certutil ca --silent --pem -out config/certs/ca.zip;
102
+ unzip config/certs/ca.zip -d config/certs;
103
+ fi;
104
+ if [ ! -f certs/certs.zip ]; then
105
+ echo "Creating certs";
106
+ echo -ne \
107
+ "instances:\n"\
108
+ " - name: elasticsearch\n"\
109
+ " dns:\n"\
110
+ " - elasticsearch\n"\
111
+ " - localhost\n"\
112
+ " ip:\n"\
113
+ " - 127.0.0.1\n"\
114
+ > config/certs/instances.yml;
115
+ bin/elasticsearch-certutil cert --silent --pem -out config/certs/certs.zip --in config/certs/instances.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key;
116
+ unzip config/certs/certs.zip -d config/certs;
117
+ fi;
118
+ echo "Setting file permissions"
119
+ chown -R root:root config/certs;
120
+ find . -type d -exec chmod 750 \{\} \;;
121
+ find . -type f -exec chmod 640 \{\} \;;
122
+ echo "Waiting for Elasticsearch availability";
123
+ until curl -s --cacert config/certs/ca/ca.crt https://elasticsearch:9200 | grep -q "missing authentication credentials"; do sleep 30; done;
124
+ echo "Setting kibana_system password";
125
+ until curl -s -X POST --cacert config/certs/ca/ca.crt -u elastic:${ELASTIC_PASSWORD} -H "Content-Type: application/json" https://elasticsearch:9200/_security/user/kibana_system/_password -d "{\"password\":\"${KIBANA_PASSWORD}\"}" | grep -q "^{}"; do sleep 10; done;
126
+ echo "All done!";
127
+ '
128
+ healthcheck :
129
+ test : ["CMD-SHELL", "[ -f config/certs/elasticsearch/elasticsearch.crt ]"]
130
+ interval : 1s
131
+ timeout : 5s
132
+ retries : 120
133
+
134
+ elasticsearch :
135
+ depends_on :
136
+ setup-elastic :
137
+ condition : service_healthy
138
+ image : docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
139
+ volumes :
140
+ - certs:/usr/share/elasticsearch/config/certs
141
+ - esdata01:/usr/share/elasticsearch/data
142
+ ports :
143
+ - ${ES_PORT}:9200
144
+ environment :
145
+ - node.name=elasticsearch
146
+ - cluster.name=${CLUSTER_NAME}
147
+ - cluster.initial_master_nodes=elasticsearch
148
+ - ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
149
+ - bootstrap.memory_lock=true
150
+ - xpack.security.enabled=true
151
+ - xpack.security.http.ssl.enabled=true
152
+ - xpack.security.http.ssl.key=certs/elasticsearch/elasticsearch.key
153
+ - xpack.security.http.ssl.certificate=certs/elasticsearch/elasticsearch.crt
154
+ - xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
155
+ - xpack.security.http.ssl.verification_mode=certificate
156
+ - xpack.security.transport.ssl.enabled=true
157
+ - xpack.security.transport.ssl.key=certs/elasticsearch/elasticsearch.key
158
+ - xpack.security.transport.ssl.certificate=certs/elasticsearch/elasticsearch.crt
159
+ - xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
160
+ - xpack.security.transport.ssl.verification_mode=certificate
161
+ - xpack.license.self_generated.type=${LICENSE}
162
+ mem_limit : ${MEM_LIMIT}
163
+ ulimits :
164
+ memlock :
165
+ soft : -1
166
+ hard : -1
167
+ healthcheck :
168
+ test :
169
+ [
170
+ " CMD-SHELL" ,
171
+ " curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'" ,
172
+ ]
173
+ interval : 10s
174
+ timeout : 10s
175
+ retries : 120
176
+
177
+ kibana :
178
+ depends_on :
179
+ elasticsearch :
180
+ condition : service_healthy
181
+ image : docker.elastic.co/kibana/kibana:${STACK_VERSION}
182
+ volumes :
183
+ - certs:/usr/share/kibana/config/certs
184
+ - kibanadata:/usr/share/kibana/data
185
+ ports :
186
+ - ${KIBANA_PORT}:5601
187
+ environment :
188
+ - SERVERNAME=kibana
189
+ - ELASTICSEARCH_HOSTS=https://elasticsearch:9200
190
+ - ELASTICSEARCH_USERNAME=kibana_system
191
+ - ELASTICSEARCH_PASSWORD=${KIBANA_PASSWORD}
192
+ - ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES=config/certs/ca/ca.crt
193
+ mem_limit : ${MEM_LIMIT}
194
+ healthcheck :
195
+ test :
196
+ [
197
+ " CMD-SHELL" ,
198
+ " curl -s -I http://localhost:5601 | grep -q 'HTTP/1.1 302 Found'" ,
199
+ ]
200
+ interval : 10s
201
+ timeout : 10s
202
+ retries : 120
203
+
204
+ filebeat :
205
+ image : docker.elastic.co/beats/filebeat:${STACK_VERSION}
206
+ volumes :
207
+ - " ../filebeat.docker.yml:/usr/share/filebeat/filebeat.yml"
208
+ - " ../auditlogs/:/source"
209
+ - certs:/certs
210
+
211
+ volumes :
212
+ certs :
213
+ driver : local
214
+ esdata01 :
215
+ driver : local
216
+ kibanadata :
217
+ driver : local
0 commit comments