reorder scripts and add new env variable for shared libraries (#231)

* reorder scripts and add new env variable for shared libraries

* Fix failing test

* Increase timeout for collation tests

Co-authored-by: admire <admire@kartoza.com>
pull/233/head
mazano 2020-04-14 19:00:36 +02:00 zatwierdzone przez GitHub
rodzic af1e88beab
commit 8b12300b2b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
19 zmienionych plików z 37 dodań i 38 usunięć

Wyświetl plik

@ -21,7 +21,7 @@ RUN set -eux \
# Generating locales takes a long time. Utilize caching by runnig it by itself
# early in the build process.
COPY locale.gen /etc/locale.gen
COPY scripts/locale.gen /etc/locale.gen
RUN set -eux \
&& /usr/sbin/locale-gen
@ -50,24 +50,15 @@ RUN set -eux \
EXPOSE 5432
# Copy scripts
COPY docker-entrypoint.sh \
env-data.sh \
setup.sh \
setup-conf.sh \
setup-database.sh \
setup-pg_hba.sh \
setup-replication.sh \
setup-ssl.sh \
setup-user.sh \
/
ADD scripts /scripts
WORKDIR /scripts
RUN chmod +x *.sh
# Run any additional tasks here that are too tedious to put in
# this dockerfile directly.
RUN set -eux \
&& chmod +x /setup.sh \
&& /setup.sh \
&& chmod +x /docker-entrypoint.sh
&& /scripts/setup.sh
VOLUME /var/lib/postgresql
ENTRYPOINT /docker-entrypoint.sh
ENTRYPOINT /scripts/docker-entrypoint.sh

Wyświetl plik

@ -146,6 +146,10 @@ user name, password and/or default database name(or multiple databases comma sep
* `-e POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology`
You can pass as many extensions as you need.
* `-e SHARED_PRELOAD_LIBRARIES='pg_cron'`
Some extensions need to be registered in the postgresql.conf
as shared_preload_libraries. pg_cron should always be added because
the extension is installed with the image.
* `-e SSL_CERT_FILE=/your/own/ssl_cert_file.pem`
* `-e SSL_KEY_FILE=/your/own/ssl_key_file.key`
* `-e SSL_CA_FILE=/your/own/ssl_ca_file.pem`

Wyświetl plik

@ -1,6 +1,6 @@
#!/usr/bin/env bash
. /env-data.sh
. /scripts/env-data.sh
set -e

Wyświetl plik

@ -1,6 +1,6 @@
#!/usr/bin/env bash
. /env-data.sh
. /scripts/env-data.sh
set -e

Wyświetl plik

@ -8,7 +8,7 @@ source ../test-env.sh
# Run service
docker-compose up -d
sleep 5
sleep 30
services=("pg" "pg-new")
@ -16,7 +16,7 @@ for service in "${services[@]}"; do
# Execute tests
until docker-compose exec $service pg_isready; do
sleep 1
sleep 30
done;
docker-compose exec $service /bin/bash /tests/test.sh

Wyświetl plik

@ -2,7 +2,7 @@
set -e
source /env-data.sh
source /scripts/env-data.sh
# execute tests
pushd /tests

Wyświetl plik

@ -2,7 +2,7 @@
set -e
source /env-data.sh
source /scripts/env-data.sh
# execute tests
pushd /tests

Wyświetl plik

@ -2,7 +2,7 @@
set -e
source /env-data.sh
source /scripts/env-data.sh
# execute tests
pushd /tests

Wyświetl plik

@ -2,7 +2,7 @@
set -e
source /env-data.sh
source /scripts/env-data.sh
# execute tests
pushd /tests

Wyświetl plik

@ -2,29 +2,29 @@
set -e
source /env-data.sh
source /scripts/env-data.sh
# Setup postgres CONF file
source /setup-conf.sh
source /scripts/setup-conf.sh
# Setup ssl
source /setup-ssl.sh
source /scripts/setup-ssl.sh
# Setup pg_hba.conf
source /setup-pg_hba.sh
source /scripts/setup-pg_hba.sh
if [[ -z "$REPLICATE_FROM" ]]; then
# This means this is a master instance. We check that database exists
echo "Setup master database"
source /setup-database.sh
source /scripts/setup-database.sh
entry_point_script
kill_postgres
else
# This means this is a slave/replication instance.
echo "Setup slave database"
source /setup-replication.sh
source /scripts/setup-replication.sh
fi

Wyświetl plik

@ -213,6 +213,10 @@ if [ -z "$EXTRA_CONF" ]; then
EXTRA_CONF=""
fi
if [ -z "${SHARED_PRELOAD_LIBRARIES}" ]; then
SHARED_PRELOAD_LIBRARIES='pg_cron'
fi
# Compatibility with official postgres variable
# Official postgres variable gets priority
if [ -n "${POSTGRES_PASSWORD}" ]; then

Wyświetl plik

@ -1,6 +1,6 @@
#!/usr/bin/env bash
source /env-data.sh
source /scripts/env-data.sh
SETUP_LOCKFILE="${ROOT_CONF}/.postgresql.conf.lock"
if [ -f "${SETUP_LOCKFILE}" ]; then
@ -47,7 +47,7 @@ primary_conninfo = 'host=${REPLICATE_FROM} port=${REPLICATE_PORT} user=${REPLICA
recovery_target_timeline=${TARGET_TIMELINE}
recovery_target_action=${TARGET_ACTION}
promote_trigger_file = '${PROMOTE_FILE}'
shared_preload_libraries = 'pg_cron'
shared_preload_libraries = '${SHARED_PRELOAD_LIBRARIES}'
cron.database_name = '${SINGLE_DB}'
EOF

Wyświetl plik

@ -1,6 +1,6 @@
#!/usr/bin/env bash
source /env-data.sh
source /scripts/env-data.sh
# test if DATADIR has content
# Do initialization if DATADIR is empty, or RECREATE_DATADIR is true
@ -36,7 +36,7 @@ done
echo "postgres ready"
# Setup user
source /setup-user.sh
source /scripts/setup-user.sh
# enable extensions in template1 if env variable set to true
if [[ "$(boolean ${POSTGRES_TEMPLATE_EXTENSIONS})" == TRUE ]] ; then

Wyświetl plik

@ -1,6 +1,6 @@
#!/usr/bin/env bash
source /env-data.sh
source /scripts/env-data.sh
SETUP_LOCKFILE="${ROOT_CONF}/.pg_hba.conf.lock"
if [ -f "${SETUP_LOCKFILE}" ]; then

Wyświetl plik

@ -1,6 +1,6 @@
#!/usr/bin/env bash
source /env-data.sh
source /scripts/env-data.sh
# This script will setup slave instance to use standby replication

Wyświetl plik

@ -1,6 +1,6 @@
#!/usr/bin/env bash
source /env-data.sh
source /scripts/env-data.sh
SETUP_LOCKFILE="${ROOT_CONF}/.ssl.conf.lock"
if [ -f "${SETUP_LOCKFILE}" ]; then

Wyświetl plik

@ -1,6 +1,6 @@
#!/usr/bin/env bash
source /env-data.sh
source /scripts/env-data.sh
# This script will setup new configured user

Wyświetl plik

@ -3,7 +3,7 @@
chmod 600 /etc/ssl/private/ssl-cert-snakeoil.key
# These tasks are run as root
source /env-data.sh
source /scripts/env-data.sh
# Restrict subnet to docker private network