forked from String-dxd/teacher-workspace-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
108 lines (102 loc) · 3.44 KB
/
Copy pathdocker-compose.yml
File metadata and controls
108 lines (102 loc) · 3.44 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
# Infrastructure for local pgw-web development.
# Provides MySQL (master + replica) and Redis.
#
# Usage:
# docker compose up -d # start containers
# docker compose down # stop containers
# docker compose down -v # stop and wipe all data
services:
mysql-master:
image: mysql:8.0
platform: linux/x86_64
container_name: pgw-mysql-master
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: pgdb
MYSQL_USER: pg-local
MYSQL_PASSWORD: ${MYSQL_PASSWORD:?MYSQL_PASSWORD must be set in .env}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?MYSQL_ROOT_PASSWORD must be set in .env}
TZ: Asia/Singapore
volumes:
- mysql_master_data:/var/lib/mysql
- ./docker/mysql/master.cnf:/etc/my.cnf
healthcheck:
test: ["CMD", "sh", "-c", "mysqladmin ping -h localhost -u root -p\"$$MYSQL_ROOT_PASSWORD\""]
interval: 5s
timeout: 5s
retries: 30
mysql-replica:
image: mysql:8.0
platform: linux/x86_64
container_name: pgw-mysql-replica
ports:
- "3307:3306"
environment:
MYSQL_DATABASE: pgdb
MYSQL_USER: pg-local
MYSQL_PASSWORD: ${MYSQL_PASSWORD:?MYSQL_PASSWORD must be set in .env}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?MYSQL_ROOT_PASSWORD must be set in .env}
TZ: Asia/Singapore
volumes:
- mysql_replica_data:/var/lib/mysql
- ./docker/mysql/slave.cnf:/etc/my.cnf
depends_on:
mysql-master:
condition: service_healthy
healthcheck:
test: ["CMD", "sh", "-c", "mysqladmin ping -h localhost -u root -p\"$$MYSQL_ROOT_PASSWORD\""]
interval: 5s
timeout: 5s
retries: 30
mysql-init:
image: mysql:8.0
platform: linux/x86_64
container_name: pgw-mysql-init
depends_on:
mysql-master:
condition: service_healthy
mysql-replica:
condition: service_healthy
volumes:
- ./docker/mysql/init-replica.sh:/init-replica.sh
entrypoint: ["sh", "/init-replica.sh"]
restart: "no"
redis:
image: redis:7.0.15-alpine
container_name: pgw-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
pgw-web:
build:
context: ..
dockerfile: tw-pg-experiment/docker/pgw-web/Dockerfile
container_name: pgw-web
ports:
- "3001:3001"
env_file:
- pgw-web.env.example
environment:
# Override DB hosts to use Docker network names instead of localhost
DB_LOCAL_WRITER_CONNECTION_CONFIG: '{"username":"pg-local","password":"${MYSQL_PASSWORD}","host":"mysql-master","connectionEndpoint":"mysql-master","port":"3306"}'
DB_LOCAL_READER_CONNECTION_CONFIG: '{"username":"pg-local-read","password":"${MYSQL_PASSWORD_READ}","host":"mysql-replica","connectionEndpoint":"mysql-replica","port":"3306"}'
REDIS_URL: redis://redis:6379
# PGW's schedule-window check (`isDateWithinDayTimeWindow`) compares the
# incoming `scheduledDateTime` against `07:00`–`21:55` in the *server's*
# local TZ. Production runs in Asia/Singapore so SGT clock faces line up
# with the window; without this the local UTC container rejects most SGT
# picks (08:00 SGT → 00:00 UTC, outside 07:00–21:55).
TZ: Asia/Singapore
depends_on:
mysql-master:
condition: service_healthy
mysql-replica:
condition: service_healthy
redis:
condition: service_started
volumes:
mysql_master_data:
mysql_replica_data:
redis_data: