You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This script is intended for three main use cases:
6
+
#
7
+
# 1. (most importantly) as an example of how to use "docker-entrypoint.sh" to extend/reuse the initialization behavior
8
+
#
9
+
# 2. ("docker-ensure-initdb.sh") as a Kubernetes "init container" to ensure the provided database directory is initialized; see also "startup probes" for an alternative solution
10
+
# (no-op if database is already initialized)
11
+
#
12
+
# 3. ("docker-enforce-initdb.sh") as part of CI to ensure the database is fully initialized before use
13
+
# (error if database is already initialized)
14
+
#
15
+
16
+
source /usr/local/bin/docker-entrypoint.sh
17
+
18
+
# arguments to this script are assumed to be arguments to the "postgres" server (same as "docker-entrypoint.sh"), and most "docker-entrypoint.sh" functions assume "postgres" is the first argument (see "_main" over there)
19
+
if [ "$#"-eq 0 ] || [ "$1"!='postgres' ];then
20
+
set -- postgres "$@"
21
+
fi
22
+
23
+
# see also "_main" in "docker-entrypoint.sh"
24
+
25
+
docker_setup_env
26
+
# setup data directories and permissions (when run as root)
27
+
docker_create_db_directories
28
+
if [ "$(id -u)"='0' ];then
29
+
# then restart script as postgres user
30
+
exec su-exec postgres "$BASH_SOURCE""$@"
31
+
fi
32
+
33
+
# only run initialization on an empty data directory
34
+
if [ -z"$DATABASE_ALREADY_EXISTS" ];then
35
+
docker_verify_minimum_env
36
+
37
+
# check dir permissions to reduce likelihood of half-initialized database
38
+
ls /docker-entrypoint-initdb.d/ > /dev/null
39
+
40
+
docker_init_database_dir
41
+
pg_setup_hba_conf "$@"
42
+
43
+
# PGPASSWORD is required for psql when authentication is required for 'local' connections via pg_hba.conf and is otherwise harmless
44
+
# e.g. when '--auth=md5' or '--auth-local=md5' is used in POSTGRES_INITDB_ARGS
0 commit comments