18 lines
801 B
Bash
18 lines
801 B
Bash
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
IMAGE="${1:?Application image is required}"
|
|
# Preserve existing credentials and Docker project/volume names during migration.
|
|
if [ ! -f /etc/prompt.env ]; then
|
|
umask 077
|
|
TEMP_ENV=$(mktemp /etc/prompt.env.XXXXXX)
|
|
trap 'rm -f "$TEMP_ENV"' EXIT
|
|
docker run --rm --entrypoint node "$IMAGE" -e "const {randomBytes}=require('crypto');const hex=()=>randomBytes(32).toString('hex');console.log('POSTGRES_PASSWORD='+hex()+'\nS3_ACCESS_KEY='+hex()+'\nS3_SECRET_KEY='+hex()+'\nS3_BUCKET=prompt')" > "$TEMP_ENV"
|
|
mv "$TEMP_ENV" /etc/prompt.env
|
|
trap - EXIT
|
|
fi
|
|
|
|
# Current public entry uses HTTP. Operators can set true here after enabling HTTPS.
|
|
if ! grep -q '^AUTH_COOKIE_SECURE=' /etc/prompt.env; then
|
|
printf '\nAUTH_COOKIE_SECURE=false\n' >> /etc/prompt.env
|
|
fi
|