generated from 8iq/nodejs-hackathon-boilerplate-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 30
/
docker-compose.yml
87 lines (82 loc) · 2.06 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
version: '3.8'
x-postgres-common:
&postgres-common
image: ${REGISTRY}postgres:16.4
user: postgres
services:
app:
image: app
profiles:
- app
build:
context: .
dockerfile: Dockerfile
user: app
volumes:
- ./apps/:/app/apps
- ./packages/:/app/packages
- ./bin/:/app/bin
- ./package.json:/app/package.json
- ./.env:/app/.env
networks:
- app-network
postgresdb:
image: alpine
depends_on:
- postgresdb-master
- postgresdb-replica
networks:
- app-network
postgresdb-master:
<<: *postgres-common
ports:
- "127.0.0.1:5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_DB: main
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: "scram-sha-256\nhost replication all 0.0.0.0/0 scram-sha-256"
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256"
command: |
postgres
-c wal_level=replica
-c synchronous_commit=on
volumes:
- ./docker-compose-postgresql-init-replication.sql:/docker-entrypoint-initdb.d/docker-compose-postgresql-init-replication.sql
networks:
- app-network
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 5s
timeout: 5s
retries: 5
postgresdb-replica:
<<: *postgres-common
ports:
- "127.0.0.1:5433:5432"
environment:
PGUSER: replicator
PGPASSWORD: replicator_password
command: |
bash -c "
if [ ! -f /var/lib/postgresql/initialized ]; then
pg_basebackup --pgdata=/var/lib/postgresql/data -R --slot=replication_slot --host=postgresdb-master --port=5432
chmod -R 0700 /var/lib/postgresql/data
touch /var/lib/postgresql/initialized
fi
postgres -c max_connections=2000
"
networks:
- app-network
depends_on:
postgresdb-master:
condition: service_healthy
redis:
image: ${REGISTRY}redis:6.2
ports:
- "127.0.0.1:6379:6379"
networks:
- app-network
networks:
app-network:
driver: bridge