лаба на 3

This commit is contained in:
2026-10-15 00:18:02 +03:00
parent 0ab3a341aa
commit d3bb55ba09
29 changed files with 2397 additions and 18 deletions
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
mkdir -p secrets
chmod 700 secrets
if [[ ! -f secrets/postgres_password ]]; then
python3 -c 'import secrets; print(secrets.token_hex(24))' > secrets/postgres_password
fi
if [[ ! -f secrets/database_url ]]; then
PASSWORD="$(cat secrets/postgres_password)"
printf 'postgresql+asyncpg://lab2:%s@postgres:5432/messenger\n' "$PASSWORD" > secrets/database_url
fi
if [[ ! -f secrets/cache_url ]]; then
printf 'redis://redis:6379/0\n' > secrets/cache_url
fi
chmod 644 secrets/postgres_password secrets/database_url secrets/cache_url
if [[ ! -f .env ]]; then
cp .env.example .env
fi
docker compose config --quiet
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
docker compose restart postgres redis api-1 api-2
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
: "${TARGET_INSTANCE_ID:?}"
case "$TARGET_INSTANCE_ID" in
api-1|api-2)
docker compose stop "$TARGET_INSTANCE_ID"
;;
*)
echo "Unknown instance: $TARGET_INSTANCE_ID" >&2
exit 1
;;
esac