forked from Rapter1990/springbootmicroserviceswithsecurity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
129 lines (121 loc) · 3.44 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
version: "3.9"
services:
database:
container_name: database
image: mysql:8.0.33
restart: always
env_file:
- .env # Use the .env file for environment variables
environment:
MYSQL_PASSWORD: ${DATABASE_PASSWORD}
MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD}
MYSQL_ROOT_HOST: '%'
MYSQL_PORT: 3307
volumes:
- ./db:/var/lib/mysql
- ./init.sql:/data/application/init.sql
ports:
- "3307:3306"
command: --init-file /data/application/init.sql
healthcheck:
test: [ "CMD-SHELL", "mysqladmin ping -h localhost -u root -p${DATABASE_PASSWORD}" ]
interval: 20s
timeout: 10s
retries: 5
networks:
- springbootmicroservicesnetwork
eurekaserver:
image: eurekaserver:latest
build:
context: ./eurekaserver
dockerfile: Dockerfile
ports:
- "8761:8761"
environment:
- SPRING_APPLICATION_NAME=eurekaserver
- EUREKA_INSTANCE_HOSTNAME=localhost
- EUREKA_CLIENT_REGISTER_WITH_EUREKA=false
- EUREKA_CLIENT_FETCH_REGISTRY=false
- SERVER_PORT=8761
networks:
- springbootmicroservicesnetwork
apigateway:
image: apigateway:latest
build:
context: ./apigateway
dockerfile: Dockerfile
ports:
- "1110:1110"
environment:
- SPRING_APPLICATION_NAME=apigateway
- EUREKA_SERVICE_URL=http://eurekaserver:8761/eureka/
depends_on:
eurekaserver:
condition: service_started
networks:
- springbootmicroservicesnetwork
productservice:
image: productservice:latest
build:
context: ./productservice
dockerfile: Dockerfile
ports:
- "1111:1111"
environment:
- server.port=1111
- SPRING_APPLICATION_NAME=productservice
- EUREKA_SERVICE_URL=http://eurekaserver:8761/eureka/
- SECURITY_DB_IP=database
- SECURITY_DB_PORT=3307
- spring.datasource.url=jdbc:mysql://host.docker.internal:3307/springbootmicroservicesjwtproduct
- spring.datasource.username=${DATABASE_USERNAME}
- spring.datasource.password=${DATABASE_PASSWORD}
depends_on:
database:
condition: service_healthy
eurekaserver:
condition: service_started
networks:
- springbootmicroservicesnetwork
authservice:
image: authservice:latest
build:
context: ./authservice
dockerfile: Dockerfile
ports:
- "1112:1112"
environment:
- server.port=1112
- SPRING_APPLICATION_NAME=authservice
- EUREKA_SERVICE_URL=http://eurekaserver:8761/eureka/
depends_on:
eurekaserver:
condition: service_started
networks:
- springbootmicroservicesnetwork
userservice:
image: userservice:latest
build:
context: ./userservice
dockerfile: Dockerfile
ports:
- "1113:1113"
environment:
- server.port=1113
- SPRING_APPLICATION_NAME=userservice
- EUREKA_SERVICE_URL=http://eurekaserver:8761/eureka/
- SECURITY_DB_IP=database
- SECURITY_DB_PORT=3307
- spring.datasource.url=jdbc:mysql://host.docker.internal:3307/springbootmicroservicesjwtuser
- spring.datasource.username=${DATABASE_USERNAME}
- spring.datasource.password=${DATABASE_PASSWORD}
depends_on:
database:
condition: service_healthy
eurekaserver:
condition: service_started
networks:
- springbootmicroservicesnetwork
networks:
springbootmicroservicesnetwork:
driver: bridge