aboutsummaryrefslogtreecommitdiffstats
path: root/postgresql/docker-entrypoint.sh
blob: c438de9fc64511fe2995771d26d5ae9c1aeeea25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 "$@"