├── docker_entrypoint.sh ├── LICENSE ├── README.md └── Dockerfile /docker_entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | #POSTGRES_USER="docker" 5 | #POSTGRES_PASSWORD="'docker'" 6 | 7 | su - postgres -c " 8 | export PATH=$PATH:/usr/local/pgsql/bin &&\ 9 | echo \"export PATH=$PATH:/usr/local/pgsql/bin\" >> /home/postgres/.bashrc &&\ 10 | pg_ctl -w -D /usr/local/pgsql/data -l /usr/local/pgsql/data/logfile start &&\ 11 | if psql -t -c '\du' | cut -d \| -f 1 | grep -qw \"$POSTGRES_USER\"; then echo \"main db user already exists\"; else psql -h 127.0.0.1 --command \"CREATE USER $POSTGRES_USER WITH SUPERUSER PASSWORD $POSTGRES_PASSWORD;\"; fi 12 | " 13 | 14 | exec "$@"; 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker image for PostgreSQL 8.3.8 with PostGIS 1.3.5 2 | 3 | This image is very simple. It's not intended for new projects. Please use the [official postgres images](https://hub.docker.com/_/postgres/) or -- if you need postgis -- an up-to-date and well prepared implementation like the one from [mdillon](https://hub.docker.com/r/mdillon/postgis/). 4 | 5 | The abomination in this repository creates a badly crafted docker container with terribly outdated software (Ubuntu 12.04, PostgreSQL 8.3.8, PostGIS 1.3.5, etc.). I created it to deal with very old PostGIS enabled Postgres databases. In my usecase the work necessary to port the databases to new versions would be disproportionately high. I therefore decided to craft this container with the old environment. I share it here to provide people in the same situation with a fast solution. 6 | 7 | ## Pull image from dockerhub and run container 8 | 9 | ``` 10 | docker run \ 11 | -e POSTGRES_USER="docker" \ 12 | -e POSTGRES_PASSWORD="'docker'" \ 13 | -p 5432:5432 \ 14 | --name pgres8 \ 15 | -dit nevrome/docker_postgres838_postgis135 /bin/bash 16 | ``` 17 | 18 | ## Build image and run container from scratch 19 | 20 | ``` 21 | docker build -t docker_postgres838_postgis135 . 22 | 23 | docker run \ 24 | -e POSTGRES_USER="docker" \ 25 | -e POSTGRES_PASSWORD="'docker'" \ 26 | -p 5432:5432 \ 27 | --name pgres8 \ 28 | -dit docker_postgres838_postgis135 /bin/bash 29 | ``` 30 | 31 | ## Enable postgis for individual databases 32 | See [here](http://www.postgis.org/download/postgis-1.3.5.pdf) for reference. 33 | 34 | ``` 35 | docker exec -it pgres8 /bin/bash 36 | ``` 37 | 38 | ``` 39 | su postgres 40 | createlang plpgsql [yourdatabase] 41 | psql -d [yourdatabase] -U [youruser] -f /usr/local/pgsql/share/lwpostgis.sql 42 | psql -d [yourdatabase] -U [youruser] -f /usr/local/pgsql/share/spatial_ref_sys.sql 43 | ``` -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:12.04.5 2 | 3 | MAINTAINER Clemens Schmid 4 | 5 | # explicitly set user/group IDs 6 | RUN groupadd -r postgres --gid=999 && useradd -r -m -d /home/postgres/ -s /bin/bash -g postgres --uid=999 postgres 7 | 8 | # make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default 9 | RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ 10 | && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 11 | ENV LANG en_US.utf8 12 | 13 | # install software from package repos 14 | RUN apt-get update && \ 15 | apt-get install -y build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev clang libgeos-dev wget 16 | 17 | # install postgres 18 | RUN wget --no-check-certificate https://ftp.postgresql.org/pub/source/v8.3.8/postgresql-8.3.8.tar.gz && \ 19 | tar zxf postgresql-8.3.8.tar.gz && \ 20 | cd postgresql-8.3.8 && \ 21 | ./configure LDFLAGS=-lstdc++ CFLAGS="-O1" CC=clang && \ 22 | make && \ 23 | make install && \ 24 | cd .. && \ 25 | rm postgresql-8.3.8.tar.gz && \ 26 | rm -r postgresql-8.3.8 27 | 28 | # setup directories and variables for postgres 29 | RUN mkdir /usr/local/pgsql/data && \ 30 | chown postgres /usr/local/pgsql/data 31 | RUN LD_LIBRARY_PATH=/usr/local/pgsql/lib:$LD_LIBRARY_PATH && \ 32 | export LD_LIBRARY_PATH && \ 33 | export PATH=/usr/local/pgsql/bin:$PATH 34 | 35 | # install proj4 36 | RUN wget http://download.osgeo.org/proj/proj-4.6.0.tar.gz && \ 37 | tar xzf proj-4.6.0.tar.gz && \ 38 | cd proj-4.6.0 && \ 39 | ./configure && make clean && make && \ 40 | make install && \ 41 | ldconfig && \ 42 | cd .. && \ 43 | rm proj-4.6.0.tar.gz && \ 44 | rm -r proj-4.6.0 45 | 46 | # install postgis 47 | RUN LD_LIBRARY_PATH=/usr/local/pgsql/lib:$LD_LIBRARY_PATH && \ 48 | export LD_LIBRARY_PATH && \ 49 | export PATH=/usr/local/pgsql/bin:$PATH && \ 50 | wget http://postgis.refractions.net/download/postgis-1.3.5.tar.gz && \ 51 | tar zxf postgis-1.3.5.tar.gz && \ 52 | cd postgis-1.3.5 && \ 53 | ./configure && \ 54 | make && \ 55 | make install && \ 56 | cd .. && \ 57 | rm postgis-1.3.5.tar.gz && \ 58 | rm -r postgis-1.3.5 59 | 60 | ENV PGDATA /usr/local/pgsql/data 61 | 62 | # port 63 | EXPOSE 5432 64 | 65 | # further postgres settings and system test 66 | USER postgres 67 | ENV PATH="/usr/local/pgsql/bin:${PATH}" 68 | RUN initdb -D $PGDATA && \ 69 | echo "host all all 0.0.0.0/0 md5" >> $PGDATA/pg_hba.conf && \ 70 | echo "listen_addresses='*'" >> $PGDATA/postgresql.conf && \ 71 | pg_ctl -D $PGDATA -l $PGDATA/logfile start && \ 72 | top -b -n 1 73 | 74 | # configure entrypoint 75 | USER root 76 | COPY docker_entrypoint.sh /usr/local/bin/ 77 | RUN chmod +x /usr/local/bin/docker_entrypoint.sh 78 | RUN ln -s usr/local/bin/docker_entrypoint.sh / 79 | ENTRYPOINT ["docker_entrypoint.sh"] 80 | --------------------------------------------------------------------------------