feat: persist messenger data and sessions in PostgreSQL

This commit is contained in:
Artem
2026-12-04 20:56:56 +03:00
parent 65003b6119
commit 4abfcf2cd9
25 changed files with 1632 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
name: mtusi-lab2
services:
db:
image: postgres:17.6-alpine
environment:
POSTGRES_USER: lab
POSTGRES_DB: lab
POSTGRES_PASSWORD: ${PG_PASS:?run scripts/bootstrap.sh}
volumes:
- pg:/var/lib/postgresql/data
healthcheck:
test:
- CMD-SHELL
- pg_isready -U lab -d lab
interval: 2s
timeout: 2s
retries: 30
cache:
image: valkey/valkey:8.1.3-alpine
command:
- valkey-server
- --appendonly
- 'yes'
- --requirepass
- ${CACHE_PASS:?}
volumes:
- cache:/data
migrate:
build: .
image: mtusi-lab2-app:local
command:
- node
- dist/migrate.js
environment:
DATABASE_URL: postgresql://lab:${PG_PASS}@db:5432/lab
CACHE_URL: redis://:${CACHE_PASS}@cache:6379
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
depends_on:
db:
condition: service_healthy
cache:
condition: service_started
healthcheck:
disable: true
api:
image: mtusi-lab2-app:local
environment:
DATABASE_URL: postgresql://lab:${PG_PASS}@db:5432/lab
CACHE_URL: redis://:${CACHE_PASS}@cache:6379
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
PG_POOL_SIZE: ${PG_POOL_SIZE:-8}
depends_on:
db:
condition: service_healthy
cache:
condition: service_started
migrate:
condition: service_completed_successfully
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
tmpfs:
- /tmp
mem_limit: ${API_MEM:-256m}
cpus: ${API_CPUS:-1.0}
ports:
- 127.0.0.1:8080:8080
volumes:
pg: {}
cache: {}