Skip to content

Commit e0b4286

Browse files
committed
Completed docker files each service and Generated docker-compose file.
1 parent 1eaa1aa commit e0b4286

File tree

20 files changed

+200
-47
lines changed

20 files changed

+200
-47
lines changed

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,33 @@ docker run -d -p 9411:9411 openzipkin/zipkin
5656
---
5757

5858
Project Links:
59-
- Health : http://localhost:9191/actuator/health
60-
- Eureka : http://localhost:8761/
61-
- Department GetMethod: http://localhost:9191/departments/1
62-
- Hystrix: http://localhost:9295/hystrix
63-
- http://localhost:9295/hystrix/monitor?stream=http%3A%2F%2Flocalhost%3A9191%2Factuator%2Fhystrix.stream
59+
- Health : http://person-service:9191/actuator/health
60+
- Eureka : http://service-registry:8761/
61+
- Department GetMethod: http://department-service:9191/departments/1
62+
- Hystrix: http://hystrix-dashboard:9295/hystrix
63+
- http://hystrix-dashboard:9295/hystrix/monitor?stream=http%3A%2F%2Flocalhost%3A9191%2Factuator%2Fhystrix.stream
6464

65+
## Maven and Docker Build -> jib
66+
```shell
6567

68+
$ cd service-registry && ./mvnw -Pprod clean verify jib:dockerBuild && cd ..
69+
$ cd config-server && ./mvnw -Pprod clean verify jib:dockerBuild && cd ..
70+
$ cd api-gateway && ./mvnw -Pprod clean verify jib:dockerBuild && cd ..
71+
$ cd hystrix-dashboard && ./mvnw -Pprod clean verify jib:dockerBuild && cd ..
72+
$ cd department-service && ./mvnw -Pprod clean verify jib:dockerBuild && cd ..
73+
$ cd person-service && ./mvnw -Pprod clean verify jib:dockerBuild && cd ..
74+
$ cd task-service && ./mvnw -Pprod clean verify jib:dockerBuild && cd ..
75+
```
76+
77+
## Run docker-compose
78+
```shell
79+
$ docker-compose -f docker-compose/app.yml up -d
80+
```
81+
82+
## Stop docker-compose
83+
```shell
84+
$ docker-compose -f docker-compose/app.yml down
85+
```
6686

6787
References:
6888

@@ -80,4 +100,3 @@ References:
80100
- https://www.amazon.com/Spring-Boot-Action-Craig-Walls/dp/1617292540
81101
- https://www.amazon.com/Spring-Microservices-Action-John-Carnell/dp/1617293989
82102
- https://www.oreilly.com/library/view/mastering-spring-boot/9781787127562/
83-
-

api-gateway/src/main/docker/app.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ version: '3.8'
22
services:
33
api-gateway:
44
image: cevheri/api-gateway
5+
container_name: api-gateway
6+
hostname: api-gateway
57
environment:
68
- _JAVA_OPTIONS=-Xmx512m -Xms256m
79
ports:

api-gateway/src/main/resources/application.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,13 @@ management:
5454
exposure:
5555
include: hystrix.stream #, prometheus
5656

57-
57+
eureka:
58+
client:
59+
register-with-eureka: true
60+
fetch-registry: true
61+
service-url:
62+
defaultZone: http://localhost:8761/eureka/
63+
#defaultZone: http://service-registry:8761/eureka/
64+
instance:
65+
hostname: service-registry
5866

config-server/src/main/docker/app.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ version: '3.8'
22
services:
33
config-server:
44
image: cevheri/config-server
5+
container_name: config-server
6+
hostname: config-server
57
environment:
68
- _JAVA_OPTIONS=-Xmx512m -Xms256m
79
ports:

config-server/src/main/java/com/cevher/ms/config/ConfigServerApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@SpringBootApplication
99
@EnableEurekaClient
10-
@EnableConfigServer
10+
//@EnableConfigServer
1111
public class ConfigServerApplication {
1212
// We used @EnableEurekaClient and @EnableConfigServer
1313
// See application.yml

config-server/src/main/resources/application.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@ server:
44
spring:
55
application:
66
name: config-server
7-
cloud:
8-
config:
9-
server:
10-
git:
11-
uri: https://github.com/cevheri/microservices-config-server
12-
clone-on-start: true
7+
# cloud:
8+
# config:
9+
# server:
10+
# git:
11+
# uri: https://github.com/cevheri/microservices-config-server
12+
# clone-on-start: true
13+
eureka:
14+
client:
15+
register-with-eureka: true
16+
fetch-registry: true
17+
service-url:
18+
defaultZone: http://localhost:8761/eureka/
19+
#defaultZone: http://service-registry:8761/eureka/
20+
instance:
21+
hostname: service-registry

department-service/src/main/docker/app.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ version: '3.8'
22
services:
33
department-service:
44
image: cevheri/department-service
5+
container_name: department-service
6+
hostname: department-service
57
environment:
68
- _JAVA_OPTIONS=-Xmx512m -Xms256m
79
- APP_SLEEP=10 # for zipkin
810
ports:
9-
- 9001:9001
10-
zipkin:
11-
image: openzipkin/zipkin
12-
ports:
13-
- 9411:9411
11+
- 9001:9001
12+
# zipkin:
13+
# image: openzipkin/zipkin
14+
# ports:
15+
# - 9411:9411

department-service/src/main/resources/application.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,13 @@ spring:
77
server:
88
port: 9001
99

10-
10+
eureka:
11+
client:
12+
register-with-eureka: true
13+
fetch-registry: true
14+
service-url:
15+
defaultZone: http://localhost:8761/eureka/
16+
#defaultZone: http://service-registry:8761/eureka/
17+
instance:
18+
hostname: service-registry
1119

docker-compose/app.yml

Lines changed: 78 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,115 @@
1-
version: '3.8'
1+
version: '3.9'
22
services:
33
service-registry:
44
image: cevheri/service-registry
5+
container_name: service-registry
6+
hostname: service-registry
57
environment:
68
- _JAVA_OPTIONS=-Xmx512m -Xms256m
79
ports:
810
- 8761:8761
11+
networks:
12+
- ms-network
913
config-server:
1014
image: cevheri/config-server
15+
container_name: config-server
16+
hostname: config-server
1117
environment:
1218
- _JAVA_OPTIONS=-Xmx512m -Xms256m
19+
- EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://service-registry:8761/eureka
1320
ports:
14-
- 9296:9296
21+
- 9296:9296
22+
depends_on:
23+
- service-registry
24+
networks:
25+
- ms-network
1526
hystrix-dashboard:
16-
image: cevheri/hystrix-dashboard
17-
environment:
18-
- _JAVA_OPTIONS=-Xmx512m -Xms256m
19-
ports:
27+
image: cevheri/hystrix-dashboard
28+
container_name: hystrix-dashboard
29+
hostname: hystrix-dashboard
30+
environment:
31+
- _JAVA_OPTIONS=-Xmx512m -Xms256m
32+
- EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://service-registry:8761/eureka
33+
ports:
2034
- 9295:9295
35+
depends_on:
36+
- service-registry
37+
- config-server
38+
networks:
39+
- ms-network
2140
api-gateway:
2241
image: cevheri/api-gateway
42+
container_name: api-gateway
43+
hostname: api-gateway
2344
environment:
2445
- _JAVA_OPTIONS=-Xmx512m -Xms256m
46+
- EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://service-registry:8761/eureka
2547
ports:
26-
- 9191:9191
48+
- 9191:9191
49+
depends_on:
50+
- service-registry
51+
- config-server
52+
networks:
53+
- ms-network
2754
department-service:
2855
image: cevheri/department-service
56+
container_name: department-service
57+
hostname: department-service
2958
environment:
3059
- _JAVA_OPTIONS=-Xmx512m -Xms256m
60+
- EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://service-registry:8761/eureka
3161
ports:
32-
- 9001:9001
62+
- 9001:9001
63+
depends_on:
64+
- service-registry
65+
- config-server
66+
- zipkin
67+
networks:
68+
- ms-network
3369
person-service:
3470
image: cevheri/person-service
71+
container_name: person-service
72+
hostname: person-service
3573
environment:
3674
- _JAVA_OPTIONS=-Xmx512m -Xms256m
75+
- EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://service-registry:8761/eureka
3776
ports:
38-
- 9002:9002
77+
- 9002:9002
78+
depends_on:
79+
- service-registry
80+
- config-server
81+
- zipkin
82+
- department-service
83+
networks:
84+
- ms-network
3985
task-service:
4086
image: cevheri/task-service
87+
container_name: task-service
88+
hostname: task-service
4189
environment:
4290
- _JAVA_OPTIONS=-Xmx512m -Xms256m
91+
- EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://service-registry:8761/eureka
4392
ports:
44-
- 9003:9003
93+
- 9003:9003
94+
depends_on:
95+
- service-registry
96+
- config-server
97+
- zipkin
98+
- department-service
99+
- person-service
100+
networks:
101+
- ms-network
45102
zipkin:
46103
image: openzipkin/zipkin
104+
container_name: zipkin
105+
hostname: zipkin
47106
ports:
48-
- 9411:9411
107+
- 9411:9411
108+
depends_on:
109+
- service-registry
110+
- config-server
111+
networks:
112+
- ms-network
113+
114+
networks:
115+
ms-network:

hystrix-dashboard/src/main/docker/app.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ version: '3.8'
22
services:
33
hystrix-dashboard:
44
image: cevheri/hystrix-dashboard
5+
container_name: hystrix-dashboard
6+
hostname: hystrix-dashboard
57
environment:
68
- _JAVA_OPTIONS=-Xmx512m -Xms256m
79
ports:

0 commit comments

Comments
 (0)