1
- version : ' 2'
1
+ version : ' 3.8' # Specify the version of the Compose file
2
+
3
+ networks :
4
+ app-network : # Define the network here
5
+ driver : bridge
2
6
3
7
services :
8
+ app :
9
+ build :
10
+ context : . # Build from the current directory, where Dockerfile is located
11
+ dockerfile : Dockerfile # Specify the Dockerfile
12
+ container_name : kafka-study-app
13
+
14
+ ports :
15
+ - " 8080:8080" # Expose the app on localhost:8080
16
+ depends_on :
17
+ - kafka
18
+ - mongodb
19
+ command : ["java", "-jar", "/app/app.jar"] # Command to run the app
20
+ networks :
21
+ - app-network
22
+
4
23
zookeeper :
5
24
image : wurstmeister/zookeeper:latest
6
25
ports :
7
26
- " 2181:2181"
8
27
container_name : zookeeper
28
+ networks :
29
+ - app-network
30
+
9
31
kafka :
10
32
image : wurstmeister/kafka:latest
11
33
ports :
@@ -24,17 +46,23 @@ services:
24
46
- zookeeper
25
47
volumes :
26
48
- /var/run/docker.sock:/var/run/docker.sock
49
+ networks :
50
+ - app-network
51
+
27
52
mongodb :
28
53
image : mongo:latest
29
- container_name : mongodb-container
54
+ container_name : mongodb
30
55
ports :
31
56
- " 27017:27017"
32
57
environment :
33
58
MONGO_INITDB_ROOT_USERNAME : root
34
59
MONGO_INITDB_ROOT_PASSWORD : example
35
60
volumes :
36
61
- mongo-data:/data/db
37
- # sonar - code quality
62
+ networks :
63
+ - app-network
64
+
65
+ # SonarQube for code quality
38
66
sonarqube :
39
67
image : sonarqube
40
68
ports :
@@ -47,7 +75,10 @@ services:
47
75
- sonarqube_data:/opt/sonarqube/data
48
76
- sonarqube_logs:/opt/sonarqube/logs
49
77
- sonarqube_extensions:/opt/sonarqube/extensions
50
- # Sonar-related postgres
78
+ networks :
79
+ - app-network
80
+
81
+ # SonarQube-related PostgreSQL database
51
82
postgres :
52
83
image : postgres
53
84
environment :
@@ -56,6 +87,8 @@ services:
56
87
POSTGRES_PASSWORD : sonar
57
88
volumes :
58
89
- postgres_data:/var/lib/postgresql/data
90
+ networks :
91
+ - app-network
59
92
60
93
prometheus :
61
94
image : prom/prometheus:latest
@@ -65,6 +98,8 @@ services:
65
98
- prometheus_data:/prometheus
66
99
ports :
67
100
- " 9090:9090"
101
+ networks :
102
+ - app-network
68
103
69
104
grafana :
70
105
image : grafana/grafana:latest
@@ -75,6 +110,9 @@ services:
75
110
- GF_SECURITY_ADMIN_PASSWORD=admin
76
111
volumes :
77
112
- grafana-storage:/var/lib/grafana
113
+ networks :
114
+ - app-network
115
+
78
116
volumes :
79
117
mongo-data :
80
118
sonarqube_data :
0 commit comments