-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.ui-test.yml
More file actions
152 lines (143 loc) · 4.56 KB
/
Copy pathdocker-compose.ui-test.yml
File metadata and controls
152 lines (143 loc) · 4.56 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
145
146
147
148
149
150
151
152
# Docker Compose for running Playwright UI automation tests.
#
# Usage:
# docker compose -f docker-compose.ui-test.yml up \
# --exit-code-from playwright --abort-on-container-exit
#
# Screenshots and test results are written to ./tests/ui/test-results.
# The Playwright container exits with code 0 on success, non-zero on failure.
# MySQL data is ephemeral (no named volume) so the schema is always fresh.
version: "3.8"
services:
# ---------------------------------------------------------------------------
# MySQL – schema is initialised from migration SQL + test seed data.
# No persistent volume: each run starts with a clean database.
# ---------------------------------------------------------------------------
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: miniapp
volumes:
- ./migrations/000001_init_schema.up.sql:/docker-entrypoint-initdb.d/01_schema.sql:ro
- ./tests/api/seed.sql:/docker-entrypoint-initdb.d/02_seed.sql:ro
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-u", "root", "-psecret"]
interval: 5s
timeout: 3s
retries: 20
networks:
- ui-test-network
redis:
image: redis:7-alpine
command: ["redis-server", "--save", "", "--appendonly", "no"]
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 20
networks:
- ui-test-network
cos:
build:
context: .
dockerfile: tests/mock-server/cos/Dockerfile
environment:
COS_PORT: 9000
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:9000/health"]
interval: 5s
timeout: 3s
retries: 20
networks:
- ui-test-network
# ---------------------------------------------------------------------------
# Backend application
# ---------------------------------------------------------------------------
app:
build:
context: .
dockerfile: Dockerfile
environment:
APP_SERVER_PORT: 8080
APP_SERVER_MODE: debug
APP_DATABASE_HOST: mysql
APP_DATABASE_PORT: 3306
APP_DATABASE_USER: root
APP_DATABASE_PASSWORD: secret
APP_DATABASE_NAME: miniapp
APP_JWT_SECRET: test-jwt-secret-for-ui-tests
APP_JWT_EXPIRY: 7200
APP_LOG_LEVEL: debug
APP_WECHAT_APP_ID: test-wechat-app-id
APP_WECHAT_APP_SECRET: test-wechat-app-secret
APP_UPLOAD_DIR: storage/uploads
APP_UPLOAD_BASE_URL: http://cos:9000
APP_UPLOAD_PROVIDER: cos
APP_UPLOAD_COS_ENDPOINT: http://cos:9000
APP_UPLOAD_COS_BUCKET: miniapp-test
APP_REDIS_HOST: redis
APP_REDIS_PORT: 6379
APP_RATE_LIMIT_ENABLED: "true"
APP_RATE_LIMIT_REQUESTS: 5000
APP_RATE_LIMIT_WINDOW_SECONDS: 60
APP_DEBUG_ENABLE_TEST_TOKEN: "true"
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/health"]
interval: 5s
timeout: 3s
start_period: 10s
retries: 12
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
cos:
condition: service_healthy
networks:
- ui-test-network
# ---------------------------------------------------------------------------
# UI – serves the static HTML/JS/CSS via nginx.
# ---------------------------------------------------------------------------
ui:
build:
context: .
dockerfile: Dockerfile.ui
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:80/admin/index.html"]
interval: 3s
timeout: 2s
retries: 10
depends_on:
app:
condition: service_healthy
networks:
- ui-test-network
# ---------------------------------------------------------------------------
# Playwright – runs the UI test suite and exits with its result code.
# Screenshots and reports are persisted to ./tests/ui/test-results.
# ---------------------------------------------------------------------------
playwright:
image: mcr.microsoft.com/playwright:v1.52.0-noble
working_dir: /work
volumes:
- ./tests/ui:/work
command: >
bash -c "
npm ci --ignore-scripts &&
npx playwright install chromium --with-deps &&
npx playwright test
"
environment:
APP_BASE_URL: "http://app:8080"
UI_BASE_URL: "http://ui:80"
PLAYWRIGHT_HTML_REPORT: /work/html-report
depends_on:
ui:
condition: service_healthy
networks:
- ui-test-network
networks:
ui-test-network:
driver: bridge