first of all, you need super account, for example user postgres
and password insecret-pass
.
Use super account to connect postgres server and create database app-name
and user app
, then grant app
to app-name
.
docker run --rm \
-e INIT_POSTGRES_HOST=postgres.example.com \
-e INIT_POSTGRES_PORT=5432 \
-e INIT_POSTGRES_DBNAME=app-name \
-e INIT_POSTGRES_USER=app \
-e INIT_POSTGRES_PASS=pass \
-e INIT_POSTGRES_SUPER_USER=postgres \
-e INIT_POSTGRES_SUPER_PASS=insecret-pass \
ghcr.io/onedr0p/postgres-init
echo "CREATE USER app WITH CREATEDB SUPERUSER PASSWORD pass;
CREATE DATABASE app-name OWNER app;" > init.sql
docker run --rm \
-e SENZING_SQL_FILES=/init.sql \
-e SENZING_DATABASE_URL=postgresql://postgres:insecret-pass@postgres.example.com \
-v init.sql:/init.sql \
senzing/postgresql-client