Skip to content

Commit

Permalink
Update Dockerfile for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
harrywong committed Feb 25, 2019
1 parent 121a08a commit f1cb586
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 21 deletions.
18 changes: 13 additions & 5 deletions Docker/postgresql/Dockerfile → Docker/postgres/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ RUN set -x \
&& rm -rf /var/lib/apt/lists/* && apt-get purge -y --auto-remove ca-certificates wget unzip make postgresql-server-dev-${POSTGRES_DEV_VERSION} gcc libc6-dev libssl-dev libkrb5-dev \
&& rm -rf /tmp/pg_*

ENV POSTGRES_USERNAME="postgres" \
POSTGRES_PASSWORD="" \
PGDATA="/bitnami/postgresql"
ENV POSTGRES_USERNAME="postgres"
ENV POSTGRES_INITDB_ARGS="-D /var/lib/postgresql/data"
ENV PGDATA="/var/lib/postgresql/config"
ENV PGCONFIG="/var/lib/postgresql/config"
ENV AUTH="trust"

COPY initdb.d/* /docker-entrypoint-initdb.d/
COPY after-initdb.sh /docker-entrypoint-initdb.d/0-after-initdb.sh
RUN mkdir -p $PGDATA
RUN cp /usr/share/postgresql/postgresql.conf.sample $PGDATA/postgresql.conf
RUN sed -i -e "s/#include_dir = 'conf.d'/include_dir = 'conf.d'/" $PGDATA/postgresql.conf
COPY conf.d $PGDATA/conf.d/

RUN mkdir -p /docker-entrypoint-initdb.d
COPY ./initdb-auth.sh /docker-entrypoint-initdb.d/00-auth.sh
COPY ./initdb-pg_pathman.sh /docker-entrypoint-initdb.d/01-pg_pathman.sh
2 changes: 2 additions & 0 deletions Docker/postgres/conf.d/00-files.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data_directory = '/var/lib/postgresql/data'
hba_file = '/var/lib/postgresql/config/pg_hba.conf'
2 changes: 2 additions & 0 deletions Docker/postgres/conf.d/01-vacuum.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vacuum_cost_delay = 10
vacuum_cost_limit = 10000
1 change: 1 addition & 0 deletions Docker/postgres/conf.d/02-client.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shared_preload_libraries = 'pg_pathman'
10 changes: 10 additions & 0 deletions Docker/postgres/initdb-auth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

set -e

{
echo "# TYPE DATABASE USER ADDRESS METHOD"
echo "local all all trust"
echo "host all all 127.0.0.1/32 trust"
echo "host all all 0.0.0.0/0 $AUTH"
} >> "$PGCONFIG/pg_hba.conf"
14 changes: 14 additions & 0 deletions Docker/postgres/initdb-pg_pathman.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

set -e

# Perform all actions as $POSTGRES_USER
export PGUSER="$POSTGRES_USER"

# Load pg_pathman into $POSTGRES_DB
for DB in "$POSTGRES_DB"; do
echo "Loading pg_pathman extensions into $DB"
"${psql[@]}" <<-'EOSQL'
CREATE EXTENSION IF NOT EXISTS pg_pathman;
EOSQL
done
14 changes: 0 additions & 14 deletions Docker/postgresql/after-initdb.sh

This file was deleted.

1 change: 0 additions & 1 deletion Docker/postgresql/initdb.d/pg_pathman_enable.sql

This file was deleted.

1 change: 0 additions & 1 deletion Docker/postgresql/initdb.d/shared_preload_libraries.conf

This file was deleted.

1 change: 1 addition & 0 deletions scripts/docker_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def create(ctx, net, port, host, password, data_volume):
me = 'md5'
click.echo('{}: Password is set only if it\'s the first time creating postgres, otherwise it will reuse old password. Please use {} command.'.format(
green('NOTICE'), green('postgres updpass')))
return
else:
me = 'trust'

Expand Down

0 comments on commit f1cb586

Please sign in to comment.