ЛР 2: PostgreSQL, сессии и Valkey — на 4
This commit is contained in:
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
mkdir -p secrets
|
||||
chmod 700 secrets
|
||||
umask 077
|
||||
if [ ! -f secrets/postgres_password ]; then
|
||||
od -An -N32 -tx1 /dev/urandom | tr -d ' \n' > secrets/postgres_password
|
||||
fi
|
||||
password=$(cat secrets/postgres_password)
|
||||
for file in secrets/database_url secrets/cache_url; do
|
||||
[ ! -f "$file" ] || chmod u+w "$file"
|
||||
done
|
||||
printf 'postgresql://messenger:%s@postgres:5432/messenger' "$password" > secrets/database_url
|
||||
printf 'redis://valkey:6379/0' > secrets/cache_url
|
||||
# The parent directory protects host access; bind-mounted files must be readable
|
||||
# by the non-root API user inside its container (Compose file secrets preserve modes).
|
||||
chmod 444 secrets/postgres_password secrets/database_url secrets/cache_url
|
||||
[ -f .env ] || cp .env.example .env
|
||||
printf '%s\n' 'Local configuration ready; secrets were not printed.'
|
||||
Reference in New Issue
Block a user