-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build postgresql image with bitnami/postgres as a base image
Install required tools for doing backup operation Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
- Loading branch information
1 parent
da43bcd
commit 95136fd
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM bitnami/postgresql:11.5.0-debian-9-r1 | ||
|
||
USER root | ||
|
||
# Explicitly set user/group IDs | ||
RUN useradd -r --gid=0 --uid=1001 postgres | ||
|
||
# Install required components for backup | ||
RUN set -x \ | ||
&& apt-get update \ | ||
&& apt-get install -y curl groff lzop pv postgresql-client python3-pip daemontools \ | ||
&& pip3 install --upgrade pip \ | ||
&& hash -r pip3 \ | ||
&& pip3 install wal-e[aws] \ | ||
&& pip3 install awscli \ | ||
&& (cd /usr/local/bin; curl -L https://github.com/wal-g/wal-g/releases/download/v0.1.7/wal-g.linux-amd64.tar.gz | tar -zxv) | ||
|
||
# Override base image's CMD script | ||
COPY docker/postgresql/run.sh / | ||
|
||
RUN chown postgres:root /run.sh | ||
|
||
USER postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
# Forked from https://github.com/bitnami/bitnami-docker-postgresql/blob/master/11/debian-9/rootfs/run.sh | ||
# to modify runtime args | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
# set -o xtrace # Uncomment this line for debugging purpose | ||
# shellcheck disable=SC1091 | ||
|
||
# Load libraries | ||
. /libpostgresql.sh | ||
. /libos.sh | ||
|
||
# Load PostgreSQL environment variables | ||
eval "$(postgresql_env)" | ||
readonly flags=("-D" "$POSTGRESQL_DATA_DIR" "--config-file=$POSTGRESQL_CONF_FILE" "--external_pid_file=$POSTGRESQL_PID_FILE" "--hba_file=$POSTGRESQL_PGHBA_FILE" "-c" "archive_command=envdir \"${PGDATA}/env\" wal-e wal-push %p" "-c" "archive_mode=true" "-c" "archive_timeout=60" "-c" "wal_level=archive") | ||
readonly cmd=$(command -v postgres) | ||
|
||
info "** Starting PostgreSQL **" | ||
if am_i_root; then | ||
exec gosu "$POSTGRESQL_DAEMON_USER" "${cmd}" "${flags[@]}" | ||
else | ||
exec "${cmd}" "${flags[@]}" | ||
fi |