Files
ai-soulmate-local-deployment/scripts/create-local-env.sh
T

55 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
target_path="${1:-compose/.env}"
force_write="${FORCE_WRITE:-0}"
if [[ -e "$target_path" && "$force_write" != "1" ]]; then
printf 'Refusing to overwrite %s; set FORCE_WRITE=1 to replace it.\n' "$target_path" >&2
exit 1
fi
if ! command -v openssl >/dev/null 2>&1; then
printf 'openssl is required to generate local secrets.\n' >&2
exit 1
fi
target_directory="$(dirname -- "$target_path")"
mkdir -p -- "$target_directory"
umask 077
random_secret() {
openssl rand -hex 32
}
cat > "$target_path" <<EOF
COMPOSE_PROJECT_NAME=ai-soulmate-infra
DOCKER_NETWORK_NAME=ai-soulmate-internal
TZ=Asia/Shanghai
POSTGRES_IMAGE=postgres:16-alpine
POSTGRES_DB=ai_soulmate
POSTGRES_USER=ai_soulmate
POSTGRES_PASSWORD=$(random_secret)
POSTGRES_HOST_PORT=5432
POSTGRES_VOLUME_NAME=ai-soulmate-postgres-data
REDIS_IMAGE=redis:7-alpine
REDIS_PASSWORD=$(random_secret)
REDIS_HOST_PORT=6379
REDIS_VOLUME_NAME=ai-soulmate-redis-data
MINIO_IMAGE=minio/minio:latest
MINIO_MC_IMAGE=minio/mc:latest
MINIO_ROOT_USER=ai_soulmate_admin
MINIO_ROOT_PASSWORD=$(random_secret)
MINIO_BUCKET=ai-soulmate
MINIO_API_HOST_PORT=9000
MINIO_CONSOLE_HOST_PORT=9001
MINIO_VOLUME_NAME=ai-soulmate-minio-data
EOF
chmod 600 "$target_path"
printf 'Created %s with generated secrets.\n' "$target_path"
printf 'Replace mutable image tags with verified tags or digests before a release.\n'