1
0

[info=e77a717227fe1ceca8587a22dc88ddce]

OBS-URL: https://build.opensuse.org/package/show/devel:BCI:Tumbleweed/postgres-12-image?expand=0&rev=9
This commit is contained in:
Dan Čermák 2023-02-21 08:49:43 +00:00 committed by Git OBS Bridge
parent 6b251b8ea4
commit 1ebba30c32
3 changed files with 40 additions and 24 deletions

View File

@ -2,6 +2,7 @@
#!BuildTag: opensuse/postgres:12 #!BuildTag: opensuse/postgres:12
#!BuildTag: opensuse/postgres:12-%RELEASE% #!BuildTag: opensuse/postgres:12-%RELEASE%
#!BuildTag: opensuse/postgres:%%pg_version%% #!BuildTag: opensuse/postgres:%%pg_version%%
#!BuildTag: opensuse/postgres:%%pg_version%%-%RELEASE%
FROM opensuse/tumbleweed:latest FROM opensuse/tumbleweed:latest

View File

@ -11,7 +11,7 @@ file_env() {
local fileVar="${var}_FILE" local fileVar="${var}_FILE"
local def="${2:-}" local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)" printf >&2 'error: both %s and %s are set (but are exclusive)\n' "$var" "$fileVar"
exit 1 exit 1
fi fi
local val="$def" local val="$def"
@ -77,8 +77,8 @@ docker_init_database_dir() {
NSS_WRAPPER_GROUP="$(mktemp)" NSS_WRAPPER_GROUP="$(mktemp)"
export LD_PRELOAD="$wrapper" NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP export LD_PRELOAD="$wrapper" NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP
local gid; gid="$(id -g)" local gid; gid="$(id -g)"
echo "postgres:x:$uid:$gid:PostgreSQL:$PGDATA:/bin/false" > "$NSS_WRAPPER_PASSWD" printf 'postgres:x:%s:%s:PostgreSQL:%s:/bin/false\n' "$uid" "$gid" "$PGDATA" > "$NSS_WRAPPER_PASSWD"
echo "postgres:x:$gid:" > "$NSS_WRAPPER_GROUP" printf 'postgres:x:%s:\n' "$gid" > "$NSS_WRAPPER_GROUP"
break break
fi fi
done done
@ -88,7 +88,8 @@ docker_init_database_dir() {
set -- --waldir "$POSTGRES_INITDB_WALDIR" "$@" set -- --waldir "$POSTGRES_INITDB_WALDIR" "$@"
fi fi
eval 'initdb --username="$POSTGRES_USER" --pwfile=<(echo "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"' # --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
# unset/cleanup "nss_wrapper" bits # unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
@ -157,7 +158,7 @@ docker_process_init_files() {
# psql here for backwards compatibility "${psql[@]}" # psql here for backwards compatibility "${psql[@]}"
psql=( docker_process_sql ) psql=( docker_process_sql )
echo printf '\n'
local f local f
for f; do for f; do
case "$f" in case "$f" in
@ -165,20 +166,20 @@ docker_process_init_files() {
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
# https://github.com/docker-library/postgres/pull/452 # https://github.com/docker-library/postgres/pull/452
if [ -x "$f" ]; then if [ -x "$f" ]; then
echo "$0: running $f" printf '%s: running %s\n' "$0" "$f"
"$f" "$f"
else else
echo "$0: sourcing $f" printf '%s: sourcing %s\n' "$0" "$f"
. "$f" . "$f"
fi fi
;; ;;
*.sql) echo "$0: running $f"; docker_process_sql -f "$f"; echo ;; *.sql) printf '%s: running %s\n' "$0" "$f"; docker_process_sql -f "$f"; printf '\n' ;;
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;; *.sql.gz) printf '%s: running %s\n' "$0" "$f"; gunzip -c "$f" | docker_process_sql; printf '\n' ;;
*.sql.xz) echo "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;; *.sql.xz) printf '%s: running %s\n' "$0" "$f"; xzcat "$f" | docker_process_sql; printf '\n' ;;
*.sql.zst) echo "$0: running $f"; zstd -dc "$f" | docker_process_sql; echo ;; *.sql.zst) printf '%s: running %s\n' "$0" "$f"; zstd -dc "$f" | docker_process_sql; printf '\n' ;;
*) echo "$0: ignoring $f" ;; *) printf '%s: ignoring %s\n' "$0" "$f" ;;
esac esac
echo printf '\n'
done done
} }
@ -209,7 +210,7 @@ docker_setup_db() {
POSTGRES_DB= docker_process_sql --dbname postgres --set db="$POSTGRES_DB" <<-'EOSQL' POSTGRES_DB= docker_process_sql --dbname postgres --set db="$POSTGRES_DB" <<-'EOSQL'
CREATE DATABASE :"db" ; CREATE DATABASE :"db" ;
EOSQL EOSQL
echo printf '\n'
fi fi
} }
@ -243,12 +244,12 @@ pg_setup_hba_conf() {
auth="$(postgres -C password_encryption "$@")" auth="$(postgres -C password_encryption "$@")"
: "${POSTGRES_HOST_AUTH_METHOD:=$auth}" : "${POSTGRES_HOST_AUTH_METHOD:=$auth}"
{ {
echo printf '\n'
if [ 'trust' = "$POSTGRES_HOST_AUTH_METHOD" ]; then if [ 'trust' = "$POSTGRES_HOST_AUTH_METHOD" ]; then
echo '# warning trust is enabled for all connections' printf '# warning trust is enabled for all connections\n'
echo '# see https://www.postgresql.org/docs/12/auth-trust.html' printf '# see https://www.postgresql.org/docs/12/auth-trust.html\n'
fi fi
echo "host all all all $POSTGRES_HOST_AUTH_METHOD" printf 'host all all all %s\n' "$POSTGRES_HOST_AUTH_METHOD"
} >> "$PGDATA/pg_hba.conf" } >> "$PGDATA/pg_hba.conf"
} }
@ -328,13 +329,17 @@ _main() {
docker_temp_server_stop docker_temp_server_stop
unset PGPASSWORD unset PGPASSWORD
echo cat <<-'EOM'
echo 'PostgreSQL init process complete; ready for start up.'
echo PostgreSQL init process complete; ready for start up.
EOM
else else
echo cat <<-'EOM'
echo 'PostgreSQL Database directory appears to contain a database; Skipping initialization'
echo PostgreSQL Database directory appears to contain a database; Skipping initialization
EOM
fi fi
fi fi

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Fri Dec 23 08:03:11 UTC 2022 - Dirk Müller <dmueller@suse.com>
- Update entrypoint scripts from upstream
-------------------------------------------------------------------
Wed Dec 21 14:05:32 UTC 2022 - Dirk Müller <dmueller@suse.com>
- BuildTag sorting and consistency fixes
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Nov 21 13:47:17 UTC 2022 - Dan Čermák <dcermak@suse.com> Mon Nov 21 13:47:17 UTC 2022 - Dan Čermák <dcermak@suse.com>