diff --git a/Dev_Diplodocus/Dockerfile b/Dev_Diplodocus/Dockerfile index 495c8ee..8d7cf86 100644 --- a/Dev_Diplodocus/Dockerfile +++ b/Dev_Diplodocus/Dockerfile @@ -3,11 +3,11 @@ FROM ubuntu:18.04 WORKDIR /usr/local # Environment -ENV PG_VERSION 12.0 +ENV PG_VERSION 12.2 ENV GEOS_VERSION 3.8.0 -ENV PROJ4_VERSION 6.2.0 -ENV POSTGIS_VERSION 3.0.0 -ENV GOSU_VERSION 1.9 +ENV PROJ_VERSION 6.3.1 +ENV POSTGIS_VERSION 3.0.1 +ENV GOSU_VERSION 1.11 ENV ENCODING UTF-8 ENV LOCALE en_US ENV TERM xterm diff --git a/Dev_Diplodocus/README.md b/Dev_Diplodocus/README.md index 8d82faa..ebfd421 100644 --- a/Dev_Diplodocus/README.md +++ b/Dev_Diplodocus/README.md @@ -1,4 +1,4 @@ -# PostgreSQL 12.0 PostGIS 3.0.0 GEOS 3.8.0, PROJ 6.2 +# PostgreSQL 12.2 PostGIS 3.0.1 GEOS 3.8.0, PROJ 6.3.1 This image uses the development versions of PostgreSQL and PostGIS. @@ -59,13 +59,13 @@ Containers can be configured by means of setting environmental variables: This Dockerfile compiles the following software: -- __PostgreSQL 12.0__ +- __PostgreSQL 12.2__ - __GEOS 3.8.0__ -- __Proj 6.2.0__ +- __Proj 6.3.1__ -- __PostGIS 3.0.0__ +- __PostGIS 3.0.1__ ## Scripts diff --git a/Dev_Diplodocus/packages/compile.sh b/Dev_Diplodocus/packages/compile.sh index eda2c3b..8024409 100755 --- a/Dev_Diplodocus/packages/compile.sh +++ b/Dev_Diplodocus/packages/compile.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Compilation of PostgreSQL, GEOS, Proj4, and PostGIS +# Compilation of PostgreSQL, GEOS, Proj, and PostGIS set -exu exec_dir=$PWD @@ -65,7 +65,7 @@ apt-get update \ # Download & untar sources curl --progress-bar https://ftp.postgresql.org/pub/source/v${PG_VERSION}/postgresql-${PG_VERSION}.tar.bz2 | tar xj -C /usr/local/src/ curl --progress-bar http://download.osgeo.org/geos/geos-${GEOS_VERSION}.tar.bz2 | tar xj -C /usr/local/src/ -curl --progress-bar http://download.osgeo.org/proj/proj-${PROJ4_VERSION}.tar.gz | tar xz -C /usr/local/src/ +curl --progress-bar http://download.osgeo.org/proj/proj-${PROJ_VERSION}.tar.gz | tar xz -C /usr/local/src/ curl --progress-bar http://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz | tar xz -C /usr/local/src/ @@ -106,8 +106,8 @@ cd src/geos-${GEOS_VERSION} cd ../.. ldconfig -# Compilation of Proj4 -cd src/proj-${PROJ4_VERSION} +# Compilation of Proj +cd src/proj-${PROJ_VERSION} ./configure make -j "$(nproc)" make install diff --git a/Dev_Diplodocus_raster/Dockerfile b/Dev_Diplodocus_raster/Dockerfile new file mode 100644 index 0000000..9d64b18 --- /dev/null +++ b/Dev_Diplodocus_raster/Dockerfile @@ -0,0 +1,46 @@ +FROM osgeo/gdal:ubuntu-small-3.0.4 + +WORKDIR /usr/local + +# Environment +ENV PG_VERSION 12.2 +ENV GEOS_VERSION 3.8.0 +ENV PROJ_VERSION 6.3.1 +ENV POSTGIS_VERSION 3.0.1 +ENV GOSU_VERSION 1.11 +ENV ENCODING UTF-8 +ENV LOCALE en_US +ENV TERM xterm +ENV POSTGRES_PASSWD postgres +ENV PG_HBA "local all all trust#host all all 127.0.0.1/32 trust#host all all 0.0.0.0/0 md5#host all all ::1/128 trust" +ENV PG_CONF "max_connections=100#listen_addresses='*'#shared_buffers=128MB#dynamic_shared_memory_type=posix#log_timezone='UTC'#datestyle='iso, mdy'#timezone='UTC'#log_statement='all'#log_directory='pg_log'#log_filename='postgresql-%Y-%m-%d_%H%M%S.log'#logging_collector=on#client_min_messages=notice#log_min_messages=notice#log_line_prefix='%a %u %d %r %h %m %i %e'#log_destination='stderr'#log_rotation_size=500MB#log_error_verbosity=default" +ENV PGDATA /data + +# Creation of postgres user and group +RUN \ + set -ex; \ + useradd --shell /bin/bash --home /data/ postgres \ + && mkdir -p "$PGDATA" \ + && chown -R postgres:postgres "$PGDATA" \ + && chmod 777 "$PGDATA" + +# Load assets +ADD packages/pg_hba_conf /usr/local/bin +ADD packages/postgresql_conf /usr/local/bin +ADD packages/psqlrc /root/.psqlrc +ADD packages/compile.sh /usr/local/src/ + +# Compilation +RUN src/compile.sh + +VOLUME /data + +RUN chmod +x /usr/local/bin/pg_hba_conf +RUN chmod +x /usr/local/bin/postgresql_conf + +STOPSIGNAL SIGINT +COPY packages/run.sh /usr/local/bin/ +ENTRYPOINT ["/usr/local/bin/run.sh"] + +EXPOSE 5432 +CMD ["run_default"] diff --git a/Dev_Diplodocus_raster/README.md b/Dev_Diplodocus_raster/README.md new file mode 100644 index 0000000..15c16a8 --- /dev/null +++ b/Dev_Diplodocus_raster/README.md @@ -0,0 +1,220 @@ +# PostgreSQL 12.2 PostGIS 3.0.1 GEOS 3.8.0, PROJ 6.3.1 GDAL 3.0.4 + +This image uses the development versions of PostgreSQL and PostGIS (with raster support). + +# Contents +- [How to use](#how-to-use) +- [Versions](#versions) +- [Scripts](#scripts) +- [Executing Arbitrary Commands](#executing-arbitrary-commands) +- [Data Persistence](#data-persistence) +- [Passwords](#passwords) +- [Configuring the Data Store](#configuring-the-data-store) +- [Killing the Container](#killing-the-container) + +## How to use + +### Using Docker compose +docker-compose.yml: +```yml +version: "3" +services: + postgis: + image: geographica/postgis:dev_diplodocus_raster + ports: + - "5432:5432" + volumes: + - db-data:/data + environment: + - POSTGRES_PASSWD=postgres +volumes: + db-data: +``` +Run: +```bash +docker-compose up +``` + +### Without compose +``` +docker run --name postgis -p 5432:5432 geographica/postgis:dev_diplodocus_raster +``` + +### Environment variables +This will create a container with a default volume, __/data__, for storing the data store. The default encoding will be __UTF-8__, and the locale __en_US__. No additional modification or action is taken. + +Containers can be configured by means of setting environmental variables: + +- __POSTGRES_PASSWD:__ set the password for user postgres. See [Passwords](#Passwords) for more details. Defaults to _postgres_; + +- __ENCODING:__ encoding to create the data store and the default database, if applicable. Defaults to _UTF-8_; + +- __LOCALE:__ locale for the data store and the default database, if any. Defaults to _en_US_; + +- __PG_HBA:__ configuration of _pg_hba.con_ access file. See [Configuring the Data Store](#Configuring the Data Store) for details; + +- __PG_CONF:__ configuration of _postgresql.conf_ See [Configuring the Data Store](#Configuring the Data Store) for details. + +## Versions + +This Dockerfile compiles the following software: + +- __PostgreSQL 12.2__ + +- __GEOS 3.8.0__ + +- __Proj 6.3.1__ + +- __PostGIS 3.0.1__ + +- __GDAL 3.0.4__ + + +## Scripts + +There is a script in this repo to help working with this image. __psql-docker__ opens a psql console on a standalone container to connect to other databases. To check how it works: + +```Shell +psql-docker -h +``` + +## Executing Arbitrary Commands + +The image can run arbitrary commands. This is useful for example for creating a temporary container for just dump a database, run a psql session with the one inside this image, or executing scripts into another container. + +Some examples: + +```Shell +# Interactive pg_dump, will ask for password + +docker run --rm -ti -v /whatever/:/d --link the_container_running_the_database:pg \ +geographica/postgis:dev_diplodocus_raster \ +pg_dump -b -E UTF8 -f /d/dump -F c -v -Z 9 -h pg -p 5432 -U postgres project + +# Full automatic pg_dump, with password as ENV variable + +docker run --rm -v /home/malkab/Desktop/:/d --link test_07:pg \ +geographica/postgis:dev_diplodocus_raster \ +PGPASSWORD="new_password_here" pg_dump -b -E UTF8 -f /d/dump33 -F c \ +-v -Z 9 -h pg -p 5432 -U postgres postgres + +# Interactive psql + +docker run --rm -ti -v /home/malkab/Desktop/:/d --link test_07:pg \ geographica/postgis:dev_diplodocus_raster \ PGPASSWORD="new_password_here" psql -h pg -p 5432 -U postgres postgres +``` + +## Data Persistence + +Datastore data can be persisted in a data volume or host mounted folder and be used later by another container. The container checks if __/data/__ is empty or not. If not, considers the datastore to be not created and creates an empty one. + + +## Passwords + +Passwords sent to the container with environment variable __POSTGRES_PASSWD__ can be passed either on plain text or already encrypted รก la PostgreSQL. To pass it on plain text means that anybody with access to the __docker inspect__ command on the server will be able to read passwords. Encrypting them previously means that __docker inspect__ will show the encrypted password, adding an additional layer of secrecy. + +PostgreSQL passwords are encrypted using the MD5 checksum algorithm on the following literal: + +```text +md5 + md5hash(real password + username) +``` + +For example, in the case of user _myself_ and password _secret_, the encrypted password will be the MD5 sum of _secretmyself_ prefixed with _md5_, in this case, _md5a296d28d6121e7307ac8e72635ae206b_. + +To provide encrypted password to containers, use the following command: + +```Shell +export USER="projectuser" && \ +export USERPASSWD="md5"$(printf '%s' "userpass" ${USER} | md5sum | cut -d ' ' -f 1) && \ +export PGPASSWD="md5"$(printf '%s' "password_here" "postgres" | md5sum | cut -d ' ' -f 1) && \ +docker run -d -P --name ageworkshoptestpg -e "POSTGRES_PASSWD=${PGPASSWD}" \ +-e "CREATE_USER=${USER}" -e "CREATE_USER_PASSWD=${USERPASSWD}" \ +geographica/postgis:dev_diplodocus_raster +``` + +Ugly, but effective. Keep in mind, however, that if you use provisioning methods like bash scripts or _Docker Compose_ others will still be able to read passwords from these sources, so keep them safe. + + +## Configuring the Data Store + +The image allows for configuration of _pg_hba.conf_ and _postgresql.conf_ data store files at creation time and later. This is advanced stuff, refer to the PostgreSQL documentation for details. + +_pg_hba.conf_ configuration is handled by a script called __pg_hba_conf__. _pg_hba_conf_ has three modes of operation: + +```Shell +[1] pg_hba_conf l + +[2] pg_hba_conf a "line 1#line 2#...#line n" + +[3] pg_hba_conf d "line 1#line 2#...#line n" +``` + +which means: + +- __[1]__ prints current contents of _pg_hba.conf_; + +- __[2]__ adds lines to _pg_hba.conf_; + +- __[3]__ deletes lines from _pg_hba.conf_. + +This commands can be issued by standard Docker's __exec__: + +```Shell +docker exec -ti whatevercontainer pg_hba_conf a \ +"host all all 23.123.22.1/32 trust#host all all 93.32.12.3/32 md5" +``` + +but at startup it is controlled by an environment variable, __PG_HBA__, which defaults to: + +```txt +ENV PG_HBA "local all all trust#host all all 127.0.0.1/32 trust#host all all 0.0.0.0/0 md5#host all all ::1/128 trust" +``` + +This defaults should be submitted for basic operation. For universal access, for example for testing, add: + +```txt +local all all trust#host all all 0.0.0.0/0 trust#host all all 127.0.0.1/32 trust#host all all ::1/128 trust +``` + +Modify this variable to configure at creation time. Keep in mind, however, that any value provided to this variable will supersede the default. Don't forget to include basic access permissions if you modify this variable, or the server will be hardly reachable. For testing purposes, direct commands can be issued via __exec__. + +Configuration of __postgresql.conf__ follows an identical procedure. Command is __postgresql_conf__ and has the same syntax as __pg_hba_conf__. The environmental variable is __PG_CONF__, which defaults to the following configuration: + +```txt +max_connections=100#listen_addresses='*'#shared_buffers=128MB#dynamic_shared_memory_type=posix#log_timezone='UTC'#datestyle='iso, mdy'#timezone='UTC'#lc_messages='en_US.UTF-8'#lc_monetary='en_US.UTF-8'#lc_numeric='en_US.UTF-8'#lc_time='en_US.UTF-8'#log_statement='all'#log_directory='pg_log'#log_filename='postgresql-%Y-%m-%d_%H%M%S.log'#logging_collector=on#client_min_messages=notice#log_min_messages=notice#log_line_prefix='%a %u %d %r %h %m %i %e'#log_destination='stderr,csvlog'#log_rotation_size=500MB +``` + +At creation time, language, encoding, and locale info is added based on env variables __LOCALE__ and __ENCODING__. + +Logs are stored at __$POSTGRES_DATA_FOLDER/pg_log__. + + + + +## Killing the Container + + +This container will handle signals send to it with _docker kill_ properly, so the database is shut down tidily. Thus: + +- __SIGTERM__ signals for a smart shutdown, waiting for all connections and transactions to be finished. The server won't allow for new connections, thou: + +```Shell +pg_ctl -D . stop -m smart + +docker kill -s SIGTERM containername +``` + +- __SIGINT__ signals for fast shutdown. The server will abort current transactions and disconnect users, but will exit nicely otherwise; + +```Shell +pg_ctl -D . stop -m fast + +docker kill -s SIGINT containername +``` + +- __SIGQUIT__ signals for immediate shutdown. This will leave the database in a improper state and lead to recovery on next startup: + +```Shell +pg_ctl -D . stop -m immediate + +docker kill -s SIGQUIT containername +``` diff --git a/Dev_Diplodocus_raster/build.sh b/Dev_Diplodocus_raster/build.sh new file mode 100644 index 0000000..611846e --- /dev/null +++ b/Dev_Diplodocus_raster/build.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -ex + +docker build \ + --pull \ + -t geographica/postgis:dev_diplodocus_raster \ + . diff --git a/Dev_Diplodocus_raster/docker-compose.yml b/Dev_Diplodocus_raster/docker-compose.yml new file mode 100644 index 0000000..640357b --- /dev/null +++ b/Dev_Diplodocus_raster/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" +services: + postgis: + image: geographica/postgis:dev_diplodocus_raster + ports: + - "5432:5432" + volumes: + - db-data:/data + environment: + - POSTGRES_PASSWD=postgres +volumes: + db-data: diff --git a/Dev_Diplodocus_raster/packages/compile.sh b/Dev_Diplodocus_raster/packages/compile.sh new file mode 100755 index 0000000..c677198 --- /dev/null +++ b/Dev_Diplodocus_raster/packages/compile.sh @@ -0,0 +1,144 @@ +#!/bin/bash +# Compilation of PostgreSQL, GEOS, Proj, and PostGIS +set -exu + +exec_dir=$PWD + +current_os=$(set +x; . /etc/os-release; echo ${ID}) +current_os_version=$(set +x; . /etc/os-release; echo ${VERSION_ID}) + +if [ "$current_os" = "ubuntu" ]; then + BUILD_DEPENDENCIES="$( set +x; echo \ + `# Required !` \ + build-essential \ + python \ + python-dev \ + curl \ + ca-certificates \ + gnupg \ + locales \ + pkg-config \ + libreadline-dev \ + zlib1g-dev \ + libssl-dev \ + libxml2-dev \ + libxslt1-dev \ + libjson-c-dev \ + libprotobuf-c-dev \ + libprotoc-dev \ + protobuf-compiler \ + protobuf-c-compiler \ + libsqlite3-dev\ + sqlite3 \ + llvm-dev \ + clang \ + )" + RUN_DEPENDENCIES="$( set +x; echo \ + `# Required !` \ + python \ + locales \ + libreadline7 \ + zlib1g \ + libssl1.0.0 \ + libxml2 \ + libxslt1.1 \ + libjson-c3 \ + libprotobuf-c1 \ + libprotoc10 \ + sqlite3 \ + llvm \ + )" +elif [ "$current_os" = "debian" ]; then + echo "here!" +else + echo "Operating System `$curren_os` not supported" + exit 1 +fi + +# Update and apt-get basic packages +apt-get update \ + && apt-get install \ + -y \ + --no-install-recommends \ + $BUILD_DEPENDENCIES + +# Download & untar sources +curl --progress-bar https://ftp.postgresql.org/pub/source/v${PG_VERSION}/postgresql-${PG_VERSION}.tar.bz2 | tar xj -C /usr/local/src/ +curl --progress-bar http://download.osgeo.org/geos/geos-${GEOS_VERSION}.tar.bz2 | tar xj -C /usr/local/src/ +curl --progress-bar http://download.osgeo.org/proj/proj-${PROJ_VERSION}.tar.gz | tar xz -C /usr/local/src/ +curl --progress-bar http://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz | tar xz -C /usr/local/src/ + + +# Grab gosu +for server in ha.pool.sks-keyservers.net \ + hkp://p80.pool.sks-keyservers.net:80 \ + keyserver.ubuntu.com \ + hkp://keyserver.ubuntu.com:80 \ + pgp.mit.edu; do + gpg --keyserver "$server" --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && break || echo "Trying new server..." +done + +curl -o /usr/local/bin/gosu \ + -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" > \ + /dev/null 2>&1 \ + && curl -o /usr/local/bin/gosu.asc \ + -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture).asc" > \ + /dev/null 2>&1 \ + && gpg --verify /usr/local/bin/gosu.asc > /dev/null 2>&1 \ + && rm /usr/local/bin/gosu.asc > /dev/null 2>&1 \ + && chmod +x /usr/local/bin/gosu > /dev/null 2>&1 + +# Compilation of PostgreSQL +cd src/postgresql-${PG_VERSION} + ./configure --prefix=/usr/local --with-pgport=5432 --with-python --with-openssl --with-libxml --with-libxslt --with-zlib --with-llvm + make -j "$(nproc)" + make install + make all + make install +cd ../.. +ldconfig + +# Compilation of GEOS +cd src/geos-${GEOS_VERSION} + ./configure + make -j "$(nproc)" + make install +cd ../.. +ldconfig + +# Compilation of Proj +cd src/proj-${PROJ_VERSION} + ./configure + make -j "$(nproc)" + make install +cd ../.. +ldconfig + +# Compilation of PostGIS +cd src/postgis-${POSTGIS_VERSION} + ./configure --with-topology --with-jsondir=/usr + make -j "$(nproc)" + make install +cd ../.. +ldconfig + +# Clean up +rm -rf /usr/local/src \ + /usr/local/share/doc* \ + /usr/local/share/man +apt-get remove \ + -y \ + --purge \ + --auto-remove \ + $BUILD_DEPENDENCIES + +## Clean "a" files (Not required after compilation) +find /usr/local/lib/ -name '*.a' -delete + +# Install run dependencies +apt-get install \ + -y \ + --no-install-recommends \ + $RUN_DEPENDENCIES + +rm -rf /var/lib/apt/lists/* diff --git a/Dev_Diplodocus_raster/packages/pg_hba_conf b/Dev_Diplodocus_raster/packages/pg_hba_conf new file mode 100644 index 0000000..d8f093c --- /dev/null +++ b/Dev_Diplodocus_raster/packages/pg_hba_conf @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# coding=UTF-8 + +import sys, os + +pgHome = "/data/" + +def error(): + print "Usage:" + print "l: show pg_hba.conf content" + print "a: adds hash-separated lines to pg_hba.conf, for example pg_hba_conf a \"host all all 127.0.0.1/32 trust#host all all 182.3.2.1/32 md5\"" + print "d: deletes hash-separated lines from pg_hba.conf, for example pg_hba_conf d \"host all all 127.0.0.1/32 trust#host all all 182.3.2.1/32 md5\"" + sys.exit(1) + + +# Check if no argument is submitted +if len(sys.argv)==1: + error() + + +# List command +if sys.argv[1]=="l": + try: + f = open("%s/pg_hba.conf" % pgHome, "r") + print f.read() + f.close() + except: + error() + + sys.exit(0) + + +# Add command +if sys.argv[1]=="a": + try: + entries = sys.argv[2].split("#") + f = open("%s/pg_hba.conf" % pgHome, "a") + + for i in entries: + f.write("%s\n" % i) + + f.close() + except: + error() + + sys.exit(0) + + +# Delete command +if sys.argv[1]=="d": + try: + entries = sys.argv[2].split("#") + f = open("%s/pg_hba.conf" % pgHome, "r") + lines = [] + + for line in f: + if line.rstrip("\n") not in entries: + lines.append(line) + + f.close() + f = open("%s/pg_hba.conf" % pgHome, "w") + + for line in lines: + f.write("%s" % line) + + f.close() + except: + error() + + sys.exit(0) diff --git a/Dev_Diplodocus_raster/packages/postgresql_conf b/Dev_Diplodocus_raster/packages/postgresql_conf new file mode 100644 index 0000000..5abaa24 --- /dev/null +++ b/Dev_Diplodocus_raster/packages/postgresql_conf @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# coding=UTF-8 + +import sys, os + +pgHome = "/data/" + +def error(): + print "Usage:" + print "l: show postgresql.conf content" + print "a: adds hash-separated lines to postgresql.conf, for example postgresql_conf a \"listen_addresses='*'#shared_buffers=128MB\"" + print "d: deletes hash-separated lines from pg_hba.conf, for example postgresql_conf d \"listen_addresses='*'#shared_buffers=128MB\"" + sys.exit(1) + + +# Check if no argument is submitted +if len(sys.argv)==1: + error() + + +# List command +if sys.argv[1]=="l": + try: + f = open("%s/postgresql.conf" % pgHome, "r") + print f.read() + f.close() + except: + error() + + sys.exit(0) + + +# Add command +if sys.argv[1]=="a": + try: + entries = sys.argv[2].split("#") + f = open("%s/postgresql.conf" % pgHome, "a") + + for i in entries: + f.write("%s\n" % i) + + f.close() + except: + error() + + sys.exit(0) + + +# Delete command +if sys.argv[1]=="d": + try: + entries = sys.argv[2].split("#") + f = open("%s/postgresql.conf" % pgHome, "r") + lines = [] + + for line in f: + if line.rstrip("\n") not in entries: + lines.append(line) + + f.close() + f = open("%s/postgresql.conf" % pgHome, "w") + + for line in lines: + f.write("%s" % line) + + f.close() + except: + error() + + sys.exit(0) diff --git a/Dev_Diplodocus_raster/packages/psqlrc b/Dev_Diplodocus_raster/packages/psqlrc new file mode 100644 index 0000000..2792b2c --- /dev/null +++ b/Dev_Diplodocus_raster/packages/psqlrc @@ -0,0 +1,9 @@ +\set QUIET 1 +\set PROMPT1 '%n@%M %~>' +\pset null '[NULL]' +\set VERBOSITY terse +\set HISTFILE ~/psql_history- :DBNAME +\set HISTCONTROL ignoredups +\timing +\x auto +\unset QUIET diff --git a/Dev_Diplodocus_raster/packages/run.sh b/Dev_Diplodocus_raster/packages/run.sh new file mode 100644 index 0000000..152427c --- /dev/null +++ b/Dev_Diplodocus_raster/packages/run.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +set -e + +log(){ + echo "$(date +"%Y-%m-%d %T") > $1" >> /log.txt +} + +# Generate locale +LANG=${LOCALE}.${ENCODING} + +locale-gen ${LANG} > /dev/null + +log "Locale ${LOCALE}.${ENCODING} generated" + + + +# Check if command is just "run_default" + +if [ "$1" = 'run_default' ]; then + log "Running server" + + # Check if data folder is empty. If it is, configure the dataserver + if [ -z "$(ls -A "/data/")" ]; then + log "Initializing datastore..." + + chown postgres:postgres /data + # Create datastore + su postgres -c "initdb --encoding=${ENCODING} --locale=${LANG} --lc-collate=${LANG} --lc-monetary=${LANG} --lc-numeric=${LANG} --lc-time=${LANG} -D /data/" + + log "Datastore created..." + + # Create log folder + mkdir -p /data/logs + chown postgres:postgres /data/logs + + log "Log folder created..." + + # Erase default configuration and initialize it + su postgres -c "rm /data/pg_hba.conf" + su postgres -c "pg_hba_conf a \"${PG_HBA}\"" + + # Modify basic configuration + su postgres -c "rm /data/postgresql.conf" + PG_CONF="${PG_CONF}#lc_messages='${LANG}'#lc_monetary='${LANG}'#lc_numeric='${LANG}'#lc_time='${LANG}'" + su postgres -c "postgresql_conf a \"${PG_CONF}\"" + + # Establish postgres user password and run the database + su postgres -c "pg_ctl -w -D /data/ start" + su postgres -c "psql -h localhost -U postgres -p 5432 -c \"alter role postgres password '${POSTGRES_PASSWD}';\"" + + log "Configurating and adding postgres user to the database..." + + log "Stopping the server..." + + # Stop the server + su postgres -c "pg_ctl -w -D /data/ stop" + else + log "Datastore already exists..." + fi + + # Fix permissions + chown postgres:postgres /data + chown postgres:postgres /data/logs + + log "Starting the server..." + + # Start the database + exec gosu postgres postgres -D /data/ +else + exec env "$@" +fi diff --git a/README.md b/README.md index 36fa055..4d590da 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,15 @@ The philosophy behind Git / Docker tags correlation we ended up using is simple: Please refer to each tag README.md for full details. To get a quick overview over tags capabilities: -- [__Dev_Diplodocus__](Dev_Diplodocus) released 2019-10-15. PostgreSQL 12.0 PostGIS 3.0.0 GEOS 3.8.0, PROJ 6.2. Development version. +- [__Dev_Diplodocus__](Dev_Diplodocus) released 2020-03-05. PostgreSQL 12.2 PostGIS 3.0.1, GEOS 3.8.0, PROJ 6.3.1. Development version. -- [__Tasty_Termite:__](Tasty_Termite) released 2019-03-26. PostgreSQL 11.2, PostGIS 2.5.2, GEOS 3.7.1, PROJ4 6.0, GDAL 2.4.1. Bleeding edge. +- [__Dev_Diplodocus_raster__](Dev_Diplodocus_raster) released 2020-03-05. PostgreSQL 12.2 PostGIS 3.0.1, GEOS 3.8.0, PROJ 6.3.1, GDAL 3.0.4. Development version with raster. -- [__Spry_Sparrow:__](Spry_Sparrow) released 2018-29-10. PostgreSQL 11.0, PostGIS 2.5, GEOS 3.7, PROJ4 5.2, GDAL 2.3.2. +- [__Tasty_Termite:__](Tasty_Termite) released 2019-03-26. PostgreSQL 11.2, PostGIS 2.5.2, GEOS 3.7.1, PROJ 6.0, GDAL 2.4.1. Bleeding edge. -- [__Rapid_Reedbuck:__](Rapid_Reedbuck) released 2018-09-15. PostgreSQL 10.5, PostGIS 2.4.5, GEOS 3.7.0, PROJ4 5.1.0, GDAL 2.3.1. +- [__Spry_Sparrow:__](Spry_Sparrow) released 2018-29-10. PostgreSQL 11.0, PostGIS 2.5, GEOS 3.7, PROJ 5.2, GDAL 2.3.2. + +- [__Rapid_Reedbuck:__](Rapid_Reedbuck) released 2018-09-15. PostgreSQL 10.5, PostGIS 2.4.5, GEOS 3.7.0, PROJ 5.1.0, GDAL 2.3.1. - [__Quick_Quail:__](Quick_Quail) released 2018-04-16. PostgreSQL 10.3, PostGIS 2.4.4, GEOS 3.6.2, GDAL 2.2.4, patched. diff --git a/Rapid_Reedbuck/Dockerfile b/Rapid_Reedbuck/Dockerfile index 7f1411b..42dbae6 100644 --- a/Rapid_Reedbuck/Dockerfile +++ b/Rapid_Reedbuck/Dockerfile @@ -4,7 +4,7 @@ FROM ubuntu:latest # Environment ENV PG_VERSION 10.5 ENV GEOS_VERSION 3.7.0 -ENV PROJ4_VERSION 5.1.0 +ENV PROJ_VERSION 5.1.0 ENV GDAL_VERSION 2.3.1 ENV POSTGIS_VERSION 2.4.5 ENV GOSU_VERSION 1.9 @@ -25,7 +25,7 @@ ADD packages/postgresql_conf /usr/local/bin ADD packages/psqlrc /root/.psqlrc ADD https://ftp.postgresql.org/pub/source/v${PG_VERSION}/postgresql-${PG_VERSION}.tar.bz2 /usr/local/src/ ADD http://download.osgeo.org/geos/geos-${GEOS_VERSION}.tar.bz2 /usr/local/src/ -ADD http://download.osgeo.org/proj/proj-${PROJ4_VERSION}.tar.gz /usr/local/src/ +ADD http://download.osgeo.org/proj/proj-${PROJ_VERSION}.tar.gz /usr/local/src/ ADD http://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz /usr/local/src/ ADD http://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz /usr/local/src/ diff --git a/Rapid_Reedbuck/README.md b/Rapid_Reedbuck/README.md index 02e0adf..bfc0ec8 100644 --- a/Rapid_Reedbuck/README.md +++ b/Rapid_Reedbuck/README.md @@ -1,4 +1,4 @@ -# PostgreSQL 10.5 PostGIS 2.4.5, GEOS 3.7, GDAL 2.3.1, PROJ4 5.1.0 +# PostgreSQL 10.5 PostGIS 2.4.5, GEOS 3.7, GDAL 2.3.1, PROJ 5.1.0 # Contents - [How to use](#how-to-use) diff --git a/Rapid_Reedbuck/packages/compile.sh b/Rapid_Reedbuck/packages/compile.sh index 05be8f4..7d44d6e 100644 --- a/Rapid_Reedbuck/packages/compile.sh +++ b/Rapid_Reedbuck/packages/compile.sh @@ -1,4 +1,4 @@ -# Compilation of PostgreSQL, GEOS, Proj4, GDAL, and PostGIS 2 +# Compilation of PostgreSQL, GEOS, Proj, GDAL, and PostGIS 2 # Update and apt-get basic packages @@ -39,7 +39,7 @@ curl -o /usr/local/bin/gosu \ # Untar cd src ; tar -xjvf postgresql-${PG_VERSION}.tar.bz2 ; cd .. cd src ; tar -xjvf geos-${GEOS_VERSION}.tar.bz2 ; cd .. -cd src ; tar -xvf proj-${PROJ4_VERSION}.tar.gz ; cd .. +cd src ; tar -xvf proj-${PROJ_VERSION}.tar.gz ; cd .. cd src ; tar -xvf gdal-${GDAL_VERSION}.tar.gz ; cd .. cd src ; tar -xvf postgis-${POSTGIS_VERSION}.tar.gz ; cd .. @@ -71,12 +71,12 @@ cd src/geos-${GEOS_VERSION} ; make install ; cd ../.. ldconfig -# Compilation of Proj 4 -cd src/proj-${PROJ4_VERSION} ; ./configure ; cd ../.. +# Compilation of Proj +cd src/proj-${PROJ_VERSION} ; ./configure ; cd ../.. -cd src/proj-${PROJ4_VERSION} ; make ; cd ../.. +cd src/proj-${PROJ_VERSION} ; make ; cd ../.. -cd src/proj-${PROJ4_VERSION} ; make install ; cd ../.. +cd src/proj-${PROJ_VERSION} ; make install ; cd ../.. ldconfig diff --git a/Spry_Sparrow/Dockerfile b/Spry_Sparrow/Dockerfile index bbaa22f..a9d1e47 100644 --- a/Spry_Sparrow/Dockerfile +++ b/Spry_Sparrow/Dockerfile @@ -4,7 +4,7 @@ FROM ubuntu:latest # Environment ENV PG_VERSION 11.0 ENV GEOS_VERSION 3.7.0 -ENV PROJ4_VERSION 5.2.0 +ENV PROJ_VERSION 5.2.0 ENV GDAL_VERSION 2.3.2 ENV POSTGIS_VERSION 2.5.0 ENV GOSU_VERSION 1.9 @@ -25,7 +25,7 @@ ADD packages/postgresql_conf /usr/local/bin ADD packages/psqlrc /root/.psqlrc ADD https://ftp.postgresql.org/pub/source/v${PG_VERSION}/postgresql-${PG_VERSION}.tar.bz2 /usr/local/src/ ADD http://download.osgeo.org/geos/geos-${GEOS_VERSION}.tar.bz2 /usr/local/src/ -ADD http://download.osgeo.org/proj/proj-${PROJ4_VERSION}.tar.gz /usr/local/src/ +ADD http://download.osgeo.org/proj/proj-${PROJ_VERSION}.tar.gz /usr/local/src/ ADD http://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz /usr/local/src/ ADD http://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz /usr/local/src/ diff --git a/Spry_Sparrow/README.md b/Spry_Sparrow/README.md index 2afc4f6..313309c 100644 --- a/Spry_Sparrow/README.md +++ b/Spry_Sparrow/README.md @@ -1,4 +1,4 @@ -# PostgreSQL 11.0 PostGIS 2.5.0 GEOS 3.7, GDAL 2.3.2, PROJ4 5.2.0 +# PostgreSQL 11.0 PostGIS 2.5.0 GEOS 3.7, GDAL 2.3.2, PROJ 5.2.0 # Contents - [How to use](#how-to-use) diff --git a/Spry_Sparrow/packages/compile.sh b/Spry_Sparrow/packages/compile.sh index bd122d6..10ab574 100644 --- a/Spry_Sparrow/packages/compile.sh +++ b/Spry_Sparrow/packages/compile.sh @@ -1,4 +1,4 @@ -# Compilation of PostgreSQL, GEOS, Proj4, GDAL, and PostGIS 2 +# Compilation of PostgreSQL, GEOS, Proj, GDAL, and PostGIS 2 # Update and apt-get basic packages @@ -39,7 +39,7 @@ curl -o /usr/local/bin/gosu \ # Untar cd src ; tar -xjvf postgresql-${PG_VERSION}.tar.bz2 ; cd .. cd src ; tar -xjvf geos-${GEOS_VERSION}.tar.bz2 ; cd .. -cd src ; tar -xvf proj-${PROJ4_VERSION}.tar.gz ; cd .. +cd src ; tar -xvf proj-${PROJ_VERSION}.tar.gz ; cd .. cd src ; tar -xvf gdal-${GDAL_VERSION}.tar.gz ; cd .. cd src ; tar -xvf postgis-${POSTGIS_VERSION}.tar.gz ; cd .. @@ -71,12 +71,12 @@ cd src/geos-${GEOS_VERSION} ; make install ; cd ../.. ldconfig -# Compilation of Proj 4 -cd src/proj-${PROJ4_VERSION} ; ./configure ; cd ../.. +# Compilation of Proj +cd src/proj-${PROJ_VERSION} ; ./configure ; cd ../.. -cd src/proj-${PROJ4_VERSION} ; make ; cd ../.. +cd src/proj-${PROJ_VERSION} ; make ; cd ../.. -cd src/proj-${PROJ4_VERSION} ; make install ; cd ../.. +cd src/proj-${PROJ_VERSION} ; make install ; cd ../.. ldconfig diff --git a/Tasty_Termite/Dockerfile b/Tasty_Termite/Dockerfile index 21e3693..f851e1e 100644 --- a/Tasty_Termite/Dockerfile +++ b/Tasty_Termite/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /usr/local # Environment ENV PG_VERSION 11.2 ENV GEOS_VERSION 3.7.1 -ENV PROJ4_VERSION 6.0.0 +ENV PROJ_VERSION 6.0.0 ENV GDAL_VERSION 2.4.1 ENV POSTGIS_VERSION 2.5.2 ENV GOSU_VERSION 1.9 diff --git a/Tasty_Termite/packages/compile.sh b/Tasty_Termite/packages/compile.sh index d32cd0c..be6fae8 100755 --- a/Tasty_Termite/packages/compile.sh +++ b/Tasty_Termite/packages/compile.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Compilation of PostgreSQL, GEOS, Proj4, GDAL, and PostGIS 2 +# Compilation of PostgreSQL, GEOS, Proj, GDAL, and PostGIS 2 set -exu exec_dir=$PWD @@ -62,7 +62,7 @@ apt-get update \ # Download & untar sources curl --progress-bar https://ftp.postgresql.org/pub/source/v${PG_VERSION}/postgresql-${PG_VERSION}.tar.bz2 | tar xj -C /usr/local/src/ curl --progress-bar http://download.osgeo.org/geos/geos-${GEOS_VERSION}.tar.bz2 | tar xj -C /usr/local/src/ -curl --progress-bar http://download.osgeo.org/proj/proj-${PROJ4_VERSION}.tar.gz | tar xz -C /usr/local/src/ +curl --progress-bar http://download.osgeo.org/proj/proj-${PROJ_VERSION}.tar.gz | tar xz -C /usr/local/src/ curl --progress-bar http://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz | tar xz -C /usr/local/src/ curl --progress-bar http://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz | tar xz -C /usr/local/src/ @@ -98,8 +98,8 @@ cd src/geos-${GEOS_VERSION} cd ../.. ldconfig -# Compilation of Proj 4 -cd src/proj-${PROJ4_VERSION} +# Compilation of Proj +cd src/proj-${PROJ_VERSION} ./configure make -j "$(nproc)" make install