forked from mtusi2026/mtusi2026lab4
ЛР 4 - БПИ2302 - Щербацевич - на 4
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
ROOT=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
||||
mkdir -p "$ROOT/secrets"
|
||||
|
||||
write_secret() {
|
||||
name=$1
|
||||
value=$2
|
||||
path="$ROOT/secrets/$name"
|
||||
if [ ! -f "$path" ]; then
|
||||
printf '%s' "$value" > "$path"
|
||||
fi
|
||||
}
|
||||
|
||||
rand() {
|
||||
python3 -c 'import secrets; print(secrets.token_hex(16))'
|
||||
}
|
||||
|
||||
pg=$(rand)
|
||||
write_secret postgres_password "$pg"
|
||||
write_secret database_url "postgresql+asyncpg://messenger:${pg}@postgres:5432/messenger"
|
||||
write_secret host_database_url "postgresql+asyncpg://messenger:${pg}@127.0.0.1:5433/messenger"
|
||||
write_secret cache_url "redis://redis:6379/0"
|
||||
write_secret host_cache_url "redis://127.0.0.1:6379/0"
|
||||
write_secret minio_root_user minioadmin
|
||||
write_secret minio_root_password "$(rand)"
|
||||
write_secret s3_access_key_id messengerapi
|
||||
write_secret s3_secret_access_key "$(rand)"
|
||||
write_secret host_s3_endpoint "http://127.0.0.1:9000"
|
||||
|
||||
if [ ! -f "$ROOT/.env" ]; then
|
||||
cp "$ROOT/.env.example" "$ROOT/.env"
|
||||
fi
|
||||
|
||||
echo "secrets and .env are ready"
|
||||
echo "next: docker compose --env-file .env up -d --build --scale api=2"
|
||||
Reference in New Issue
Block a user