Skip to content

Commit 0cb9f37

Browse files
committed
Merge branch 'master' into stretch-me
2 parents 9ee5255 + 34ad931 commit 0cb9f37

File tree

4 files changed

+194
-0
lines changed

4 files changed

+194
-0
lines changed
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
FROM amazonlinux:2-with-sources
2+
LABEL maintainer="M. Edward (Ed) Borasky <znmeb@znmeb.net>"
3+
4+
# PostgreSQL and command line tools
5+
RUN amazon-linux-extras install \
6+
postgresql9.6 \
7+
nano \
8+
vim \
9+
&& yum install -y \
10+
awscli \
11+
curl \
12+
git \
13+
groff \
14+
lynx \
15+
postgresql \
16+
postgresql-contrib \
17+
postgresql-devel \
18+
postgresql-docs \
19+
postgresql-server \
20+
procps-ng \
21+
shadow-utils \
22+
tar \
23+
wget \
24+
&& yum clean all \
25+
&& rm -rf /var/cache/yum
26+
27+
# PostGIS build dependencies
28+
RUN yum update -y \
29+
&& yum install -y \
30+
boost-devel \
31+
bzip2 \
32+
file \
33+
gcc \
34+
gcc-c++ \
35+
gettext-devel \
36+
gmp-devel \
37+
json-c-devel \
38+
libxml2-devel \
39+
make \
40+
mpfr-devel \
41+
unzip \
42+
&& yum clean all \
43+
&& rm -rf /var/cache/yum
44+
45+
# setup for builds
46+
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig
47+
RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf \
48+
&& mkdir -p /usr/local/src/
49+
WORKDIR /usr/local/src/
50+
51+
# source installs
52+
ENV CMAKE_MAJOR 3.10
53+
ENV CMAKE_VERSION ${CMAKE_MAJOR}.2
54+
RUN wget -q https://cmake.org/files/v${CMAKE_MAJOR}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh \
55+
&& chmod +x cmake-${CMAKE_VERSION}-Linux-x86_64.sh \
56+
&& ./cmake-${CMAKE_VERSION}-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir --skip-license
57+
58+
ENV CGAL_VERSION 4.11.1
59+
RUN wget -q https://github.com/CGAL/cgal/archive/releases/CGAL-${CGAL_VERSION}.tar.gz \
60+
&& tar xf CGAL-${CGAL_VERSION}.tar.gz \
61+
&& cd cgal-releases-CGAL-${CGAL_VERSION} \
62+
&& cmake . > ../cgal.cmake \
63+
&& make \
64+
&& make install \
65+
&& ldconfig
66+
67+
ENV PROTOBUF_VERSION 3.5.1
68+
RUN wget -q https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-cpp-${PROTOBUF_VERSION}.tar.gz \
69+
&& tar xf protobuf-cpp-${PROTOBUF_VERSION}.tar.gz \
70+
&& cd /usr/local/src/protobuf-${PROTOBUF_VERSION} \
71+
&& ./configure > ../protobuf.configure \
72+
&& make > /dev/null \
73+
&& make install > /dev/null \
74+
&& ldconfig
75+
76+
ENV PROTOBUF_C_VERSION 1.3.0
77+
RUN wget -q https://github.com/protobuf-c/protobuf-c/releases/download/v${PROTOBUF_C_VERSION}/protobuf-c-${PROTOBUF_C_VERSION}.tar.gz \
78+
&& tar xf protobuf-c-${PROTOBUF_C_VERSION}.tar.gz \
79+
&& cd /usr/local/src/protobuf-c-${PROTOBUF_C_VERSION} \
80+
&& ./configure > ../protobuf-c.configure \
81+
&& make > /dev/null \
82+
&& make install > /dev/null \
83+
&& ldconfig
84+
85+
ENV GEOS_VERSION 3.6.2
86+
RUN wget -q http://download.osgeo.org/geos/geos-${GEOS_VERSION}.tar.bz2 \
87+
&& tar xf geos-${GEOS_VERSION}.tar.bz2 \
88+
&& cd /usr/local/src/geos-${GEOS_VERSION} \
89+
&& ./configure > ../geos.configure \
90+
&& make > /dev/null \
91+
&& make install > /dev/null \
92+
&& ldconfig
93+
94+
ENV PROJ_VERSION 4.9.3
95+
ENV DATUMGRID_VERSION 1.6
96+
RUN wget -q http://download.osgeo.org/proj/proj-${PROJ_VERSION}.tar.gz \
97+
&& tar xf proj-${PROJ_VERSION}.tar.gz \
98+
&& wget -q http://download.osgeo.org/proj/proj-datumgrid-${DATUMGRID_VERSION}.zip \
99+
&& cd /usr/local/src/proj-${PROJ_VERSION} \
100+
&& ./configure > ../proj.configure \
101+
&& make > /dev/null \
102+
&& make install > /dev/null \
103+
&& ldconfig \
104+
&& cd /usr/local/share/proj/ \
105+
&& unzip /usr/local/src/proj-datumgrid-${DATUMGRID_VERSION}.zip
106+
107+
ENV GDAL_VERSION 2.2.4
108+
RUN wget -q http://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz \
109+
&& tar xf gdal-${GDAL_VERSION}.tar.gz \
110+
&& cd /usr/local/src/gdal-${GDAL_VERSION} \
111+
&& ./configure > ../gdal.configure \
112+
&& make > /dev/null \
113+
&& make install > /dev/null \
114+
&& ldconfig
115+
116+
ENV POSTGIS_VERSION 2.4.3
117+
RUN wget -q https://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz \
118+
&& tar xf postgis-${POSTGIS_VERSION}.tar.gz \
119+
&& cd /usr/local/src/postgis-${POSTGIS_VERSION} \
120+
&& ./configure > ../postgis.configure \
121+
&& make > /dev/null \
122+
&& make install > /dev/null \
123+
&& ldconfig
124+
125+
# pgRouting
126+
ENV PGROUTING_VERSION 2.5.2
127+
RUN yum install -y perl-Data-Dumper
128+
RUN curl -Ls https://github.com/pgRouting/pgrouting/archive/v${PGROUTING_VERSION}.tar.gz \
129+
> pgrouting-${PGROUTING_VERSION}.tar.gz \
130+
&& tar xf pgrouting-${PGROUTING_VERSION}.tar.gz \
131+
&& cd pgrouting-${PGROUTING_VERSION} \
132+
&& mkdir build \
133+
&& cd build \
134+
&& cmake .. > ../../pgrouting.cmake \
135+
&& make > ../../pgrouting.make \
136+
&& make install > /dev/null \
137+
&& ldconfig
138+
139+
# make the users
140+
RUN useradd --shell /bin/bash --user-group --create-home dbsuper \
141+
&& mkdir -p /home/dbsuper/Projects/ \
142+
&& echo "alias l='ls -ACF --color=auto'" >> /etc/bashrc \
143+
&& echo "alias ll='ls -ltrAF --color=auto'" >> /etc/bashrc
144+
COPY home-scripts /home/dbsuper/
145+
COPY amazon-scripts/1make-dbusers.bash /var/lib/pgsql/
146+
RUN chmod +x /home/dbsuper/*.bash /var/lib/pgsql/1make-dbusers.bash
147+
RUN chown postgres:postgres /var/lib/pgsql/1make-dbusers.bash
148+
149+
USER postgres
150+
ARG DB_USERS_TO_CREATE
151+
RUN initdb --locale=en_US.utf8 --encoding=UTF8 -D /var/lib/pgsql/data/main \
152+
&& pg_ctl start -w -D /var/lib/pgsql/data/main \
153+
&& createuser --superuser dbsuper \
154+
&& createdb --owner=dbsuper dbsuper \
155+
&& bash /var/lib/pgsql/1make-dbusers.bash \
156+
&& pg_ctl stop -w -D /var/lib/pgsql/data/main
157+
158+
# do backups at the end so rest of image doesn't need a rebuild
159+
USER root
160+
COPY Backups /home/dbsuper/Backups
161+
COPY Raw /home/dbsuper/Raw
162+
RUN chown -R dbsuper:dbsuper /home/dbsuper
163+
164+
USER postgres
165+
CMD pg_ctl -D /var/lib/pgsql/data/main start; /usr/bin/sleep 1001d

containers/amazon-postgis.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: '3.4'
2+
services:
3+
postgis:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile.postgis
7+
args:
8+
- DB_USERS_TO_CREATE
9+
image: postgis
10+
ports:
11+
- $HOST_POSTGRES_PORT:5432
12+
environment:
13+
- POSTGRES_PASSWORD
14+
- DB_USERS_TO_CREATE
15+
command: [ "postgres", "-c", "max_wal_size=2GB" ]
16+
amazon-postgis:
17+
build:
18+
context: .
19+
dockerfile: Dockerfile.amazon-postgis
20+
args:
21+
- DB_USERS_TO_CREATE
22+
image: amazon-postgis
23+
environment:
24+
- DB_USERS_TO_CREATE
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /bin/bash
2+
3+
docker exec -it -e LINES=$(tput lines) -e COLUMNS=$(tput cols) -u dbsuper -w /home/dbsuper \
4+
containers_amazon-postgis_1 /bin/bash

docs/_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
theme: jekyll-theme-hacker

0 commit comments

Comments
 (0)