forked from mtusi2026/mtusi2026lab2
Lab2: PostgreSQL, Bearer sessions and Redis for grade 4
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
# Создаёт локальные учебные секреты. Не печатает их и не кладёт в git.
|
||||
$ErrorActionPreference = "Stop"
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
Set-Location $root
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $root "secrets") | Out-Null
|
||||
$pass = "lab-only-password"
|
||||
$utf8 = New-Object System.Text.UTF8Encoding $false
|
||||
[System.IO.File]::WriteAllText((Join-Path $root "secrets\postgres_password"), $pass, $utf8)
|
||||
[System.IO.File]::WriteAllText((Join-Path $root "secrets\database_url"), "postgresql+asyncpg://messenger:${pass}@postgres:5432/messenger", $utf8)
|
||||
[System.IO.File]::WriteAllText((Join-Path $root "secrets\cache_url"), "redis://redis:6379/0", $utf8)
|
||||
[System.IO.File]::WriteAllText((Join-Path $root "secrets\host_database_url"), "postgresql+asyncpg://messenger:${pass}@127.0.0.1:5433/messenger", $utf8)
|
||||
[System.IO.File]::WriteAllText((Join-Path $root "secrets\host_cache_url"), "redis://127.0.0.1:6379/0", $utf8)
|
||||
[System.IO.File]::WriteAllText((Join-Path $root ".env"), "SESSION_TTL_SECONDS=3600`nAPP_ENV=lab`n", $utf8)
|
||||
Write-Host "bootstrap: wrote .env and secrets/ for the local lab stand"
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
# Создаёт локальные учебные секреты. Не печатает их и не кладёт в git.
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
mkdir -p secrets
|
||||
pass='lab-only-password'
|
||||
printf '%s' "$pass" > secrets/postgres_password
|
||||
printf '%s' "postgresql+asyncpg://messenger:${pass}@postgres:5432/messenger" > secrets/database_url
|
||||
printf '%s' 'redis://redis:6379/0' > secrets/cache_url
|
||||
printf '%s' "postgresql+asyncpg://messenger:${pass}@127.0.0.1:5433/messenger" > secrets/host_database_url
|
||||
printf '%s' 'redis://127.0.0.1:6379/0' > secrets/host_cache_url
|
||||
printf '%s\n' 'SESSION_TTL_SECONDS=3600' 'APP_ENV=lab' > .env
|
||||
echo 'bootstrap: wrote .env and secrets/ for the local lab stand'
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
# Перезапуск API и всех хранилищ лабораторной 2. Тома не удаляются.
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
if [ -f .env ]; then
|
||||
docker compose --env-file .env restart api postgres redis
|
||||
else
|
||||
docker compose restart api postgres redis
|
||||
fi
|
||||
Reference in New Issue
Block a user