-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.example.yml
More file actions
83 lines (76 loc) · 2.42 KB
/
docker-compose.example.yml
File metadata and controls
83 lines (76 loc) · 2.42 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
# Example compose fragment for structs-pg services.
# Merge into your stack compose file; adjust memory limits for your host.
#
# structs-pg CMD uses /src/scripts/database-start.sh (supervised pg_ctl).
# Do not wrap with bash/tail -f; that prevents clean shutdown and restart.
version: '3.9'
x-postgres-env: &postgres-env
POSTGRES_MEMORY_MB: "8192"
POSTGRES_SHUTDOWN_MODE: fast
POSTGRES_SHUTDOWN_TIMEOUT: "115"
# Branch of github.com/playstructs/structs-pg to deploy sqitch from.
# Sentinel "origin" (default) means "use the branch baked into the image at
# clone time" - i.e. the upstream default. Override with a branch name to
# pin both init and auto-migrate to that branch.
STRUCTS_PG_BRANCH: "${STRUCTS_PG_BRANCH:-origin}"
services:
structs-pg-init:
image: 'structs/structs-pg:latest'
hostname: 'structs-pg'
command: [ "bash", "/src/scripts/database-init.sh" ]
stop_grace_period: 120s
volumes:
- pgdata:/var/lib/postgresql/
- pgetc:/etc/postgresql/
environment:
<<: *postgres-env
RUN_MIGRATIONS: "0"
SQITCH_PG_CONNECTION: "${SQITCH_PG_CONNECTION}"
# Set RUN_MIGRATIONS=1 to force sqitch on an existing volume.
structs-pg:
image: 'structs/structs-pg:latest'
hostname: 'structs-pg'
# Default CMD: /src/scripts/database-start.sh (supervised)
volumes:
- pgdata:/var/lib/postgresql/
- pgetc:/etc/postgresql/
ports:
- ${DIRECT_POSTGRES_PORT:-5432}:5432
restart: on-failure
stop_grace_period: 120s
deploy:
resources:
limits:
memory: 8G
depends_on:
structs-pg-init:
condition: service_completed_successfully
healthcheck:
test: [ "CMD-SHELL", "pg_isready -h localhost -p 5432" ]
interval: 20s
timeout: 10s
retries: 5
start_period: 30s
environment:
<<: *postgres-env
structs-pg-auto-migrate:
image: 'structs/structs-pg:latest'
command: [ "bash", "/src/scripts/database-auto-migrate.sh" ]
depends_on:
structs-pg:
condition: service_healthy
restart: true
environment:
<<: *postgres-env
AUTO_MIGRATE_SLEEP: "${AUTO_MIGRATE_SLEEP:-120}"
SQITCH_PG_CONNECTION: "${SQITCH_PG_CONNECTION}"
# Example: depend on healthy postgres, not merely started
structs-grass:
depends_on:
structs-pg:
condition: service_healthy
volumes:
pgetc:
name: structs-pg-etc
pgdata:
name: structs-pg-data