From 5a12120d1fb9f9f92e6d9a893cb930bc0aa41aa1 Mon Sep 17 00:00:00 2001 From: henry senyondo <5192965+henrykironde@users.noreply.github.com> Date: Sun, 26 Jan 2020 01:54:13 -0500 Subject: [PATCH] Add python 3 Test on Travis (#193) * Shell script clean up * Add python 3 test * Add travis Test for Python 3 --- .travis.yml | 6 +++--- Dockerfile | 4 ++-- README.md | 8 +++++--- docker-entrypoint.sh | 26 +++++++++++++------------- setup-database.sh | 4 +--- setup-replication.sh | 2 +- setup-ssl.sh | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index ab5aa77..d8ad827 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,11 +5,11 @@ language: python services: - docker -virtualenv: - system_site_packages: true - python: - '2.7' + - '3.5' + - '3.6.7' + - '3.7.1' script: - ./build.sh diff --git a/Dockerfile b/Dockerfile index 6491c8e..97b21ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,8 +49,8 @@ ADD setup-replication.sh / ADD setup-ssl.sh / ADD setup-user.sh / RUN chmod +x /docker-entrypoint.sh -RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ - && dpkg --remove --force-depends unzip +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ + && dpkg --remove --force-depends unzip ENTRYPOINT /docker-entrypoint.sh diff --git a/README.md b/README.md index 7407b71..77588d3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/kartoza/docker-postgis.svg?branch=develop)](https://travis-ci.org/kartoza/docker-postgis) + # docker-postgis @@ -95,7 +97,7 @@ user name, password and/or default database name(or multiple databases comma sep * -e POSTGRES_USER= * -e POSTGRES_PASS= * -e POSTGRES_DBNAME= -* -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. * -e SSL_CERT_FILE=/your/own/ssl_cert_file.pem @@ -247,7 +249,7 @@ Master settings: to connect into the container. This is needed to allow the `slave` to connect into `master`, so specifically this settings should allow `slave` address. It is also needed to allow clients on other hosts to connect to either the slave or the master. - **REPLICATION_USER** User to initiate streaming replication -- **REPLICATION_PASS** Password for a user with streaming replication role +- **REPLICATION_PASS** Password for a user with streaming replication role Slave settings: - **REPLICATE_FROM**: This should be the domain name or IP address of the `master` @@ -266,7 +268,7 @@ Slave settings: is not able to revert to replicant anymore, unless it is destroyed and resynced with the new master. - **REPLICATION_USER** User to initiate streaming replication -- **REPLICATION_PASS** Password for a user with streaming replication role +- **REPLICATION_PASS** Password for a user with streaming replication role To run the sample replication, follow these instructions: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index d9214f5..96bbbe8 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -21,7 +21,7 @@ source /setup-pg_hba.sh function entry_point_script { SETUP_LOCKFILE="/docker-entrypoint-initdb.d/.entry_point.lock" if [[ -f "${SETUP_LOCKFILE}" ]]; then - return 0 + return 0 else if find "/docker-entrypoint-initdb.d" -mindepth 1 -print -quit 2>/dev/null | grep -q .; then for f in /docker-entrypoint-initdb.d/*; do @@ -58,31 +58,31 @@ done } 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 - entry_point_script - kill_postgres + # This means this is a master instance. We check that database exists + echo "Setup master database" + source /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 + # This means this is a slave/replication instance. + echo "Setup slave database" + source /setup-replication.sh fi # If no arguments passed to entrypoint, then run postgres by default if [[ $# -eq 0 ]]; then - echo "Postgres initialisation process completed .... restarting in foreground" + echo "Postgres initialisation process completed .... restarting in foreground" - su - postgres -c "$SETVARS $POSTGRES -D $DATADIR -c config_file=$CONF" + su - postgres -c "$SETVARS $POSTGRES -D $DATADIR -c config_file=$CONF" fi # If arguments passed, run postgres with these arguments # This will make sure entrypoint will always be executed if [[ "${1:0:1}" = '-' ]]; then - # append postgres into the arguments - set -- postgres "$@" + # append postgres into the arguments + set -- postgres "$@" fi exec su - "$@" diff --git a/setup-database.sh b/setup-database.sh index 8543116..751c072 100644 --- a/setup-database.sh +++ b/setup-database.sh @@ -62,7 +62,7 @@ for db in $(echo ${POSTGRES_DBNAME} | tr ',' ' '); do RESULT=`su - postgres -c "psql -t -c \"SELECT count(1) from pg_database where datname='${db}';\""` if [[ ${RESULT} -eq 0 ]]; then echo "Create db ${db}" - su - postgres -c "createdb -O ${POSTGRES_USER} ${db}" + su - postgres -c "createdb -O ${POSTGRES_USER} ${db}" for ext in $(echo ${POSTGRES_MULTIPLE_EXTENSIONS} | tr ',' ' '); do echo "Enabling ${ext} in the database ${db}" su - postgres -c "psql -c 'CREATE EXTENSION IF NOT EXISTS ${ext} cascade;' $db" @@ -79,5 +79,3 @@ done rm custom.sql # This should show up in docker logs afterwards su - postgres -c "psql -l" - - diff --git a/setup-replication.sh b/setup-replication.sh index b7cf35d..cca6060 100755 --- a/setup-replication.sh +++ b/setup-replication.sh @@ -24,7 +24,7 @@ function configure_replication_permissions { echo "Setup data permissions" echo "----------------------" - chown -R postgres:postgres $(getent passwd postgres | cut -d: -f6) + chown -R postgres:postgres $(getent passwd postgres | cut -d: -f6) su - postgres -c "echo \"${REPLICATE_FROM}:${REPLICATE_PORT}:*:${REPLICATION_USER}:${REPLICATION_PASS}\" > ~/.pgpass" su - postgres -c "chmod 0600 ~/.pgpass" } diff --git a/setup-ssl.sh b/setup-ssl.sh index 9be8fed..f134e9c 100644 --- a/setup-ssl.sh +++ b/setup-ssl.sh @@ -10,7 +10,7 @@ fi # This script will setup default SSL config # /etc/ssl/private can't be accessed from within container for some reason -# (@andrewgodwin says it's something AUFS related) - taken from https://github.com/orchardup/docker-postgresql/blob/master/Dockerfile +# (@andrewgodwin says it's something AUFS related) - taken from https://github.com/orchardup/docker-postgresql/blob/master/Dockerfile cp -r /etc/ssl /tmp/ssl-copy/ chmod -R 0700 /etc/ssl chown -R postgres /tmp/ssl-copy