Replaced hardcoded 'CHANGE_ME' in the SQL init file with a shell script that reads FORGEJO_DB_PASSWORD from the environment. Also pass the variable into the postgres service in docker-compose.yml so it is available at init time. https://claude.ai/code/session_01FKCW3FDjNFj6jve4niMFXH
10 lines
406 B
Bash
Executable file
10 lines
406 B
Bash
Executable file
#!/usr/bin/env bash
|
|
# Create a dedicated database and user for Forgejo.
|
|
# Runs once when the Postgres container is first initialised.
|
|
# FORGEJO_DB_PASSWORD must be set in the environment (via docker-compose.yml).
|
|
set -euo pipefail
|
|
|
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
|
|
CREATE USER forgejo WITH PASSWORD '${FORGEJO_DB_PASSWORD}';
|
|
CREATE DATABASE forgejo OWNER forgejo;
|
|
EOSQL
|