forked from KingFRANKHOOD/Amana
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
146 lines (135 loc) · 4.7 KB
/
Copy pathdocker-compose.yml
File metadata and controls
146 lines (135 loc) · 4.7 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
version: '3.8'
# ─────────────────────────────────────────────────────────────────────────────
# Amana Docker Compose – environment-specific profiles
#
# Profiles:
# dev – local development (postgres + redis, persistent volume)
# staging – staging parity (postgres + redis, seeded synthetic data)
# test – CI / unit-test isolation (ephemeral in-memory postgres)
#
# Usage:
# docker compose --profile dev up -d
# docker compose --profile staging up -d
# docker compose --profile test up -d
#
# Or use the helper scripts in scripts/:
# ./scripts/dev-up.sh
# ./scripts/staging-up.sh
# ./scripts/test-up.sh
# ─────────────────────────────────────────────────────────────────────────────
x-postgres-healthcheck: &postgres-healthcheck
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
x-redis-healthcheck: &redis-healthcheck
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
services:
# ── Development ─────────────────────────────────────────────────────────────
# Note: Default fallback credentials (e.g. 'password') and passwordless Redis are
# for local isolated development only. Override passwords in non-dev environments.
postgres:
image: postgres:17-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password} # Dev default only
POSTGRES_DB: ${POSTGRES_DB:-amana}
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck: *postgres-healthcheck
deploy:
resources:
limits:
memory: 512M
profiles: [dev]
redis:
image: redis:7-alpine
# Note: Unsecured Redis is dev-only. Staging/prod environments mandate authentication.
ports:
- "${REDIS_PORT:-6379}:6379"
healthcheck: *redis-healthcheck
deploy:
resources:
limits:
memory: 512M
profiles: [dev]
# ── Staging ─────────────────────────────────────────────────────────────────
# Mirrors production topology: same images, separate named volume, locked
# credentials sourced from .env.staging (never committed).
postgres-staging:
image: postgres:17-alpine
environment:
POSTGRES_USER: ${STAGING_POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${STAGING_POSTGRES_PASSWORD:-staging-password}
POSTGRES_DB: ${STAGING_POSTGRES_DB:-amana_staging}
ports:
- "${STAGING_POSTGRES_PORT:-5434}:5432"
volumes:
- postgres_staging_data:/var/lib/postgresql/data
healthcheck: *postgres-healthcheck
deploy:
resources:
limits:
memory: 512M
profiles: [staging]
redis-staging:
image: redis:7-alpine
command: redis-server --requirepass ${STAGING_REDIS_PASSWORD:-staging-redis-pass}
ports:
- "${STAGING_REDIS_PORT:-6380}:6379"
healthcheck: *redis-healthcheck
deploy:
resources:
limits:
memory: 512M
profiles: [staging]
# ── Test (CI / ephemeral) ───────────────────────────────────────────────────
# Uses tmpfs so data never persists between test runs.
postgres-test:
image: postgres:17-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: amana_test
ports:
- "${TEST_POSTGRES_PORT:-5433}:5432"
tmpfs:
- /var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 3s
retries: 10
start_period: 5s
deploy:
resources:
limits:
memory: 512M
profiles: [test]
redis-test:
image: redis:7-alpine
ports:
- "${TEST_REDIS_PORT:-6381}:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
start_period: 3s
deploy:
resources:
limits:
memory: 512M
profiles: [test]
volumes:
postgres_data:
driver: local
postgres_staging_data:
driver: local