LifeMate — Personal, Family & Learning Companion

feat/aparat-learning-library
chore/phase1-repository-cleanup deploy/stable-web-apk deployment-static design/mobile-accessibility-v2 design/mobile-navigation-review docs/child-education-access-decision docs/offline-data-rescue-options docs/owner-guide-and-delivery-plan docs/phase1-policy-options docs/public-review-live-2026-10-15 feat/aparat-learning-library feat/child-device-safety feat/child-identity-schema feat/flutter-mobile-navigation feat/learning-content-operations feat/local-signing-preflight feat/online-family-stage0 feat/personal-encrypted-recovery feat/private-planner-series-api feat/public-review-page feat/standalone-weekly-planner feat/weekly-planner-android final-feature-1/iran-family-school fix/auth-abuse-expiry-safety fix/auth-expiry-after-lock fix/backend-request-safety fix/lifeguide-bootstrap-naming-ci fix/lifeguide-pages-qa-base-preflight fix/lifeguide-qa-pages-env-deployment fix/local-task-persistence fix/managed-child-session-boundary fix/personal-jalali-dates fix/personal-notification-controls fix/personal-upgrade-delivery-guard fix/sms-approval-gates fix/study-duration-display infra/cloudflare-neon-migration infra/lifeguide-cloudflare-qa infra/lifeguide-github-pages-qa infra/lifeguide-supabase-qa main phase-1/foundation-completion phase-2/product-foundation-identity phase-3/planner-school-family-core phase-4/ai-learning-wellbeing phase-5/hardening-observability-release test/android-reminder-acceptance test/personal-notification-settings test/personal-recovery-acceptance test/role-entry-apk
yml 244 lines 7.99 KB
Raw
1 name: ${COMPOSE_PROJECT_NAME:-lifeguide-stage0}
2
3 x-api-environment: &api-environment
4 NODE_ENV: ${NODE_ENV:-production}
5 PORT: 8080
6 PGHOST: postgres
7 PGPORT: 5432
8 PGDATABASE: ${POSTGRES_DB:-lifemate}
9 PGUSER: ${API_DB_USER:-lifeguide_api}
10 PGPASSWORD: ${API_DB_PASSWORD:?Generate independent API_DB_PASSWORD in .env}
11 JWT_SECRET: ${JWT_SECRET:?Generate JWT_SECRET in .env}
12 PUBLIC_APP_URL: ${PUBLIC_APP_URL:?Set the operator-approved HTTPS origin}
13 CORS_ORIGINS: ${CORS_ORIGINS:?Set the operator-approved HTTPS origin}
14 LOG_REQUESTS: ${LOG_REQUESTS:-false}
15 EMAIL_FROM: ${EMAIL_FROM:-}
16 SMTP_HOST: ${SMTP_HOST:-}
17 SMTP_PORT: ${SMTP_PORT:-587}
18 SMTP_SECURE: ${SMTP_SECURE:-false}
19 SMTP_USER: ${SMTP_USER:-}
20 SMTP_PASSWORD: ${SMTP_PASSWORD:-}
21 SMS_PROVIDER: ${SMS_PROVIDER:-disabled}
22 SMS_PROVIDER_URL: ${SMS_PROVIDER_URL:-}
23 SMS_PROVIDER_TOKEN: ${SMS_PROVIDER_TOKEN:-}
24 TRUSTED_PROXY_CIDRS: ${GATEWAY_PROXY_IP:-172.30.86.10}/32
25
26 x-admin-environment: &admin-environment
27 PGHOST: postgres
28 PGPORT: 5432
29 PGDATABASE: ${POSTGRES_DB:-lifemate}
30 PGUSER: ${POSTGRES_USER:-lifeguide}
31 PGPASSWORD: ${POSTGRES_PASSWORD:?Generate POSTGRES_PASSWORD in .env}
32 API_DB_USER: ${API_DB_USER:-lifeguide_api}
33 MIGRATOR_DB_USER: ${MIGRATOR_DB_USER:-lifeguide_migrator}
34 BACKUP_DB_USER: ${BACKUP_DB_USER:-lifeguide_backup}
35
36 x-migration-environment: &migration-environment
37 PGHOST: postgres
38 PGPORT: 5432
39 PGDATABASE: ${POSTGRES_DB:-lifemate}
40 PGUSER: ${MIGRATOR_DB_USER:-lifeguide_migrator}
41 PGPASSWORD: ${MIGRATOR_DB_PASSWORD:?Generate independent MIGRATOR_DB_PASSWORD in .env}
42
43 services:
44 postgres:
45 image: postgres:16
46 restart: unless-stopped
47 environment:
48 POSTGRES_DB: ${POSTGRES_DB:-lifemate}
49 POSTGRES_USER: ${POSTGRES_USER:-lifeguide}
50 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Generate POSTGRES_PASSWORD in .env}
51 PGDATA: /var/lib/postgresql/data/pgdata
52 volumes:
53 - postgres-data:/var/lib/postgresql/data
54 healthcheck:
55 test: [CMD-SHELL, 'pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"']
56 interval: 5s
57 timeout: 5s
58 retries: 20
59 networks: [private]
60
61 db-provision:
62 image: ${API_IMAGE:-lifeguide-api:local}
63 build:
64 context: ./backend
65 command: [node, scripts/provision-db-roles.js, --prepare]
66 # Short-lived ops job reads root-owned mode600 backups read-only; the API
67 # remains USER node and never mounts this volume or receives admin secrets.
68 user: '0:0'
69 read_only: true
70 tmpfs: [/tmp]
71 security_opt: [no-new-privileges:true]
72 environment:
73 <<: *admin-environment
74 API_DB_PASSWORD: ${API_DB_PASSWORD:?Generate independent API_DB_PASSWORD in .env}
75 MIGRATOR_DB_PASSWORD: ${MIGRATOR_DB_PASSWORD:?Generate independent MIGRATOR_DB_PASSWORD in .env}
76 BACKUP_DB_PASSWORD: ${BACKUP_DB_PASSWORD:?Generate independent BACKUP_DB_PASSWORD in .env}
77 volumes:
78 - backups:/backups:ro
79 depends_on:
80 postgres:
81 condition: service_healthy
82 restart: 'no'
83 networks: [private]
84
85 migrate:
86 image: ${API_IMAGE:-lifeguide-api:local}
87 build:
88 context: ./backend
89 command: [node, scripts/migrate.js]
90 environment: *migration-environment
91 depends_on:
92 postgres:
93 condition: service_healthy
94 db-provision:
95 condition: service_completed_successfully
96 restart: 'no'
97 networks: [private]
98
99 catalog-import:
100 image: ${API_IMAGE:-lifeguide-api:local}
101 command: [node, scripts/import-learning-catalog.js]
102 environment: *migration-environment
103 depends_on:
104 migrate:
105 condition: service_completed_successfully
106 restart: 'no'
107 networks: [private]
108
109 db-grants:
110 image: ${API_IMAGE:-lifeguide-api:local}
111 command: [node, scripts/provision-db-roles.js, --grants]
112 environment: *admin-environment
113 depends_on:
114 migrate:
115 condition: service_completed_successfully
116 catalog-import:
117 condition: service_completed_successfully
118 restart: 'no'
119 networks: [private]
120
121 api:
122 image: ${API_IMAGE:-lifeguide-api:local}
123 build:
124 context: ./backend
125 restart: unless-stopped
126 environment: *api-environment
127 read_only: true
128 tmpfs: [/tmp]
129 security_opt: [no-new-privileges:true]
130 depends_on:
131 postgres:
132 condition: service_healthy
133 migrate:
134 condition: service_completed_successfully
135 db-grants:
136 condition: service_completed_successfully
137 healthcheck:
138 test: [CMD, node, -e, "fetch('http://127.0.0.1:8080/ready').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
139 interval: 10s
140 timeout: 5s
141 retries: 12
142 start_period: 10s
143 # Provider delivery may use outbound networking after owner configuration;
144 # no API host port is published. PostgreSQL remains private-only.
145 networks:
146 private:
147 edge:
148 proxy:
149 aliases: [api-proxy]
150
151 gateway:
152 image: ${WEB_IMAGE:-lifeguide-web:local}
153 build:
154 context: ./apps/lifemate
155 restart: unless-stopped
156 ports:
157 - '${HTTPS_BIND:-0.0.0.0}:${HTTPS_PORT:-443}:443'
158 volumes:
159 - ${TLS_CERT_PATH:-./deployment/tls/server.pem}:/etc/nginx/tls/server.pem:ro
160 - ${TLS_KEY_PATH:-./deployment/tls/server-key.pem}:/etc/nginx/tls/server-key.pem:ro
161 - ./deployment/runtime-config.json:/usr/share/nginx/html/config.json:ro
162 - ./deployment/downloads:/usr/share/nginx/html/downloads:ro
163 depends_on:
164 api:
165 condition: service_healthy
166 healthcheck:
167 test: [CMD-SHELL, 'wget -Y off -q -O /dev/null http://127.0.0.1:8081/gateway-health']
168 interval: 10s
169 timeout: 5s
170 retries: 6
171 networks:
172 edge:
173 proxy:
174 ipv4_address: ${GATEWAY_PROXY_IP:-172.30.86.10}
175
176 backup:
177 build:
178 context: .
179 dockerfile: deployment/backup/Dockerfile
180 restart: unless-stopped
181 environment:
182 DATABASE_URL: postgresql://${BACKUP_DB_USER:-lifeguide_backup}@postgres:5432/${POSTGRES_DB:-lifemate}
183 PGPASSWORD: ${BACKUP_DB_PASSWORD:?Generate independent BACKUP_DB_PASSWORD in .env}
184 BACKUP_SCHEDULE: ${BACKUP_SCHEDULE:-0 2 * * *}
185 BACKUP_KEEP_DAYS: ${BACKUP_KEEP_DAYS:-14}
186 BACKUP_MAX_AGE_SECONDS: ${BACKUP_MAX_AGE_SECONDS:-93600}
187 volumes:
188 - backups:/backups
189 depends_on:
190 postgres:
191 condition: service_healthy
192 db-grants:
193 condition: service_completed_successfully
194 healthcheck:
195 test: [CMD-SHELL, 'kill -0 1 && test -f /backups/last-success && test "$$(( $$(date +%s) - $$(stat -c %Y /backups/last-success) ))" -lt "$${BACKUP_MAX_AGE_SECONDS:-93600}"']
196 interval: 60s
197 timeout: 5s
198 retries: 3
199 start_period: 60s
200 networks: [private]
201
202 # Explicit operator tools: never start these as a background application.
203 restore:
204 profiles: [ops]
205 build:
206 context: .
207 dockerfile: deployment/backup/Dockerfile
208 entrypoint: [/opt/lifeguide/restore.sh]
209 environment:
210 DATABASE_URL: postgresql://${MIGRATOR_DB_USER:-lifeguide_migrator}@postgres:5432/${POSTGRES_DB:-lifemate}
211 PGPASSWORD: ${MIGRATOR_DB_PASSWORD:?Generate independent MIGRATOR_DB_PASSWORD in .env}
212 volumes: [backups:/backups]
213 restart: 'no'
214 networks: [private]
215
216 db-role-test:
217 profiles: [ops]
218 image: ${API_IMAGE:-lifeguide-api:local}
219 command: [node, scripts/test-db-roles.js, --synthetic-only]
220 environment:
221 <<: *admin-environment
222 API_DB_PASSWORD: ${API_DB_PASSWORD:?Generate independent API_DB_PASSWORD in .env}
223 MIGRATOR_DB_PASSWORD: ${MIGRATOR_DB_PASSWORD:?Generate independent MIGRATOR_DB_PASSWORD in .env}
224 BACKUP_DB_PASSWORD: ${BACKUP_DB_PASSWORD:?Generate independent BACKUP_DB_PASSWORD in .env}
225 DB_ROLE_RESTORE_FIXTURE: /app/restore-fixture.sql
226 volumes:
227 - ./backend/tests/online_acceptance.test.js:/app/tests/online_acceptance.test.js:ro
228 - ./deployment/restore-fixture.sql:/app/restore-fixture.sql:ro
229 restart: 'no'
230 networks: [private]
231
232 volumes:
233 postgres-data:
234 backups:
235
236 networks:
237 private:
238 internal: true
239 edge:
240 proxy:
241 internal: true
242 ipam:
243 config:
244 - subnet: ${PROXY_SUBNET:-172.30.86.0/24}