-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
144 lines (138 loc) · 3.98 KB
/
Copy pathdocker-compose.yml
File metadata and controls
144 lines (138 loc) · 3.98 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
services:
mysql:
image: mysql:8.0
container_name: crm-mysql-test
ports:
- "3307:3306"
environment:
MYSQL_ROOT_PASSWORD: root123
MYSQL_DATABASE: crm
MYSQL_USER: crm_user
MYSQL_PASSWORD: crm_pass
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --default-authentication-plugin=mysql_native_password
volumes:
- mysql-test-data:/var/lib/mysql
- ./e2e-tests/init-scripts:/docker-entrypoint-initdb.d
networks:
- crm-test-network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot123"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
crm-backend:
build:
context: ./chapter8/crm-backend
dockerfile: Dockerfile
container_name: crm-backend-test
ports:
- "8080:8080"
environment:
- SERVER_PORT=8080
- SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/crm?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
- SPRING_DATASOURCE_USERNAME=crm_user
- SPRING_DATASOURCE_PASSWORD=crm_pass
- SPRING_DATASOURCE_DRIVER_CLASS_NAME=com.mysql.cj.jdbc.Driver
- CUSTOMER_CENTER_BASE_URL=http://customer-center:8081
- MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=health
depends_on:
mysql:
condition: service_healthy
networks:
- crm-test-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 10s
timeout: 5s
retries: 10
start_period: 60s
customer-center:
build:
context: ./chapter7/customer-center
dockerfile: Dockerfile
container_name: customer-center-test
ports:
- "8081:8081"
environment:
- SERVER_PORT=8081
- SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/customer_center?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
- SPRING_DATASOURCE_USERNAME=crm_user
- SPRING_DATASOURCE_PASSWORD=crm_pass
- SPRING_DATASOURCE_DRIVER_CLASS_NAME=com.mysql.cj.jdbc.Driver
- MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=health
depends_on:
mysql:
condition: service_healthy
networks:
- crm-test-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8081/actuator/health"]
interval: 10s
timeout: 5s
retries: 10
start_period: 60s
frontend:
build:
context: ./chapter8/crm-frontend
dockerfile: Dockerfile
container_name: crm-frontend-test
ports:
- "5173:80"
depends_on:
crm-backend:
condition: service_healthy
customer-center:
condition: service_healthy
networks:
- crm-test-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
e2e-tests:
image: mcr.microsoft.com/playwright:v1.52.0-noble
container_name: crm-e2e-tests
depends_on:
frontend:
condition: service_healthy
crm-backend:
condition: service_healthy
customer-center:
condition: service_healthy
mysql:
condition: service_healthy
environment:
- BASE_URL=http://frontend:80
- CRM_API_URL=http://crm-backend:8080
- CUSTOMER_CENTER_URL=http://customer-center:8081
- DB_HOST=mysql
- DB_PORT=3306
- DB_NAME=crm
- DB_USER=crm_user
- DB_PASSWORD=crm_pass
volumes:
- ./e2e-tests:/e2e-tests
- ./e2e-tests/playwright-report:/playwright-report
working_dir: /e2e-tests
command: >
sh -c "
echo 'All services ready, installing dependencies...' &&
npm install &&
npx playwright test
"
networks:
- crm-test-network
profiles:
- test
volumes:
mysql-test-data:
name: crm-mysql-test-data
networks:
crm-test-network:
driver: bridge