выполнение лр2 на 4

This commit is contained in:
Ilya
2026-10-07 18:28:12 +03:00
parent 65003b6119
commit e914e384fc
32 changed files with 2054 additions and 15 deletions
+32
View File
@@ -0,0 +1,32 @@
#!/bin/sh
# Generate local synthetic credentials into ./secrets (git-ignored). Idempotent:
# existing files are kept, so a running stack keeps working. Prints no secret values.
set -eu
cd "$(dirname "$0")/.."
mkdir -p secrets
gen() { python3 -c 'import secrets; print(secrets.token_hex(24))'; }
if [ ! -f secrets/postgres_password ]; then
gen > secrets/postgres_password
echo "created secrets/postgres_password"
fi
PG_PASS=$(cat secrets/postgres_password)
printf 'postgresql://messenger:%s@postgres:5432/messenger\n' "$PG_PASS" > secrets/database_url
if [ ! -f secrets/valkey.conf ]; then
{
printf 'requirepass %s\n' "$(gen)"
# Pure cache: PostgreSQL holds the sessions, so no RDB/AOF is needed.
printf 'save ""\nappendonly no\n'
printf 'maxmemory 64mb\nmaxmemory-policy volatile-lru\n'
} > secrets/valkey.conf
echo "created secrets/valkey.conf"
fi
VK_PASS=$(sed -n 's/^requirepass //p' secrets/valkey.conf)
printf 'redis://:%s@valkey:6379/0\n' "$VK_PASS" > secrets/cache_url
# Containers run as non-root users that do not own these files on Linux.
chmod 644 secrets/*
echo "secrets ready in ./secrets (not tracked by git)"
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
# Restart the API and ALL state stores (PostgreSQL, Valkey), keeping volumes.
# Never `down -v`, never flush, never re-seed. Migrations run again (idempotent).
set -eu
cd "$(dirname "$0")/.."
docker compose stop api
docker compose stop valkey postgres
# depends_on brings postgres, valkey and migrate up first; --wait = api healthcheck (/health/ready).
docker compose up -d --no-build --wait api
docker compose ps --all --format 'table {{.Service}}\t{{.Status}}'