kopia lustrzana https://github.com/kartoza/docker-postgis
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
rodzic
af1e88beab
commit
8b12300b2b
21
Dockerfile
21
Dockerfile
|
@ -21,7 +21,7 @@ RUN set -eux \
|
||||||
|
|
||||||
# Generating locales takes a long time. Utilize caching by runnig it by itself
|
# Generating locales takes a long time. Utilize caching by runnig it by itself
|
||||||
# early in the build process.
|
# early in the build process.
|
||||||
COPY locale.gen /etc/locale.gen
|
COPY scripts/locale.gen /etc/locale.gen
|
||||||
RUN set -eux \
|
RUN set -eux \
|
||||||
&& /usr/sbin/locale-gen
|
&& /usr/sbin/locale-gen
|
||||||
|
|
||||||
|
@ -50,24 +50,15 @@ RUN set -eux \
|
||||||
EXPOSE 5432
|
EXPOSE 5432
|
||||||
|
|
||||||
# Copy scripts
|
# Copy scripts
|
||||||
COPY docker-entrypoint.sh \
|
ADD scripts /scripts
|
||||||
env-data.sh \
|
WORKDIR /scripts
|
||||||
setup.sh \
|
RUN chmod +x *.sh
|
||||||
setup-conf.sh \
|
|
||||||
setup-database.sh \
|
|
||||||
setup-pg_hba.sh \
|
|
||||||
setup-replication.sh \
|
|
||||||
setup-ssl.sh \
|
|
||||||
setup-user.sh \
|
|
||||||
/
|
|
||||||
|
|
||||||
# Run any additional tasks here that are too tedious to put in
|
# Run any additional tasks here that are too tedious to put in
|
||||||
# this dockerfile directly.
|
# this dockerfile directly.
|
||||||
RUN set -eux \
|
RUN set -eux \
|
||||||
&& chmod +x /setup.sh \
|
&& /scripts/setup.sh
|
||||||
&& /setup.sh \
|
|
||||||
&& chmod +x /docker-entrypoint.sh
|
|
||||||
|
|
||||||
VOLUME /var/lib/postgresql
|
VOLUME /var/lib/postgresql
|
||||||
|
|
||||||
ENTRYPOINT /docker-entrypoint.sh
|
ENTRYPOINT /scripts/docker-entrypoint.sh
|
||||||
|
|
|
@ -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`
|
* `-e POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology`
|
||||||
|
|
||||||
You can pass as many extensions as you need.
|
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_CERT_FILE=/your/own/ssl_cert_file.pem`
|
||||||
* `-e SSL_KEY_FILE=/your/own/ssl_key_file.key`
|
* `-e SSL_KEY_FILE=/your/own/ssl_key_file.key`
|
||||||
* `-e SSL_CA_FILE=/your/own/ssl_ca_file.pem`
|
* `-e SSL_CA_FILE=/your/own/ssl_ca_file.pem`
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
. /env-data.sh
|
. /scripts/env-data.sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
. /env-data.sh
|
. /scripts/env-data.sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ source ../test-env.sh
|
||||||
# Run service
|
# Run service
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
|
||||||
sleep 5
|
sleep 30
|
||||||
|
|
||||||
services=("pg" "pg-new")
|
services=("pg" "pg-new")
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ for service in "${services[@]}"; do
|
||||||
|
|
||||||
# Execute tests
|
# Execute tests
|
||||||
until docker-compose exec $service pg_isready; do
|
until docker-compose exec $service pg_isready; do
|
||||||
sleep 1
|
sleep 30
|
||||||
done;
|
done;
|
||||||
docker-compose exec $service /bin/bash /tests/test.sh
|
docker-compose exec $service /bin/bash /tests/test.sh
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
# execute tests
|
# execute tests
|
||||||
pushd /tests
|
pushd /tests
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
# execute tests
|
# execute tests
|
||||||
pushd /tests
|
pushd /tests
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
# execute tests
|
# execute tests
|
||||||
pushd /tests
|
pushd /tests
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
# execute tests
|
# execute tests
|
||||||
pushd /tests
|
pushd /tests
|
||||||
|
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
# Setup postgres CONF file
|
# Setup postgres CONF file
|
||||||
|
|
||||||
source /setup-conf.sh
|
source /scripts/setup-conf.sh
|
||||||
|
|
||||||
# Setup ssl
|
# Setup ssl
|
||||||
source /setup-ssl.sh
|
source /scripts/setup-ssl.sh
|
||||||
|
|
||||||
# Setup pg_hba.conf
|
# Setup pg_hba.conf
|
||||||
|
|
||||||
source /setup-pg_hba.sh
|
source /scripts/setup-pg_hba.sh
|
||||||
|
|
||||||
if [[ -z "$REPLICATE_FROM" ]]; then
|
if [[ -z "$REPLICATE_FROM" ]]; then
|
||||||
# This means this is a master instance. We check that database exists
|
# This means this is a master instance. We check that database exists
|
||||||
echo "Setup master database"
|
echo "Setup master database"
|
||||||
source /setup-database.sh
|
source /scripts/setup-database.sh
|
||||||
entry_point_script
|
entry_point_script
|
||||||
kill_postgres
|
kill_postgres
|
||||||
else
|
else
|
||||||
# This means this is a slave/replication instance.
|
# This means this is a slave/replication instance.
|
||||||
echo "Setup slave database"
|
echo "Setup slave database"
|
||||||
source /setup-replication.sh
|
source /scripts/setup-replication.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,10 @@ if [ -z "$EXTRA_CONF" ]; then
|
||||||
EXTRA_CONF=""
|
EXTRA_CONF=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "${SHARED_PRELOAD_LIBRARIES}" ]; then
|
||||||
|
SHARED_PRELOAD_LIBRARIES='pg_cron'
|
||||||
|
fi
|
||||||
|
|
||||||
# Compatibility with official postgres variable
|
# Compatibility with official postgres variable
|
||||||
# Official postgres variable gets priority
|
# Official postgres variable gets priority
|
||||||
if [ -n "${POSTGRES_PASSWORD}" ]; then
|
if [ -n "${POSTGRES_PASSWORD}" ]; then
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
SETUP_LOCKFILE="${ROOT_CONF}/.postgresql.conf.lock"
|
SETUP_LOCKFILE="${ROOT_CONF}/.postgresql.conf.lock"
|
||||||
if [ -f "${SETUP_LOCKFILE}" ]; then
|
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_timeline=${TARGET_TIMELINE}
|
||||||
recovery_target_action=${TARGET_ACTION}
|
recovery_target_action=${TARGET_ACTION}
|
||||||
promote_trigger_file = '${PROMOTE_FILE}'
|
promote_trigger_file = '${PROMOTE_FILE}'
|
||||||
shared_preload_libraries = 'pg_cron'
|
shared_preload_libraries = '${SHARED_PRELOAD_LIBRARIES}'
|
||||||
cron.database_name = '${SINGLE_DB}'
|
cron.database_name = '${SINGLE_DB}'
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
# test if DATADIR has content
|
# test if DATADIR has content
|
||||||
# Do initialization if DATADIR is empty, or RECREATE_DATADIR is true
|
# Do initialization if DATADIR is empty, or RECREATE_DATADIR is true
|
||||||
|
@ -36,7 +36,7 @@ done
|
||||||
echo "postgres ready"
|
echo "postgres ready"
|
||||||
|
|
||||||
# Setup user
|
# Setup user
|
||||||
source /setup-user.sh
|
source /scripts/setup-user.sh
|
||||||
|
|
||||||
# enable extensions in template1 if env variable set to true
|
# enable extensions in template1 if env variable set to true
|
||||||
if [[ "$(boolean ${POSTGRES_TEMPLATE_EXTENSIONS})" == TRUE ]] ; then
|
if [[ "$(boolean ${POSTGRES_TEMPLATE_EXTENSIONS})" == TRUE ]] ; then
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
SETUP_LOCKFILE="${ROOT_CONF}/.pg_hba.conf.lock"
|
SETUP_LOCKFILE="${ROOT_CONF}/.pg_hba.conf.lock"
|
||||||
if [ -f "${SETUP_LOCKFILE}" ]; then
|
if [ -f "${SETUP_LOCKFILE}" ]; then
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
# This script will setup slave instance to use standby replication
|
# This script will setup slave instance to use standby replication
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
SETUP_LOCKFILE="${ROOT_CONF}/.ssl.conf.lock"
|
SETUP_LOCKFILE="${ROOT_CONF}/.ssl.conf.lock"
|
||||||
if [ -f "${SETUP_LOCKFILE}" ]; then
|
if [ -f "${SETUP_LOCKFILE}" ]; then
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
# This script will setup new configured user
|
# This script will setup new configured user
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
chmod 600 /etc/ssl/private/ssl-cert-snakeoil.key
|
chmod 600 /etc/ssl/private/ssl-cert-snakeoil.key
|
||||||
|
|
||||||
# These tasks are run as root
|
# These tasks are run as root
|
||||||
source /env-data.sh
|
source /scripts/env-data.sh
|
||||||
|
|
||||||
|
|
||||||
# Restrict subnet to docker private network
|
# Restrict subnet to docker private network
|
Ładowanie…
Reference in New Issue