mirror of
https://github.com/bitnami/containers.git
synced 2026-03-13 06:48:08 +08:00
12.6.0-debian-10-r45 release
This commit is contained in:
@@ -22,7 +22,7 @@ COPY rootfs /
|
|||||||
RUN /opt/bitnami/scripts/postgresql/postunpack.sh
|
RUN /opt/bitnami/scripts/postgresql/postunpack.sh
|
||||||
RUN /opt/bitnami/scripts/locales/add-extra-locales.sh
|
RUN /opt/bitnami/scripts/locales/add-extra-locales.sh
|
||||||
ENV BITNAMI_APP_NAME="postgresql" \
|
ENV BITNAMI_APP_NAME="postgresql" \
|
||||||
BITNAMI_IMAGE_VERSION="12.6.0-debian-10-r44" \
|
BITNAMI_IMAGE_VERSION="12.6.0-debian-10-r45" \
|
||||||
LANG="en_US.UTF-8" \
|
LANG="en_US.UTF-8" \
|
||||||
LANGUAGE="en_US:en" \
|
LANGUAGE="en_US:en" \
|
||||||
NSS_WRAPPER_LIB="/opt/bitnami/common/lib/libnss_wrapper.so" \
|
NSS_WRAPPER_LIB="/opt/bitnami/common/lib/libnss_wrapper.so" \
|
||||||
|
|||||||
@@ -357,19 +357,6 @@ postgresql_create_replication_user() {
|
|||||||
echo "CREATE ROLE \"$POSTGRESQL_REPLICATION_USER\" REPLICATION LOGIN ENCRYPTED PASSWORD '$escaped_password'" | postgresql_execute
|
echo "CREATE ROLE \"$POSTGRESQL_REPLICATION_USER\" REPLICATION LOGIN ENCRYPTED PASSWORD '$escaped_password'" | postgresql_execute
|
||||||
}
|
}
|
||||||
|
|
||||||
########################
|
|
||||||
# Return PostgreSQL major version
|
|
||||||
# Globals:
|
|
||||||
# POSTGRESQL_*
|
|
||||||
# Arguments:
|
|
||||||
# None
|
|
||||||
# Returns:
|
|
||||||
# String
|
|
||||||
#########################
|
|
||||||
postgresql_get_major_version() {
|
|
||||||
psql --version | grep -oE "[0-9]+\.[0-9]+" | grep -oE "^[0-9]+"
|
|
||||||
}
|
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# Change postgresql.conf by setting replication parameters
|
# Change postgresql.conf by setting replication parameters
|
||||||
# Globals:
|
# Globals:
|
||||||
@@ -493,7 +480,7 @@ postgresql_create_admin_user() {
|
|||||||
# None
|
# None
|
||||||
#########################
|
#########################
|
||||||
postgresql_create_custom_database() {
|
postgresql_create_custom_database() {
|
||||||
echo "CREATE DATABASE \"$POSTGRESQL_DATABASE\"" | postgresql_execute "" "postgres" "" "localhost"
|
echo "CREATE DATABASE \"$POSTGRESQL_DATABASE\"" | postgresql_execute "" "postgres" ""
|
||||||
}
|
}
|
||||||
|
|
||||||
########################
|
########################
|
||||||
@@ -732,43 +719,6 @@ postgresql_stop() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
########################
|
|
||||||
# Execute an arbitrary query/queries against the running PostgreSQL service
|
|
||||||
# Stdin:
|
|
||||||
# Query/queries to execute
|
|
||||||
# Globals:
|
|
||||||
# BITNAMI_DEBUG
|
|
||||||
# POSTGRESQL_*
|
|
||||||
# Arguments:
|
|
||||||
# $1 - Database where to run the queries
|
|
||||||
# $2 - User to run queries
|
|
||||||
# $3 - Password
|
|
||||||
# $4 - Host
|
|
||||||
# $5 - Port
|
|
||||||
# $6 - Extra options (eg. -tA)
|
|
||||||
# Returns:
|
|
||||||
# None
|
|
||||||
postgresql_execute() {
|
|
||||||
local -r db="${1:-}"
|
|
||||||
local -r user="${2:-postgres}"
|
|
||||||
local -r pass="${3:-}"
|
|
||||||
local -r host="${4:-localhost}"
|
|
||||||
local -r port="${5:-5432}"
|
|
||||||
local -r opts="${6:-}"
|
|
||||||
|
|
||||||
local args=("-h" "$host" "-p" "$port" "-U" "$user")
|
|
||||||
local cmd=("$POSTGRESQL_BIN_DIR/psql")
|
|
||||||
[[ -n "$db" ]] && args+=("-d" "$db")
|
|
||||||
[[ -n "$opts" ]] && args+=("$opts")
|
|
||||||
if [[ "${BITNAMI_DEBUG:-false}" = true ]]; then
|
|
||||||
PGPASSWORD=$pass "${cmd[@]}" "${args[@]}"
|
|
||||||
elif [[ "${NO_ERRORS:-false}" = true ]]; then
|
|
||||||
PGPASSWORD=$pass "${cmd[@]}" "${args[@]}" 2>/dev/null
|
|
||||||
else
|
|
||||||
PGPASSWORD=$pass "${cmd[@]}" "${args[@]}" >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# Start PostgreSQL and wait until it is ready
|
# Start PostgreSQL and wait until it is ready
|
||||||
# Globals:
|
# Globals:
|
||||||
@@ -1015,3 +965,288 @@ postgresql_remove_pghba_lines() {
|
|||||||
echo "$result" >"$POSTGRESQL_PGHBA_FILE"
|
echo "$result" >"$POSTGRESQL_PGHBA_FILE"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Return PostgreSQL major version
|
||||||
|
# Globals:
|
||||||
|
# POSTGRESQL_*
|
||||||
|
# Arguments:
|
||||||
|
# None
|
||||||
|
# Returns:
|
||||||
|
# String
|
||||||
|
#########################
|
||||||
|
postgresql_get_major_version() {
|
||||||
|
psql --version | grep -oE "[0-9]+\.[0-9]+" | grep -oE "^[0-9]+"
|
||||||
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Gets an environment variable name based on the suffix
|
||||||
|
# Arguments:
|
||||||
|
# $1 - environment variable suffix
|
||||||
|
# Returns:
|
||||||
|
# environment variable name
|
||||||
|
#########################
|
||||||
|
get_env_var_value() {
|
||||||
|
local env_var_suffix="${1:?missing suffix}"
|
||||||
|
local env_var_name
|
||||||
|
for env_var_prefix in POSTGRESQL POSTGRESQL_CLIENT; do
|
||||||
|
env_var_name="${env_var_prefix}_${env_var_suffix}"
|
||||||
|
if [[ -n "${!env_var_name:-}" ]]; then
|
||||||
|
echo "${!env_var_name}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Execute an arbitrary query/queries against the running PostgreSQL service and print the output
|
||||||
|
# Stdin:
|
||||||
|
# Query/queries to execute
|
||||||
|
# Globals:
|
||||||
|
# BITNAMI_DEBUG
|
||||||
|
# POSTGRESQL_*
|
||||||
|
# Arguments:
|
||||||
|
# $1 - Database where to run the queries
|
||||||
|
# $2 - User to run queries
|
||||||
|
# $3 - Password
|
||||||
|
# $4 - Extra options (eg. -tA)
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
#########################
|
||||||
|
postgresql_execute_print_output() {
|
||||||
|
local -r db="${1:-}"
|
||||||
|
local -r user="${2:-postgres}"
|
||||||
|
local -r pass="${3:-}"
|
||||||
|
local opts
|
||||||
|
read -r -a opts <<< "${@:4}"
|
||||||
|
|
||||||
|
local args=("-U" "$user")
|
||||||
|
[[ -n "$db" ]] && args+=("-d" "$db")
|
||||||
|
[[ "${#opts[@]}" -gt 0 ]] && args+=( "${opts[@]}" )
|
||||||
|
|
||||||
|
# Obtain the command specified via stdin
|
||||||
|
local sql_cmd
|
||||||
|
sql_cmd="$(< /dev/stdin)"
|
||||||
|
debug "Executing SQL command:\n$sql_cmd"
|
||||||
|
PGPASSWORD=$pass psql "${args[@]}" <<< "$sql_cmd"
|
||||||
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Execute an arbitrary query/queries against the running PostgreSQL service
|
||||||
|
# Stdin:
|
||||||
|
# Query/queries to execute
|
||||||
|
# Globals:
|
||||||
|
# BITNAMI_DEBUG
|
||||||
|
# POSTGRESQL_*
|
||||||
|
# Arguments:
|
||||||
|
# $1 - Database where to run the queries
|
||||||
|
# $2 - User to run queries
|
||||||
|
# $3 - Password
|
||||||
|
# $4 - Extra options (eg. -tA)
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
#########################
|
||||||
|
postgresql_execute() {
|
||||||
|
if [[ "${BITNAMI_DEBUG:-false}" = true ]]; then
|
||||||
|
"postgresql_execute_print_output" "$@"
|
||||||
|
elif [[ "${NO_ERRORS:-false}" = true ]]; then
|
||||||
|
"postgresql_execute_print_output" "$@" 2>/dev/null
|
||||||
|
else
|
||||||
|
"postgresql_execute_print_output" "$@" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Execute an arbitrary query/queries against a remote PostgreSQL service and print to stdout
|
||||||
|
# Stdin:
|
||||||
|
# Query/queries to execute
|
||||||
|
# Globals:
|
||||||
|
# BITNAMI_DEBUG
|
||||||
|
# DB_*
|
||||||
|
# Arguments:
|
||||||
|
# $1 - Remote PostgreSQL service hostname
|
||||||
|
# $2 - Remote PostgreSQL service port
|
||||||
|
# $3 - Database where to run the queries
|
||||||
|
# $4 - User to run queries
|
||||||
|
# $5 - Password
|
||||||
|
# $6 - Extra options (eg. -tA)
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
postgresql_remote_execute_print_output() {
|
||||||
|
local -r hostname="${1:?hostname is required}"
|
||||||
|
local -r port="${2:?port is required}"
|
||||||
|
local -a args=("-h" "$hostname" "-p" "$port")
|
||||||
|
shift 2
|
||||||
|
"postgresql_execute_print_output" "$@" "${args[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Execute an arbitrary query/queries against a remote PostgreSQL service
|
||||||
|
# Stdin:
|
||||||
|
# Query/queries to execute
|
||||||
|
# Globals:
|
||||||
|
# BITNAMI_DEBUG
|
||||||
|
# DB_*
|
||||||
|
# Arguments:
|
||||||
|
# $1 - Remote PostgreSQL service hostname
|
||||||
|
# $2 - Remote PostgreSQL service port
|
||||||
|
# $3 - Database where to run the queries
|
||||||
|
# $4 - User to run queries
|
||||||
|
# $5 - Password
|
||||||
|
# $6 - Extra options (eg. -tA)
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
postgresql_remote_execute() {
|
||||||
|
if [[ "${BITNAMI_DEBUG:-false}" = true ]]; then
|
||||||
|
"postgresql_remote_execute_print_output" "$@"
|
||||||
|
elif [[ "${NO_ERRORS:-false}" = true ]]; then
|
||||||
|
"postgresql_remote_execute_print_output" "$@" 2>/dev/null
|
||||||
|
else
|
||||||
|
"postgresql_remote_execute_print_output" "$@" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Optionally create the given database user
|
||||||
|
# Flags:
|
||||||
|
# -p|--password - database password
|
||||||
|
# --host - database host
|
||||||
|
# --port - database port
|
||||||
|
# Arguments:
|
||||||
|
# $1 - user
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
#########################
|
||||||
|
postgresql_ensure_user_exists() {
|
||||||
|
local -r user="${1:?user is missing}"
|
||||||
|
local password=""
|
||||||
|
# For accessing an external database
|
||||||
|
local db_host=""
|
||||||
|
local db_port=""
|
||||||
|
|
||||||
|
# Validate arguments
|
||||||
|
shift 1
|
||||||
|
while [ "$#" -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
-p|--password)
|
||||||
|
shift
|
||||||
|
password="${1:?missing password}"
|
||||||
|
;;
|
||||||
|
--host)
|
||||||
|
shift
|
||||||
|
db_host="${1:?missing database host}"
|
||||||
|
;;
|
||||||
|
--port)
|
||||||
|
shift
|
||||||
|
db_port="${1:?missing database port}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid command line flag $1" >&2
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
local -a postgresql_execute_cmd=("postgresql_execute")
|
||||||
|
[[ -n "$db_host" && -n "$db_port" ]] && postgresql_execute_cmd=("postgresql_remote_execute" "$db_host" "$db_port")
|
||||||
|
local -a postgresql_execute_flags=("" "$(get_env_var_value POSTGRES_USER)" "$(get_env_var_value POSTGRES_PASSWORD)")
|
||||||
|
|
||||||
|
"${postgresql_execute_cmd[@]}" "${postgresql_execute_flags[@]}" <<EOF
|
||||||
|
DO
|
||||||
|
\$do\$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT FROM pg_catalog.pg_roles WHERE rolname = '${user}'
|
||||||
|
) THEN
|
||||||
|
CREATE ROLE "${user}" LOGIN PASSWORD '${password}';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
\$do\$;
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Ensure a user has all privileges to access a database
|
||||||
|
# Arguments:
|
||||||
|
# $1 - database name
|
||||||
|
# $2 - database user
|
||||||
|
# $3 - database host (optional)
|
||||||
|
# $4 - database port (optional)
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
#########################
|
||||||
|
postgresql_ensure_user_has_database_privileges() {
|
||||||
|
local -r user="${1:?user is required}"
|
||||||
|
local -r database="${2:?db is required}"
|
||||||
|
local -r db_host="${3:-}"
|
||||||
|
local -r db_port="${4:-}"
|
||||||
|
|
||||||
|
local -a postgresql_execute_cmd=("postgresql_execute")
|
||||||
|
[[ -n "$db_host" && -n "$db_port" ]] && postgresql_execute_cmd=("postgresql_remote_execute" "$db_host" "$db_port")
|
||||||
|
local -a postgresql_execute_flags=("" "$(get_env_var_value POSTGRES_USER)" "$(get_env_var_value POSTGRES_PASSWORD)")
|
||||||
|
|
||||||
|
debug "Providing privileges to username ${user} on database ${database}"
|
||||||
|
"${postgresql_execute_cmd[@]}" "${postgresql_execute_flags[@]}" <<EOF
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE "${database}" TO "${user}";
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Optionally create the given database, and then optionally give a user
|
||||||
|
# full privileges on the database.
|
||||||
|
# Flags:
|
||||||
|
# -u|--user - database user
|
||||||
|
# --host - database host
|
||||||
|
# --port - database port
|
||||||
|
# Arguments:
|
||||||
|
# $1 - database name
|
||||||
|
# Returns:
|
||||||
|
# None
|
||||||
|
#########################
|
||||||
|
postgresql_ensure_database_exists() {
|
||||||
|
local -r database="${1:?database is missing}"
|
||||||
|
local user=""
|
||||||
|
# For accessing an external database
|
||||||
|
local db_host=""
|
||||||
|
local db_port=""
|
||||||
|
|
||||||
|
# Validate arguments
|
||||||
|
shift 1
|
||||||
|
while [ "$#" -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
-u|--user)
|
||||||
|
shift
|
||||||
|
user="${1:?missing database user}"
|
||||||
|
;;
|
||||||
|
--host)
|
||||||
|
shift
|
||||||
|
db_host="${1:?missing database host}"
|
||||||
|
;;
|
||||||
|
--port)
|
||||||
|
shift
|
||||||
|
db_port="${1:?missing database port}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid command line flag $1" >&2
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
local -a postgresql_execute_cmd=("postgresql_execute")
|
||||||
|
[[ -n "$db_host" && -n "$db_port" ]] && postgresql_execute_cmd=("postgresql_remote_execute" "$db_host" "$db_port")
|
||||||
|
local -a postgresql_execute_flags=("" "$(get_env_var_value POSTGRES_USER)" "$(get_env_var_value POSTGRES_PASSWORD)")
|
||||||
|
|
||||||
|
"${postgresql_execute_cmd[@]}" "${postgresql_execute_flags[@]}" <<EOF
|
||||||
|
SELECT 'CREATE DATABASE "${database}"'
|
||||||
|
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '${database}')\gexec
|
||||||
|
EOF
|
||||||
|
if [[ -n "$user" ]]; then
|
||||||
|
local -a grant_flags=("$user" "$database")
|
||||||
|
[[ -n "$db_host" ]] && grant_flags+=("$db_host")
|
||||||
|
[[ -n "$db_port" ]] && grant_flags+=("$db_port")
|
||||||
|
postgresql_ensure_user_has_database_privileges "${grant_flags[@]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
@@ -163,7 +163,6 @@ done
|
|||||||
unset postgresql_env_vars
|
unset postgresql_env_vars
|
||||||
|
|
||||||
# Paths
|
# Paths
|
||||||
export PATH="/opt/bitnami/postgresql/bin:/opt/bitnami/common/bin:$PATH"
|
|
||||||
export POSTGRESQL_VOLUME_DIR="/bitnami/postgresql"
|
export POSTGRESQL_VOLUME_DIR="/bitnami/postgresql"
|
||||||
export POSTGRESQL_BASE_DIR="/opt/bitnami/postgresql"
|
export POSTGRESQL_BASE_DIR="/opt/bitnami/postgresql"
|
||||||
POSTGRESQL_DATA_DIR="${POSTGRESQL_DATA_DIR:-"${POSTGRES_DATA_DIR:-}"}"
|
POSTGRESQL_DATA_DIR="${POSTGRESQL_DATA_DIR:-"${POSTGRES_DATA_DIR:-}"}"
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ Learn more about the Bitnami tagging policy and the difference between rolling t
|
|||||||
|
|
||||||
|
|
||||||
* [`13`, `13-debian-10`, `13.2.0`, `13.2.0-debian-10-r44` (13/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/13.2.0-debian-10-r44/13/debian-10/Dockerfile)
|
* [`13`, `13-debian-10`, `13.2.0`, `13.2.0-debian-10-r44` (13/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/13.2.0-debian-10-r44/13/debian-10/Dockerfile)
|
||||||
* [`12`, `12-debian-10`, `12.6.0`, `12.6.0-debian-10-r44` (12/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/12.6.0-debian-10-r44/12/debian-10/Dockerfile)
|
* [`12`, `12-debian-10`, `12.6.0`, `12.6.0-debian-10-r45` (12/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/12.6.0-debian-10-r45/12/debian-10/Dockerfile)
|
||||||
* [`11`, `11-debian-10`, `11.11.0`, `11.11.0-debian-10-r46`, `latest` (11/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/11.11.0-debian-10-r46/11/debian-10/Dockerfile)
|
* [`11`, `11-debian-10`, `11.11.0`, `11.11.0-debian-10-r46`, `latest` (11/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/11.11.0-debian-10-r46/11/debian-10/Dockerfile)
|
||||||
* [`10`, `10-debian-10`, `10.16.0`, `10.16.0-debian-10-r45` (10/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/10.16.0-debian-10-r45/10/debian-10/Dockerfile)
|
* [`10`, `10-debian-10`, `10.16.0`, `10.16.0-debian-10-r45` (10/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/10.16.0-debian-10-r45/10/debian-10/Dockerfile)
|
||||||
* [`9.6`, `9.6-debian-10`, `9.6.21`, `9.6.21-debian-10-r46` (9.6/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/9.6.21-debian-10-r46/9.6/debian-10/Dockerfile)
|
* [`9.6`, `9.6-debian-10`, `9.6.21`, `9.6.21-debian-10-r46` (9.6/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/9.6.21-debian-10-r46/9.6/debian-10/Dockerfile)
|
||||||
|
|||||||
Reference in New Issue
Block a user