-
-
Save sshkarupa/5c9a03b718e67a515fa54747ba8fcad1 to your computer and use it in GitHub Desktop.
Revisions
-
jgould22 created this gist
Nov 12, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ FROM postgres:12-alpine MAINTAINER Jordan Gould <[email protected]> # Based on https://github.com/andreaswachowski/docker-postgres/blob/master/initdb.sh ENV PG_JOBMON_VERSION v1.3.3 ENV PG_PARTMAN_VERSION v4.2.2 # Install pg_jobmon RUN set -ex \ \ && apk add --no-cache --virtual .fetch-deps \ ca-certificates \ openssl \ tar \ \ && wget -O pg_jobmon.tar.gz "https://github.com/omniti-labs/pg_jobmon/archive/$PG_JOBMON_VERSION.tar.gz" \ && mkdir -p /usr/src/pg_jobmon \ && tar \ --extract \ --file pg_jobmon.tar.gz \ --directory /usr/src/pg_jobmon \ --strip-components 1 \ && rm pg_jobmon.tar.gz \ \ && apk add --no-cache --virtual .build-deps \ autoconf \ automake \ g++ \ libtool \ libxml2-dev \ make \ perl \ && cd /usr/src/pg_jobmon \ && make \ && make install \ && cd / \ && rm -rf /usr/src/pg_jobmon # Install pg_partman RUN set -ex \ && wget -O pg_partman.tar.gz "https://github.com/pgpartman/pg_partman/archive/$PG_PARTMAN_VERSION.tar.gz" \ && mkdir -p /usr/src/pg_partman \ && tar \ --extract \ --file pg_partman.tar.gz \ --directory /usr/src/pg_partman \ --strip-components 1 \ && rm pg_partman.tar.gz \ && cd /usr/src/pg_partman \ && make \ && make install \ && cd / \ && rm -rf /usr/src/pg_partman \ && apk del .fetch-deps .build-deps # Copy the init script # The Docker Postgres initd script will run anything # in the directory /docker-entrypoint-initdb.d COPY initdb.sh /docker-entrypoint-initdb.d/initdb.sh This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ #!/bin/bash -e echo "Creating dblink extension" psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL CREATE SCHEMA dblink; CREATE EXTENSION dblink SCHEMA dblink; EOSQL echo "Creating jobmon extension" psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL CREATE SCHEMA jobmon; CREATE EXTENSION pg_jobmon SCHEMA jobmon; INSERT INTO jobmon.dblink_mapping_jobmon (username, pwd) VALUES ('$POSTGRES_USER', '$POSTGRES_PASSWORD'); EOSQL echo "Creating partman extension" psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL CREATE SCHEMA partman; CREATE EXTENSION pg_partman SCHEMA partman; EOSQL echo "Adding jobmon permissions" psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL GRANT USAGE ON SCHEMA jobmon TO $POSTGRES_USER; GRANT USAGE ON SCHEMA dblink TO $POSTGRES_USER; GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA jobmon TO $POSTGRES_USER; GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA jobmon TO $POSTGRES_USER; GRANT ALL ON ALL SEQUENCES IN SCHEMA jobmon TO $POSTGRES_USER; EOSQL echo "ADDING pg_partman_bgw TO postgresql.conf" echo "shared_preload_libraries = 'pg_partman_bgw'" >> $PGDATA/postgresql.conf echo "pg_partman_bgw.interval = 3600" >> $PGDATA/postgresql.conf echo "pg_partman_bgw.role = '$POSTGRES_USER'" >> $PGDATA/postgresql.conf echo "pg_partman_bgw.dbname = '$POSTGRES_DB'" >> $PGDATA/postgresql.conf