diff options
Diffstat (limited to 'postgresql/docker-entrypoint.sh')
-rwxr-xr-x | postgresql/docker-entrypoint.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/postgresql/docker-entrypoint.sh b/postgresql/docker-entrypoint.sh new file mode 100755 index 0000000..c438de9 --- /dev/null +++ b/postgresql/docker-entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/sh -e + +_su(){ + su-exec postgres "$@" +} + +if ! [ -s "$PGDATA"/PG_VERSION ]; then + echo "Initializing database" + _su initdb --username=postgres + + _su pg_ctl -D "$PGDATA" \ + -o "-c listen_addresses=''" \ + -w start + + # create database for gitlab + _su psql -c "CREATE USER git CREATEDB;" + _su psql -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" + _su psql -c "CREATE DATABASE gitlabhq_production OWNER git;" + + _su pg_ctl -D "$PGDATA" -m fast -w stop +fi + +_su "$@" |