LifeMate — Personal, Family & Learning Companion

feat/online-family-stage0
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 232 lines 7.64 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 db-grants:
100 image: ${API_IMAGE:-lifeguide-api:local}
101 command: [node, scripts/provision-db-roles.js, --grants]
102 environment: *admin-environment
103 depends_on:
104 migrate:
105 condition: service_completed_successfully
106 restart: 'no'
107 networks: [private]
108
109 api:
110 image: ${API_IMAGE:-lifeguide-api:local}
111 build:
112 context: ./backend
113 restart: unless-stopped
114 environment: *api-environment
115 read_only: true
116 tmpfs: [/tmp]
117 security_opt: [no-new-privileges:true]
118 depends_on:
119 postgres:
120 condition: service_healthy
121 migrate:
122 condition: service_completed_successfully
123 db-grants:
124 condition: service_completed_successfully
125 healthcheck:
126 test: [CMD, node, -e, "fetch('http://127.0.0.1:8080/ready').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
127 interval: 10s
128 timeout: 5s
129 retries: 12
130 start_period: 10s
131 # Provider delivery may use outbound networking after owner configuration;
132 # no API host port is published. PostgreSQL remains private-only.
133 networks:
134 private:
135 edge:
136 proxy:
137 aliases: [api-proxy]
138
139 gateway:
140 image: ${WEB_IMAGE:-lifeguide-web:local}
141 build:
142 context: ./apps/lifemate
143 restart: unless-stopped
144 ports:
145 - '${HTTPS_BIND:-0.0.0.0}:${HTTPS_PORT:-443}:443'
146 volumes:
147 - ${TLS_CERT_PATH:-./deployment/tls/server.pem}:/etc/nginx/tls/server.pem:ro
148 - ${TLS_KEY_PATH:-./deployment/tls/server-key.pem}:/etc/nginx/tls/server-key.pem:ro
149 - ./deployment/runtime-config.json:/usr/share/nginx/html/config.json:ro
150 - ./deployment/downloads:/usr/share/nginx/html/downloads:ro
151 depends_on:
152 api:
153 condition: service_healthy
154 healthcheck:
155 test: [CMD-SHELL, 'wget -Y off -q -O /dev/null http://127.0.0.1:8081/gateway-health']
156 interval: 10s
157 timeout: 5s
158 retries: 6
159 networks:
160 edge:
161 proxy:
162 ipv4_address: ${GATEWAY_PROXY_IP:-172.30.86.10}
163
164 backup:
165 build:
166 context: .
167 dockerfile: deployment/backup/Dockerfile
168 restart: unless-stopped
169 environment:
170 DATABASE_URL: postgresql://${BACKUP_DB_USER:-lifeguide_backup}@postgres:5432/${POSTGRES_DB:-lifemate}
171 PGPASSWORD: ${BACKUP_DB_PASSWORD:?Generate independent BACKUP_DB_PASSWORD in .env}
172 BACKUP_SCHEDULE: ${BACKUP_SCHEDULE:-0 2 * * *}
173 BACKUP_KEEP_DAYS: ${BACKUP_KEEP_DAYS:-14}
174 BACKUP_MAX_AGE_SECONDS: ${BACKUP_MAX_AGE_SECONDS:-93600}
175 volumes:
176 - backups:/backups
177 depends_on:
178 postgres:
179 condition: service_healthy
180 db-grants:
181 condition: service_completed_successfully
182 healthcheck:
183 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}"']
184 interval: 60s
185 timeout: 5s
186 retries: 3
187 start_period: 60s
188 networks: [private]
189
190 # Explicit operator tools: never start these as a background application.
191 restore:
192 profiles: [ops]
193 build:
194 context: .
195 dockerfile: deployment/backup/Dockerfile
196 entrypoint: [/opt/lifeguide/restore.sh]
197 environment:
198 DATABASE_URL: postgresql://${MIGRATOR_DB_USER:-lifeguide_migrator}@postgres:5432/${POSTGRES_DB:-lifemate}
199 PGPASSWORD: ${MIGRATOR_DB_PASSWORD:?Generate independent MIGRATOR_DB_PASSWORD in .env}
200 volumes: [backups:/backups]
201 restart: 'no'
202 networks: [private]
203
204 db-role-test:
205 profiles: [ops]
206 image: ${API_IMAGE:-lifeguide-api:local}
207 command: [node, scripts/test-db-roles.js, --synthetic-only]
208 environment:
209 <<: *admin-environment
210 API_DB_PASSWORD: ${API_DB_PASSWORD:?Generate independent API_DB_PASSWORD in .env}
211 MIGRATOR_DB_PASSWORD: ${MIGRATOR_DB_PASSWORD:?Generate independent MIGRATOR_DB_PASSWORD in .env}
212 BACKUP_DB_PASSWORD: ${BACKUP_DB_PASSWORD:?Generate independent BACKUP_DB_PASSWORD in .env}
213 DB_ROLE_RESTORE_FIXTURE: /app/restore-fixture.sql
214 volumes:
215 - ./backend/tests/online_acceptance.test.js:/app/tests/online_acceptance.test.js:ro
216 - ./deployment/restore-fixture.sql:/app/restore-fixture.sql:ro
217 restart: 'no'
218 networks: [private]
219
220 volumes:
221 postgres-data:
222 backups:
223
224 networks:
225 private:
226 internal: true
227 edge:
228 proxy:
229 internal: true
230 ipam:
231 config:
232 - subnet: ${PROXY_SUBNET:-172.30.86.0/24}