Repository navigation
Expand file tree
/
Copy pathsetup-secrets.sh
More file actions
executable file
·62 lines (48 loc) · 1.92 KB
/
Copy pathsetup-secrets.sh
File metadata and controls
executable file
·62 lines (48 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env zsh
# setup-secrets.sh — Generates all required .secrets/ files for local development.
# Run once: chmod +x setup-secrets.sh && ./setup-secrets.sh
# All values are randomly generated — change them if you need fixed passwords.
set -euo pipefail
SECRETS_DIR=".secrets"
mkdir -p "$SECRETS_DIR"
gen() {
local name="$1"
local value="$2"
local path="$SECRETS_DIR/$name"
if [[ -f "$path" ]]; then
echo " [skip] $name (already exists)"
else
printf '%s' "$value" > "$path"
echo " [ok] $name"
fi
}
rand() { openssl rand -base64 32 | tr -d '\n/+=' | cut -c1-32; }
echo "Generating secrets in ./$SECRETS_DIR/ ..."
# PostgreSQL
gen "postgres_password" "$(rand)"
# RabbitMQ
gen "RabbitMQ__Password" "$(rand)"
# Elasticsearch
gen "Elasticsearch__Password" "$(rand)"
gen "kibana_system_password" "$(rand)"
gen "kibana_encryption_key" "$(openssl rand -base64 32 | tr -d '\n')"
gen "kibana_security_encryption_key" "$(openssl rand -base64 32 | tr -d '\n')"
gen "kibana_reporting_encryption_key" "$(openssl rand -base64 32 | tr -d '\n')"
# MinIO
gen "MinIO__AccessKey" "$(rand)"
gen "MinIO__SecretKey" "$(rand)"
# JWT
gen "Jwt__Secret" "$(openssl rand -base64 64 | tr -d '\n')"
# APM — same value in both files
APM_TOKEN="$(rand)"
gen "Apm__SecretToken" "$APM_TOKEN"
gen "Telemetry__ApmSecretToken" "$APM_TOKEN"
# Connection string — built from postgres_password
PG_PASS="$(cat $SECRETS_DIR/postgres_password)"
PG_DB="${POSTGRES_DB:-cleanarcstack}"
PG_USER="${POSTGRES_USER:-postgres}"
gen "ConnectionStrings__DefaultConnection" \
"Host=postgres;Port=5432;Database=$PG_DB;Username=$PG_USER;Password=$PG_PASS;"
echo ""
echo "Done. Keep .secrets/ out of Git (already in .gitignore)."
echo "Start everything with: docker compose up -d"