├── .__travis.yml
├── LICENSE
├── README.md
├── hooks
├── pre-commit
└── setup-hooks.sh
├── quickstart.bat
├── quickstart.sh
├── templates
├── 3dcitydb-v3.x.x
│ ├── CREATE_DB.sql
│ ├── alpine
│ │ └── Dockerfile
│ └── debian
│ │ └── Dockerfile
├── 3dcitydb-v4.x.x
│ ├── alpine
│ │ └── Dockerfile
│ └── debian
│ │ └── Dockerfile
├── 3dcitydb.sh
├── addcitydb
├── dropcitydb
└── purgedb
├── v3.0.0
├── 3dcitydb.sh
├── CREATE_DB.sql
├── Dockerfile
├── addcitydb
├── alpine
│ ├── 3dcitydb.sh
│ ├── CREATE_DB.sql
│ ├── Dockerfile
│ ├── addcitydb
│ ├── dropcitydb
│ └── purgedb
├── dropcitydb
└── purgedb
├── v3.1.0
├── 3dcitydb.sh
├── CREATE_DB.sql
├── Dockerfile
├── addcitydb
├── alpine
│ ├── 3dcitydb.sh
│ ├── CREATE_DB.sql
│ ├── Dockerfile
│ ├── addcitydb
│ ├── dropcitydb
│ └── purgedb
├── dropcitydb
└── purgedb
├── v3.2.0
├── 3dcitydb.sh
├── CREATE_DB.sql
├── Dockerfile
├── addcitydb
├── alpine
│ ├── 3dcitydb.sh
│ ├── CREATE_DB.sql
│ ├── Dockerfile
│ ├── addcitydb
│ ├── dropcitydb
│ └── purgedb
├── dropcitydb
└── purgedb
├── v3.3.0
├── 3dcitydb.sh
├── CREATE_DB.sql
├── Dockerfile
├── addcitydb
├── alpine
│ ├── 3dcitydb.sh
│ ├── CREATE_DB.sql
│ ├── Dockerfile
│ ├── addcitydb
│ ├── dropcitydb
│ └── purgedb
├── dropcitydb
└── purgedb
├── v3.3.1
├── 3dcitydb.sh
├── CREATE_DB.sql
├── Dockerfile
├── addcitydb
├── alpine
│ ├── 3dcitydb.sh
│ ├── CREATE_DB.sql
│ ├── Dockerfile
│ ├── addcitydb
│ ├── dropcitydb
│ └── purgedb
├── dropcitydb
└── purgedb
├── v4.0.0
├── 3dcitydb.sh
├── Dockerfile
├── addcitydb
├── alpine
│ ├── 3dcitydb.sh
│ ├── Dockerfile
│ ├── addcitydb
│ ├── dropcitydb
│ └── purgedb
├── dropcitydb
└── purgedb
├── v4.0.1
├── 3dcitydb.sh
├── Dockerfile
├── addcitydb
├── alpine
│ ├── 3dcitydb.sh
│ ├── Dockerfile
│ ├── addcitydb
│ ├── dropcitydb
│ └── purgedb
├── dropcitydb
└── purgedb
├── v4.0.2
├── 3dcitydb.sh
├── Dockerfile
├── addcitydb
├── alpine
│ ├── 3dcitydb.sh
│ ├── Dockerfile
│ ├── addcitydb
│ ├── dropcitydb
│ └── purgedb
├── dropcitydb
└── purgedb
└── v4.0.3
├── 3dcitydb.sh
├── Dockerfile
├── addcitydb
├── alpine
├── 3dcitydb.sh
├── Dockerfile
├── addcitydb
├── dropcitydb
└── purgedb
├── dropcitydb
└── purgedb
/.__travis.yml:
--------------------------------------------------------------------------------
1 | os: linux
2 | dist: bionic
3 | language: shell
4 | services:
5 | - docker
6 | env:
7 | - version: v3.0.0
8 | - version: v3.1.0
9 | - version: v3.2.0
10 | - version: v3.3.0
11 | - version: v3.3.1
12 | - version: v4.0.0
13 | - version: v4.0.1
14 | - version: v4.0.2
15 | - version: v4.0.3
16 | before_install:
17 | - docker build --build-arg citydb_version=${version} -t tumgis/3dcitydb-postgis:${version}
18 | ./${version}
19 | - docker build --build-arg citydb_version=${version} -t tumgis/3dcitydb-postgis:${version}-alpine
20 | ./${version}/alpine
21 | before_script:
22 | - sleep 5
23 | - docker run --name ${version} -dit -e POSTGRES_PASSWORD=password -e "SRID=31468"
24 | -e "SRSNAME=EPSG:31468" tumgis/3dcitydb-postgis:${version}
25 | - docker run --name ${version}-alpine -e POSTGRES_PASSWORD=password -dit -e "SRID=31468"
26 | -e "SRSNAME=EPSG:31468" tumgis/3dcitydb-postgis:${version}-alpine
27 | - docker images
28 | - docker ps -a
29 | script:
30 | - sleep 30
31 | - docker logs ${version} | grep -Pzl '(?s)Setting up 3DCityDB ...done!.*database system
32 | is ready to accept connections'
33 | - docker logs ${version}-alpine | grep -Pzl '(?s)Setting up 3DCityDB ...done!.*database
34 | system is ready to accept connections'
35 | notifications:
36 | slack:
37 | secure: kT4yM87dFVljeaXlFrInD3ffxfAHCboL0VoViOHtMp1Sci1LSw5aHpRMYfeYBZZx50lonuppcRVmciwx420T3WwuYdGC8JD3tzhp/grZvwz8IbY5ig0IxO+W9JONXDeE7W0Da/Gy6qFNBrIuHpCeV8mPpoMp8wfuReMTp7Va/RL/lZIHG+Zr/pXdzna1r87noH7M0Zmv+e7Hfu77z/c6wJrCe2uy9AtYHGcND1X1IXhKTxvpxITbJYKRvj/0vlXpXX7xYWwTEh59Rx5/zuQ//XG/5DRmFB/6m5MIuGZoP/DLzIROAKccXYJhTZMap4niQvwwPw5uLtLN73fJ4Ic+2i5KvEZ1g4/LHw85eYKOgWKXqQMAJBB1c9xSlyHq+ba5TdWDeAJ4dN7f3ir+f/DQi42YERAB2nEox9dF1mBf/qmxHgx61HuJ+ubQ8W0538JeeAczvRqNtCfWBnmFqsbeKfNSmBnH98MfAv+N1QpPyuAN8PKF56q4yD/wIBiG9jHCWPhxXXomup9noHn10bWzaqGmSMaOOBPnVyIrFNg1cODR00SZ0YLxK3eO7Cq2YC3cCObSdFBoAMhGwX8AWqQfd7ulryB6PZJPZkgd6I8NAM1ATjLsLBHDJ5VQ20G6D8TcEFDyC+MVc0MMo+VF1lpjDU2GVDNHHRRpwWZNUdHRhbc=
38 | on_success: change
39 | on_failure: always
40 |
--------------------------------------------------------------------------------
/hooks/pre-commit:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # 3DCityDB v3.x.x -------------------------------------------------------------
4 | declare -a citydb_versions=("v3.0.0" "v3.1.0" "v3.2.0" "v3.3.0" "v3.3.1")
5 | scripts='templates/3dcitydb-v3.x.x/CREATE_DB.sql templates/3dcitydb.sh templates/addcitydb templates/dropcitydb templates/purgedb'
6 |
7 | for i in "${citydb_versions[@]}"
8 | do
9 | version="${i}"
10 | version_alpine="${i}/alpine"
11 | df_version=${version}/Dockerfile
12 | df_version_alpine=${version_alpine}/Dockerfile
13 | echo $version
14 | echo $version_alpine
15 |
16 | # clear existing version folder
17 | rm -rf ${version}
18 | mkdir -p ${version}
19 | mkdir -p ${version_alpine}
20 |
21 | # template -> Dockerfile, replace %%CITYDB_VERSION%% in template
22 | sed -e "s/%%CITYDB_VERSION%%/${version}/g" "templates/3dcitydb-v3.x.x/debian/Dockerfile" > ${df_version}
23 | sed -e "s/%%CITYDB_VERSION%%/${version}/g" "templates/3dcitydb-v3.x.x/alpine/Dockerfile" > ${df_version_alpine}
24 |
25 | # copy scripts
26 | cp $scripts ${version}
27 | cp $scripts ${version_alpine}
28 |
29 | git add ${version} ${version_alpine}
30 | done
31 |
32 | # 3DCityDB v4.x.x -------------------------------------------------------------
33 | declare -a citydb_versions=("v4.0.0" "v4.0.1" "v4.0.2" "v4.0.3")
34 | scripts='templates/3dcitydb.sh templates/addcitydb templates/dropcitydb templates/purgedb'
35 |
36 | for i in "${citydb_versions[@]}"
37 | do
38 | version="${i}"
39 | version_alpine="${i}/alpine"
40 | df_version=${version}/Dockerfile
41 | df_version_alpine=${version_alpine}/Dockerfile
42 | echo $version
43 | echo $version_alpine
44 |
45 | # clear existing version folder
46 | rm -rf ${version}
47 | mkdir -p ${version}
48 | mkdir -p ${version_alpine}
49 |
50 | # template -> Dockerfile, replace %%CITYDB_VERSION%% in template
51 | sed -e "s/%%CITYDB_VERSION%%/${version}/g" "templates/3dcitydb-v4.x.x/debian/Dockerfile" > ${df_version}
52 | sed -e "s/%%CITYDB_VERSION%%/${version}/g" "templates/3dcitydb-v4.x.x/alpine/Dockerfile" > ${df_version_alpine}
53 |
54 | # copy scripts
55 | cp $scripts ${version}
56 | cp $scripts ${version_alpine}
57 |
58 | git add ${version} ${version_alpine}
59 | done
60 |
--------------------------------------------------------------------------------
/hooks/setup-hooks.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # setup hooks located in $REPOROOT/hooks folder of a git repo -----------------
4 |
5 | # git hooks
6 | hooks=('applypatch-msg' 'pre-applypatch' 'post-applypatch' 'pre-commit' \
7 | 'prepare-commit-msg' 'commit-msg' 'post-commit' 'pre-rebase' 'post-checkout' \
8 | 'post-merge' 'pre-push' 'pre-receive' 'update' 'post-receive' 'post-update' \
9 | 'pre-auto-gc' 'post-rewrite')
10 |
11 | # manage working dir
12 | pwdBefore=$PWD
13 | REPOROOT="$(git rev-parse --show-toplevel)"
14 | cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
15 |
16 | echo
17 |
18 | if [ -d "$REPOROOT/.git" ]; then
19 | echo 'Setting up hooks...'
20 | echo
21 | for i in "${hooks[@]}"
22 | do
23 | # Remove all hooks
24 | rm -vf "$REPOROOT/.git/hooks/$i"
25 | # Add hooks existing in $REPOROOT/hooks
26 | if [ -f "$i" ]; then
27 | printf "\t$i\t"
28 | ln -sv "$PWD/$i" "$REPOROOT/.git/hooks"
29 | fi
30 | done
31 | echo
32 | echo 'Setting up hooks...done!'
33 | else
34 | echo "$REPOROOT seems not to be a git repo, Doing nothing!"
35 | fi
36 |
37 | cd $pwdBefore
38 |
--------------------------------------------------------------------------------
/templates/3dcitydb-v3.x.x/CREATE_DB.sql:
--------------------------------------------------------------------------------
1 | -- 3D City Database - The Open Source CityGML Database
2 | -- http://www.3dcitydb.org/
3 | --
4 | -- Copyright 2013 - 2016
5 | -- Chair of Geoinformatics
6 | -- Technical University of Munich, Germany
7 | -- https://www.gis.bgu.tum.de/
8 | --
9 | -- The 3D City Database is jointly developed with the following
10 | -- cooperation partners:
11 | --
12 | -- virtualcitySYSTEMS GmbH, Berlin
13 | -- M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen
14 | --
15 | -- Licensed under the Apache License, Version 2.0 (the "License");
16 | -- you may not use this file except in compliance with the License.
17 | -- You may obtain a copy of the License at
18 | --
19 | -- http://www.apache.org/licenses/LICENSE-2.0
20 | --
21 | -- Unless required by applicable law or agreed to in writing, software
22 | -- distributed under the License is distributed on an "AS IS" BASIS,
23 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | -- See the License for the specific language governing permissions and
25 | -- limitations under the License.
26 | --
27 | -- Modifications --------------------------------------------------------------
28 | -- The original script has been modified to receive SRSNO and SRSNAME as parameter
29 | -- using the psql "-v" switch instead of prompting for user input.
30 | --
31 | -- Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich
32 | -- b.willenborg@tum.de
33 | -------------------------------------------------------------------------------
34 |
35 | -- This script is called from CREATE_DB.bat
36 | \pset footer off
37 | SET client_min_messages TO WARNING;
38 | \set ON_ERROR_STOP ON
39 |
40 | \echo
41 | --\prompt 'Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin): ' SRS_NO
42 | --\prompt 'Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783): ' GMLSRSNAME
43 |
44 | \set SRSNO :srsno
45 | \set SRSNO :SRS_NO
46 | \set SRS_NO :srsno
47 | \set GMLSRSNAME :gmlsrsname
48 |
49 | -- \echo 'SRSNO ' :'SRSNO'
50 | -- \echo 'SRS_NO ' :SRS_NO
51 | -- \echo 'srsname ' :srsname
52 | -- \echo 'GMLSRSNAME ' :GMLSRSNAME
53 |
54 | --// check if the PostGIS extension is available
55 | SELECT postgis_version();
56 |
57 | --// create TABLES, SEQUENCES, CONSTRAINTS, INDEXES
58 | \echo
59 | \echo 'Setting up database schema of 3DCityDB instance ...'
60 | \i SCHEMA/SCHEMA.sql
61 |
62 | --// fill tables OBJECTCLASS
63 | \i UTIL/CREATE_DB/OBJECTCLASS_INSTANCES.sql
64 |
65 | --// create CITYDB_PKG (additional schema with PL/pgSQL-Functions)
66 | \echo
67 | \echo 'Creating additional schema ''citydb_pkg'' ...'
68 | \i CREATE_CITYDB_PKG.sql
69 |
70 | --// update search_path on database level
71 | ALTER DATABASE :"DBNAME" SET search_path TO citydb,citydb_pkg,public;
72 |
73 | \echo
74 | \echo '3DCityDB creation complete!'
75 |
76 | --// checks if the chosen SRID is provided by the spatial_ref_sys table
77 | \echo
78 | \echo 'Checking spatial reference system ...'
79 | SELECT citydb_pkg.check_srid(:SRS_NO);
80 |
81 | \echo 'Setting spatial reference system of 3DCityDB instance ...'
82 | INSERT INTO citydb.DATABASE_SRS(SRID,GML_SRS_NAME) VALUES (:SRS_NO,:'GMLSRSNAME');
83 | SELECT citydb_pkg.change_schema_srid(:SRS_NO,:'GMLSRSNAME');
84 | \echo 'Done'
85 |
--------------------------------------------------------------------------------
/templates/3dcitydb-v3.x.x/alpine/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12-alpine'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ARG postgis_version='3.0.0'
17 | ENV POSTGIS_VERSION=${postgis_version}
18 | ARG citydb_version='%%CITYDB_VERSION%%'
19 | ENV CITYDBVERSION=${citydb_version}
20 |
21 | # Setup fetch deps
22 | RUN set -ex && \
23 | apk update && \
24 | apk add --no-cache --virtual .fetch-deps tar openssl git
25 |
26 | # Create folders
27 | RUN set -ex && \
28 | mkdir -p 3dcitydb && \
29 | mkdir -p /docker-entrypoint-initdb.d
30 |
31 | # Fetch 3DCityDB
32 | RUN set -ex && \
33 | git clone -b "${POSTGIS_VERSION}" --depth 1 https://github.com/postgis/postgis.git postgis_temp && \
34 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
35 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
36 |
37 | # Setup build deps
38 | RUN set -ex && \
39 | apk add --no-cache --virtual .build-deps \
40 | autoconf \
41 | automake \
42 | file \
43 | json-c-dev \
44 | libtool \
45 | libxml2-dev \
46 | make \
47 | perl \
48 | clang-dev \
49 | g++ \
50 | gcc \
51 | gdal-dev \
52 | geos-dev \
53 | llvm10-dev \
54 | proj-dev \
55 | protobuf-c-dev
56 |
57 | # Build PostGIS
58 | RUN set -ex && \
59 | cd postgis_temp && \
60 | ./autogen.sh && \
61 | ./configure && make -j$(nproc) && make install && \
62 | cd ..
63 |
64 | # Setup runtime deps
65 | RUN set -ex && \
66 | apk add --no-cache --virtual .postgis-rundeps \
67 | json-c \
68 | geos \
69 | gdal \
70 | proj \
71 | libstdc++ \
72 | protobuf-c
73 |
74 | # Cleanup
75 | RUN set -ex && \
76 | apk del .fetch-deps .build-deps && \
77 | rm -rf postgis_temp 3dcitydb_temp
78 |
79 | # Copy scripts
80 | COPY CREATE_DB.sql /3dcitydb/
81 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
82 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
83 |
84 | # Set permissions
85 | RUN set -ex && \
86 | ln -s usr/local/bin/addcitydb / && \
87 | ln -s usr/local/bin/dropcitydb / && \
88 | ln -s usr/local/bin/purgedb / && \
89 | chmod u+x /usr/local/bin/dropcitydb && \
90 | chmod u+x /usr/local/bin/addcitydb && \
91 | chmod u+x /usr/local/bin/purgedb
92 |
--------------------------------------------------------------------------------
/templates/3dcitydb-v3.x.x/debian/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ENV POSTGIS_MAJOR='3'
17 | ARG citydb_version='%%CITYDB_VERSION%%'
18 | ENV CITYDBVERSION=${citydb_version}
19 |
20 | ARG BUILD_PACKAGES='ca-certificates git'
21 | ARG RUNTIME_PACKAGES="postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
23 | postgis"
24 |
25 | # Setup build and runtime deps
26 | RUN set -x && \
27 | apt-get update && \
28 | apt-get install -y --no-install-recommends $BUILD_PACKAGES $RUNTIME_PACKAGES
29 |
30 | # Create folders
31 | RUN set -x && \
32 | mkdir -p 3dcitydb && \
33 | mkdir -p /docker-entrypoint-initdb.d
34 |
35 | # Clone 3DCityDB
36 | RUN set -x && \
37 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
38 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
39 |
40 | # Cleanup
41 | RUN set -x && \
42 | rm -rf 3dcitydb_temp && \
43 | apt-get purge -y --auto-remove $BUILD_PACKAGES && \
44 | rm -rf /var/lib/apt/lists/*
45 |
46 | # Copy scripts
47 | COPY CREATE_DB.sql /3dcitydb/
48 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
49 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
50 |
51 | # Set permissions
52 | RUN set -ex && \
53 | ln -s usr/local/bin/addcitydb / && \
54 | ln -s usr/local/bin/dropcitydb / && \
55 | ln -s usr/local/bin/purgedb / && \
56 | chmod u+x /usr/local/bin/dropcitydb && \
57 | chmod u+x /usr/local/bin/addcitydb && \
58 | chmod u+x /usr/local/bin/purgedb
59 |
--------------------------------------------------------------------------------
/templates/3dcitydb-v4.x.x/alpine/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12-alpine'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ARG postgis_version='3.0.0'
17 | ENV POSTGIS_VERSION=${postgis_version}
18 | ARG citydb_version='%%CITYDB_VERSION%%'
19 | ENV CITYDBVERSION=${citydb_version}
20 |
21 | # Setup fetch deps
22 | RUN set -ex && \
23 | apk update && \
24 | apk add --no-cache --virtual .fetch-deps tar openssl git
25 |
26 | # Create folders
27 | RUN set -ex && \
28 | mkdir -p 3dcitydb && \
29 | mkdir -p /docker-entrypoint-initdb.d
30 |
31 | # Fetch 3DCityDB
32 | RUN set -ex && \
33 | git clone -b "${POSTGIS_VERSION}" --depth 1 https://github.com/postgis/postgis.git postgis_temp && \
34 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
35 | mv 3dcitydb_temp/?ostgre???/SQLScripts/* 3dcitydb
36 |
37 | # Setup build deps
38 | RUN set -ex && \
39 | apk add --no-cache --virtual .build-deps \
40 | autoconf \
41 | automake \
42 | file \
43 | json-c-dev \
44 | libtool \
45 | libxml2-dev \
46 | make \
47 | perl \
48 | clang-dev \
49 | g++ \
50 | gcc \
51 | gdal-dev \
52 | geos-dev \
53 | llvm10-dev \
54 | proj-dev \
55 | protobuf-c-dev
56 |
57 | # Build PostGIS
58 | RUN set -ex && \
59 | cd postgis_temp && \
60 | ./autogen.sh && \
61 | ./configure && make -j$(nproc) && make install && \
62 | cd ..
63 |
64 | # Setup runtime deps
65 | RUN set -ex && \
66 | apk add --no-cache --virtual .postgis-rundeps \
67 | json-c \
68 | geos \
69 | gdal \
70 | proj \
71 | libstdc++ \
72 | protobuf-c
73 |
74 | # Cleanup
75 | RUN set -ex && \
76 | apk del .fetch-deps .build-deps && \
77 | rm -rf postgis_temp 3dcitydb_temp
78 |
79 | # Copy scripts
80 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
81 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
82 |
83 | # Set permissions
84 | RUN set -ex && \
85 | ln -s usr/local/bin/addcitydb / && \
86 | ln -s usr/local/bin/dropcitydb / && \
87 | ln -s usr/local/bin/purgedb / && \
88 | chmod u+x /usr/local/bin/dropcitydb && \
89 | chmod u+x /usr/local/bin/addcitydb && \
90 | chmod u+x /usr/local/bin/purgedb
91 |
--------------------------------------------------------------------------------
/templates/3dcitydb-v4.x.x/debian/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ENV POSTGIS_MAJOR='3'
17 | ARG citydb_version='%%CITYDB_VERSION%%'
18 | ENV CITYDBVERSION=${citydb_version}
19 |
20 | ARG BUILD_PACKAGES='ca-certificates git'
21 | ARG RUNTIME_PACKAGES="postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
23 | postgis"
24 |
25 | # Setup build and runtime deps
26 | RUN set -x && \
27 | apt-get update && \
28 | apt-get install -y --no-install-recommends $BUILD_PACKAGES $RUNTIME_PACKAGES
29 |
30 | # Create folders
31 | RUN set -x && \
32 | mkdir -p 3dcitydb && \
33 | mkdir -p /docker-entrypoint-initdb.d
34 |
35 | # Clone 3DCityDB
36 | RUN set -x && \
37 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
38 | mv 3dcitydb_temp/?ostgre???/SQLScripts/* 3dcitydb
39 |
40 | # Cleanup
41 | RUN set -x && \
42 | rm -rf 3dcitydb_temp && \
43 | apt-get purge -y --auto-remove $BUILD_PACKAGES && \
44 | rm -rf /var/lib/apt/lists/*
45 |
46 | # Copy scripts
47 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
48 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
49 |
50 | # Set permissions
51 | RUN set -ex && \
52 | ln -s usr/local/bin/addcitydb / && \
53 | ln -s usr/local/bin/dropcitydb / && \
54 | ln -s usr/local/bin/purgedb / && \
55 | chmod u+x /usr/local/bin/dropcitydb && \
56 | chmod u+x /usr/local/bin/addcitydb && \
57 | chmod u+x /usr/local/bin/purgedb
58 |
--------------------------------------------------------------------------------
/templates/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/templates/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v3.0.0/3dcitydb.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # 3DCityDB setup --------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # Warn, if $POSTGRES_USER and $POSTGRES_PASSWORD are at their defaults
11 | if [ -z ${POSTGRES_USER+x} ] || [ "$POSTGRES_USER" = "postgres" ] ; then
12 | export POSTGRES_USER="postgres";
13 | echo
14 | echo "!!! WARNING !!! ################################################################"
15 | echo " POSTGRES_USER is at its default setting."
16 | echo " POSTGRES_USER=${POSTGRES_USER}."
17 | echo " Consider changing the default username for security reasons!"
18 | echo
19 | echo " To change the default POSTGRES_USER, use the docker run \"-e\" switch."
20 | echo " Example: \"docker run -e \"POSTGRES_USER=newuser\" tumgis/3dcitydb-postgis\""
21 | echo "################################################################################"
22 | fi
23 |
24 | # make sure a default non empty password is set
25 | if [ -z ${POSTGRES_PASSWORD+x} ] || [ "$POSTGRES_PASSWORD" = "postgres" ] || [ "$POSTGRES_PASSWORD" = "" ] ; then
26 | export POSTGRES_PASSWORD="postgres";
27 | echo
28 | echo "!!! WARNING !!! ################################################################"
29 | echo " POSTGRES_PASSWORD is at its default setting."
30 | echo " POSTGRES_PASSWORD=${POSTGRES_PASSWORD}."
31 | echo " Consider changing the default password for security reasons!"
32 | echo
33 | echo " To change the default POSTGRES_PASSWORD, use the docker run \"-e\" switch."
34 | echo " Example: \"docker run -e \"POSTGRES_PASSWORD=newuser\" tumgis/3dcitydb-postgis\""
35 | echo "################################################################################"
36 | fi
37 |
38 | # Perform all actions as $POSTGRES_USER with password $POSTGRES_PASSWORD
39 | export PGUSER="$POSTGRES_USER"
40 | export PGPASSWORD="$POSTGRES_PASSWORD"
41 |
42 | # Set default env: POSTGRES_PASSWORD, CITYDBNAME, SRID, SRSNAME
43 | echo
44 | echo "# Setting up tumgis/3dcitydb-postgis environment ... ###########################"
45 | if [ -z ${CITYDBNAME+x} ]; then
46 | export CITYDBNAME="citydb";
47 | echo "NOTE:"
48 | echo " CITYDBNAME has not been set. Using default CITYDBNAME=${CITYDBNAME}."
49 | echo " To change the default CITYDBNAME, use the docker run \"-e\" switch."
50 | echo " Example: \"docker run -e \"CITYDBNAME=myCustomDatabaseName\" tumgis/3dcitydb-postgis\""
51 | fi
52 |
53 | if [ -z ${SRID+x} ]; then
54 | export SRID=4326;
55 | echo
56 | echo "NOTE:"
57 | echo " SRID has not been set. Using default SRID=${SRID}."
58 | echo " To change the default SRID, use the docker run \"-e\" switch."
59 | echo " Example: \"docker run -e \"SRID=31468\" tumgis/3dcitydb-postgis\""
60 | fi
61 |
62 | if [ -z ${SRSNAME+x} ]; then
63 | export SRSNAME="urn:ogc:def:crs:EPSG::4326";
64 | echo
65 | echo "";
66 | echo "NOTE:"
67 | echo " SRSNAME has not been set. Using default SRSNAME=\"${SRSNAME}\"."
68 | echo " To change the default SRSNAME, use the docker run \"-e\" switch."
69 | echo " Example: \"docker run -e \"SRSNAME=urn:adv:crs:DE_DHDN_3GK4*DE_DHN92_NH\" tumgis/3dcitydb-postgis\""
70 | fi
71 |
72 | echo
73 | echo "# Setting up 3DCityDB environment ...done! #####################################"
74 |
75 | # Create database
76 | echo
77 | echo "# Setting up 3DCityDB ... ######################################################"
78 | echo
79 | echo "Creating database $CITYDBNAME ..."
80 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
81 | echo "Creating database $CITYDBNAME ...done!"
82 |
83 | # Setup PostGIS extension
84 | echo
85 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
86 | "${psql[@]}" -d "$CITYDBNAME" <<-EOSQL
87 | CREATE EXTENSION IF NOT EXISTS postgis;
88 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
89 | EOSQL
90 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
91 |
92 | # setup 3dcitydb
93 | echo
94 | echo "Setting up 3DCityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
95 | cd /3dcitydb
96 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
97 | echo "Setting up 3DCityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
98 | echo
99 | echo "# Setting up 3DCityDB ...done! #################################################"
100 |
101 | # echo version info and maintainer
102 | cat <
13 | -- M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen
14 | --
15 | -- Licensed under the Apache License, Version 2.0 (the "License");
16 | -- you may not use this file except in compliance with the License.
17 | -- You may obtain a copy of the License at
18 | --
19 | -- http://www.apache.org/licenses/LICENSE-2.0
20 | --
21 | -- Unless required by applicable law or agreed to in writing, software
22 | -- distributed under the License is distributed on an "AS IS" BASIS,
23 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | -- See the License for the specific language governing permissions and
25 | -- limitations under the License.
26 | --
27 | -- Modifications --------------------------------------------------------------
28 | -- The original script has been modified to receive SRSNO and SRSNAME as parameter
29 | -- using the psql "-v" switch instead of prompting for user input.
30 | --
31 | -- Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich
32 | -- b.willenborg@tum.de
33 | -------------------------------------------------------------------------------
34 |
35 | -- This script is called from CREATE_DB.bat
36 | \pset footer off
37 | SET client_min_messages TO WARNING;
38 | \set ON_ERROR_STOP ON
39 |
40 | \echo
41 | --\prompt 'Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin): ' SRS_NO
42 | --\prompt 'Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783): ' GMLSRSNAME
43 |
44 | \set SRSNO :srsno
45 | \set SRSNO :SRS_NO
46 | \set SRS_NO :srsno
47 | \set GMLSRSNAME :gmlsrsname
48 |
49 | -- \echo 'SRSNO ' :'SRSNO'
50 | -- \echo 'SRS_NO ' :SRS_NO
51 | -- \echo 'srsname ' :srsname
52 | -- \echo 'GMLSRSNAME ' :GMLSRSNAME
53 |
54 | --// check if the PostGIS extension is available
55 | SELECT postgis_version();
56 |
57 | --// create TABLES, SEQUENCES, CONSTRAINTS, INDEXES
58 | \echo
59 | \echo 'Setting up database schema of 3DCityDB instance ...'
60 | \i SCHEMA/SCHEMA.sql
61 |
62 | --// fill tables OBJECTCLASS
63 | \i UTIL/CREATE_DB/OBJECTCLASS_INSTANCES.sql
64 |
65 | --// create CITYDB_PKG (additional schema with PL/pgSQL-Functions)
66 | \echo
67 | \echo 'Creating additional schema ''citydb_pkg'' ...'
68 | \i CREATE_CITYDB_PKG.sql
69 |
70 | --// update search_path on database level
71 | ALTER DATABASE :"DBNAME" SET search_path TO citydb,citydb_pkg,public;
72 |
73 | \echo
74 | \echo '3DCityDB creation complete!'
75 |
76 | --// checks if the chosen SRID is provided by the spatial_ref_sys table
77 | \echo
78 | \echo 'Checking spatial reference system ...'
79 | SELECT citydb_pkg.check_srid(:SRS_NO);
80 |
81 | \echo 'Setting spatial reference system of 3DCityDB instance ...'
82 | INSERT INTO citydb.DATABASE_SRS(SRID,GML_SRS_NAME) VALUES (:SRS_NO,:'GMLSRSNAME');
83 | SELECT citydb_pkg.change_schema_srid(:SRS_NO,:'GMLSRSNAME');
84 | \echo 'Done'
85 |
--------------------------------------------------------------------------------
/v3.0.0/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ENV POSTGIS_MAJOR='3'
17 | ARG citydb_version='v3.0.0'
18 | ENV CITYDBVERSION=${citydb_version}
19 |
20 | ARG BUILD_PACKAGES='ca-certificates git'
21 | ARG RUNTIME_PACKAGES="postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
23 | postgis"
24 |
25 | # Setup build and runtime deps
26 | RUN set -x && \
27 | apt-get update && \
28 | apt-get install -y --no-install-recommends $BUILD_PACKAGES $RUNTIME_PACKAGES
29 |
30 | # Create folders
31 | RUN set -x && \
32 | mkdir -p 3dcitydb && \
33 | mkdir -p /docker-entrypoint-initdb.d
34 |
35 | # Clone 3DCityDB
36 | RUN set -x && \
37 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
38 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
39 |
40 | # Cleanup
41 | RUN set -x && \
42 | rm -rf 3dcitydb_temp && \
43 | apt-get purge -y --auto-remove $BUILD_PACKAGES && \
44 | rm -rf /var/lib/apt/lists/*
45 |
46 | # Copy scripts
47 | COPY CREATE_DB.sql /3dcitydb/
48 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
49 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
50 |
51 | # Set permissions
52 | RUN set -ex && \
53 | ln -s usr/local/bin/addcitydb / && \
54 | ln -s usr/local/bin/dropcitydb / && \
55 | ln -s usr/local/bin/purgedb / && \
56 | chmod u+x /usr/local/bin/dropcitydb && \
57 | chmod u+x /usr/local/bin/addcitydb && \
58 | chmod u+x /usr/local/bin/purgedb
59 |
--------------------------------------------------------------------------------
/v3.0.0/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <
13 | -- M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen
14 | --
15 | -- Licensed under the Apache License, Version 2.0 (the "License");
16 | -- you may not use this file except in compliance with the License.
17 | -- You may obtain a copy of the License at
18 | --
19 | -- http://www.apache.org/licenses/LICENSE-2.0
20 | --
21 | -- Unless required by applicable law or agreed to in writing, software
22 | -- distributed under the License is distributed on an "AS IS" BASIS,
23 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | -- See the License for the specific language governing permissions and
25 | -- limitations under the License.
26 | --
27 | -- Modifications --------------------------------------------------------------
28 | -- The original script has been modified to receive SRSNO and SRSNAME as parameter
29 | -- using the psql "-v" switch instead of prompting for user input.
30 | --
31 | -- Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich
32 | -- b.willenborg@tum.de
33 | -------------------------------------------------------------------------------
34 |
35 | -- This script is called from CREATE_DB.bat
36 | \pset footer off
37 | SET client_min_messages TO WARNING;
38 | \set ON_ERROR_STOP ON
39 |
40 | \echo
41 | --\prompt 'Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin): ' SRS_NO
42 | --\prompt 'Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783): ' GMLSRSNAME
43 |
44 | \set SRSNO :srsno
45 | \set SRSNO :SRS_NO
46 | \set SRS_NO :srsno
47 | \set GMLSRSNAME :gmlsrsname
48 |
49 | -- \echo 'SRSNO ' :'SRSNO'
50 | -- \echo 'SRS_NO ' :SRS_NO
51 | -- \echo 'srsname ' :srsname
52 | -- \echo 'GMLSRSNAME ' :GMLSRSNAME
53 |
54 | --// check if the PostGIS extension is available
55 | SELECT postgis_version();
56 |
57 | --// create TABLES, SEQUENCES, CONSTRAINTS, INDEXES
58 | \echo
59 | \echo 'Setting up database schema of 3DCityDB instance ...'
60 | \i SCHEMA/SCHEMA.sql
61 |
62 | --// fill tables OBJECTCLASS
63 | \i UTIL/CREATE_DB/OBJECTCLASS_INSTANCES.sql
64 |
65 | --// create CITYDB_PKG (additional schema with PL/pgSQL-Functions)
66 | \echo
67 | \echo 'Creating additional schema ''citydb_pkg'' ...'
68 | \i CREATE_CITYDB_PKG.sql
69 |
70 | --// update search_path on database level
71 | ALTER DATABASE :"DBNAME" SET search_path TO citydb,citydb_pkg,public;
72 |
73 | \echo
74 | \echo '3DCityDB creation complete!'
75 |
76 | --// checks if the chosen SRID is provided by the spatial_ref_sys table
77 | \echo
78 | \echo 'Checking spatial reference system ...'
79 | SELECT citydb_pkg.check_srid(:SRS_NO);
80 |
81 | \echo 'Setting spatial reference system of 3DCityDB instance ...'
82 | INSERT INTO citydb.DATABASE_SRS(SRID,GML_SRS_NAME) VALUES (:SRS_NO,:'GMLSRSNAME');
83 | SELECT citydb_pkg.change_schema_srid(:SRS_NO,:'GMLSRSNAME');
84 | \echo 'Done'
85 |
--------------------------------------------------------------------------------
/v3.0.0/alpine/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12-alpine'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ARG postgis_version='3.0.0'
17 | ENV POSTGIS_VERSION=${postgis_version}
18 | ARG citydb_version='v3.0.0'
19 | ENV CITYDBVERSION=${citydb_version}
20 |
21 | # Setup fetch deps
22 | RUN set -ex && \
23 | apk update && \
24 | apk add --no-cache --virtual .fetch-deps tar openssl git
25 |
26 | # Create folders
27 | RUN set -ex && \
28 | mkdir -p 3dcitydb && \
29 | mkdir -p /docker-entrypoint-initdb.d
30 |
31 | # Fetch 3DCityDB
32 | RUN set -ex && \
33 | git clone -b "${POSTGIS_VERSION}" --depth 1 https://github.com/postgis/postgis.git postgis_temp && \
34 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
35 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
36 |
37 | # Setup build deps
38 | RUN set -ex && \
39 | apk add --no-cache --virtual .build-deps \
40 | autoconf \
41 | automake \
42 | file \
43 | json-c-dev \
44 | libtool \
45 | libxml2-dev \
46 | make \
47 | perl \
48 | clang-dev \
49 | g++ \
50 | gcc \
51 | gdal-dev \
52 | geos-dev \
53 | llvm10-dev \
54 | proj-dev \
55 | protobuf-c-dev
56 |
57 | # Build PostGIS
58 | RUN set -ex && \
59 | cd postgis_temp && \
60 | ./autogen.sh && \
61 | ./configure && make -j$(nproc) && make install && \
62 | cd ..
63 |
64 | # Setup runtime deps
65 | RUN set -ex && \
66 | apk add --no-cache --virtual .postgis-rundeps \
67 | json-c \
68 | geos \
69 | gdal \
70 | proj \
71 | libstdc++ \
72 | protobuf-c
73 |
74 | # Cleanup
75 | RUN set -ex && \
76 | apk del .fetch-deps .build-deps && \
77 | rm -rf postgis_temp 3dcitydb_temp
78 |
79 | # Copy scripts
80 | COPY CREATE_DB.sql /3dcitydb/
81 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
82 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
83 |
84 | # Set permissions
85 | RUN set -ex && \
86 | ln -s usr/local/bin/addcitydb / && \
87 | ln -s usr/local/bin/dropcitydb / && \
88 | ln -s usr/local/bin/purgedb / && \
89 | chmod u+x /usr/local/bin/dropcitydb && \
90 | chmod u+x /usr/local/bin/addcitydb && \
91 | chmod u+x /usr/local/bin/purgedb
92 |
--------------------------------------------------------------------------------
/v3.0.0/alpine/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v3.0.0/alpine/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v3.0.0/dropcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Drop 3DCityDB ---------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 1 args passed?
11 | if [ "$#" -ne 1 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: dropcitydb CITYDBNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v3.0.0/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v3.1.0/3dcitydb.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # 3DCityDB setup --------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # Warn, if $POSTGRES_USER and $POSTGRES_PASSWORD are at their defaults
11 | if [ -z ${POSTGRES_USER+x} ] || [ "$POSTGRES_USER" = "postgres" ] ; then
12 | export POSTGRES_USER="postgres";
13 | echo
14 | echo "!!! WARNING !!! ################################################################"
15 | echo " POSTGRES_USER is at its default setting."
16 | echo " POSTGRES_USER=${POSTGRES_USER}."
17 | echo " Consider changing the default username for security reasons!"
18 | echo
19 | echo " To change the default POSTGRES_USER, use the docker run \"-e\" switch."
20 | echo " Example: \"docker run -e \"POSTGRES_USER=newuser\" tumgis/3dcitydb-postgis\""
21 | echo "################################################################################"
22 | fi
23 |
24 | # make sure a default non empty password is set
25 | if [ -z ${POSTGRES_PASSWORD+x} ] || [ "$POSTGRES_PASSWORD" = "postgres" ] || [ "$POSTGRES_PASSWORD" = "" ] ; then
26 | export POSTGRES_PASSWORD="postgres";
27 | echo
28 | echo "!!! WARNING !!! ################################################################"
29 | echo " POSTGRES_PASSWORD is at its default setting."
30 | echo " POSTGRES_PASSWORD=${POSTGRES_PASSWORD}."
31 | echo " Consider changing the default password for security reasons!"
32 | echo
33 | echo " To change the default POSTGRES_PASSWORD, use the docker run \"-e\" switch."
34 | echo " Example: \"docker run -e \"POSTGRES_PASSWORD=newuser\" tumgis/3dcitydb-postgis\""
35 | echo "################################################################################"
36 | fi
37 |
38 | # Perform all actions as $POSTGRES_USER with password $POSTGRES_PASSWORD
39 | export PGUSER="$POSTGRES_USER"
40 | export PGPASSWORD="$POSTGRES_PASSWORD"
41 |
42 | # Set default env: POSTGRES_PASSWORD, CITYDBNAME, SRID, SRSNAME
43 | echo
44 | echo "# Setting up tumgis/3dcitydb-postgis environment ... ###########################"
45 | if [ -z ${CITYDBNAME+x} ]; then
46 | export CITYDBNAME="citydb";
47 | echo "NOTE:"
48 | echo " CITYDBNAME has not been set. Using default CITYDBNAME=${CITYDBNAME}."
49 | echo " To change the default CITYDBNAME, use the docker run \"-e\" switch."
50 | echo " Example: \"docker run -e \"CITYDBNAME=myCustomDatabaseName\" tumgis/3dcitydb-postgis\""
51 | fi
52 |
53 | if [ -z ${SRID+x} ]; then
54 | export SRID=4326;
55 | echo
56 | echo "NOTE:"
57 | echo " SRID has not been set. Using default SRID=${SRID}."
58 | echo " To change the default SRID, use the docker run \"-e\" switch."
59 | echo " Example: \"docker run -e \"SRID=31468\" tumgis/3dcitydb-postgis\""
60 | fi
61 |
62 | if [ -z ${SRSNAME+x} ]; then
63 | export SRSNAME="urn:ogc:def:crs:EPSG::4326";
64 | echo
65 | echo "";
66 | echo "NOTE:"
67 | echo " SRSNAME has not been set. Using default SRSNAME=\"${SRSNAME}\"."
68 | echo " To change the default SRSNAME, use the docker run \"-e\" switch."
69 | echo " Example: \"docker run -e \"SRSNAME=urn:adv:crs:DE_DHDN_3GK4*DE_DHN92_NH\" tumgis/3dcitydb-postgis\""
70 | fi
71 |
72 | echo
73 | echo "# Setting up 3DCityDB environment ...done! #####################################"
74 |
75 | # Create database
76 | echo
77 | echo "# Setting up 3DCityDB ... ######################################################"
78 | echo
79 | echo "Creating database $CITYDBNAME ..."
80 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
81 | echo "Creating database $CITYDBNAME ...done!"
82 |
83 | # Setup PostGIS extension
84 | echo
85 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
86 | "${psql[@]}" -d "$CITYDBNAME" <<-EOSQL
87 | CREATE EXTENSION IF NOT EXISTS postgis;
88 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
89 | EOSQL
90 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
91 |
92 | # setup 3dcitydb
93 | echo
94 | echo "Setting up 3DCityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
95 | cd /3dcitydb
96 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
97 | echo "Setting up 3DCityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
98 | echo
99 | echo "# Setting up 3DCityDB ...done! #################################################"
100 |
101 | # echo version info and maintainer
102 | cat <
13 | -- M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen
14 | --
15 | -- Licensed under the Apache License, Version 2.0 (the "License");
16 | -- you may not use this file except in compliance with the License.
17 | -- You may obtain a copy of the License at
18 | --
19 | -- http://www.apache.org/licenses/LICENSE-2.0
20 | --
21 | -- Unless required by applicable law or agreed to in writing, software
22 | -- distributed under the License is distributed on an "AS IS" BASIS,
23 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | -- See the License for the specific language governing permissions and
25 | -- limitations under the License.
26 | --
27 | -- Modifications --------------------------------------------------------------
28 | -- The original script has been modified to receive SRSNO and SRSNAME as parameter
29 | -- using the psql "-v" switch instead of prompting for user input.
30 | --
31 | -- Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich
32 | -- b.willenborg@tum.de
33 | -------------------------------------------------------------------------------
34 |
35 | -- This script is called from CREATE_DB.bat
36 | \pset footer off
37 | SET client_min_messages TO WARNING;
38 | \set ON_ERROR_STOP ON
39 |
40 | \echo
41 | --\prompt 'Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin): ' SRS_NO
42 | --\prompt 'Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783): ' GMLSRSNAME
43 |
44 | \set SRSNO :srsno
45 | \set SRSNO :SRS_NO
46 | \set SRS_NO :srsno
47 | \set GMLSRSNAME :gmlsrsname
48 |
49 | -- \echo 'SRSNO ' :'SRSNO'
50 | -- \echo 'SRS_NO ' :SRS_NO
51 | -- \echo 'srsname ' :srsname
52 | -- \echo 'GMLSRSNAME ' :GMLSRSNAME
53 |
54 | --// check if the PostGIS extension is available
55 | SELECT postgis_version();
56 |
57 | --// create TABLES, SEQUENCES, CONSTRAINTS, INDEXES
58 | \echo
59 | \echo 'Setting up database schema of 3DCityDB instance ...'
60 | \i SCHEMA/SCHEMA.sql
61 |
62 | --// fill tables OBJECTCLASS
63 | \i UTIL/CREATE_DB/OBJECTCLASS_INSTANCES.sql
64 |
65 | --// create CITYDB_PKG (additional schema with PL/pgSQL-Functions)
66 | \echo
67 | \echo 'Creating additional schema ''citydb_pkg'' ...'
68 | \i CREATE_CITYDB_PKG.sql
69 |
70 | --// update search_path on database level
71 | ALTER DATABASE :"DBNAME" SET search_path TO citydb,citydb_pkg,public;
72 |
73 | \echo
74 | \echo '3DCityDB creation complete!'
75 |
76 | --// checks if the chosen SRID is provided by the spatial_ref_sys table
77 | \echo
78 | \echo 'Checking spatial reference system ...'
79 | SELECT citydb_pkg.check_srid(:SRS_NO);
80 |
81 | \echo 'Setting spatial reference system of 3DCityDB instance ...'
82 | INSERT INTO citydb.DATABASE_SRS(SRID,GML_SRS_NAME) VALUES (:SRS_NO,:'GMLSRSNAME');
83 | SELECT citydb_pkg.change_schema_srid(:SRS_NO,:'GMLSRSNAME');
84 | \echo 'Done'
85 |
--------------------------------------------------------------------------------
/v3.1.0/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ENV POSTGIS_MAJOR='3'
17 | ARG citydb_version='v3.1.0'
18 | ENV CITYDBVERSION=${citydb_version}
19 |
20 | ARG BUILD_PACKAGES='ca-certificates git'
21 | ARG RUNTIME_PACKAGES="postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
23 | postgis"
24 |
25 | # Setup build and runtime deps
26 | RUN set -x && \
27 | apt-get update && \
28 | apt-get install -y --no-install-recommends $BUILD_PACKAGES $RUNTIME_PACKAGES
29 |
30 | # Create folders
31 | RUN set -x && \
32 | mkdir -p 3dcitydb && \
33 | mkdir -p /docker-entrypoint-initdb.d
34 |
35 | # Clone 3DCityDB
36 | RUN set -x && \
37 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
38 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
39 |
40 | # Cleanup
41 | RUN set -x && \
42 | rm -rf 3dcitydb_temp && \
43 | apt-get purge -y --auto-remove $BUILD_PACKAGES && \
44 | rm -rf /var/lib/apt/lists/*
45 |
46 | # Copy scripts
47 | COPY CREATE_DB.sql /3dcitydb/
48 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
49 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
50 |
51 | # Set permissions
52 | RUN set -ex && \
53 | ln -s usr/local/bin/addcitydb / && \
54 | ln -s usr/local/bin/dropcitydb / && \
55 | ln -s usr/local/bin/purgedb / && \
56 | chmod u+x /usr/local/bin/dropcitydb && \
57 | chmod u+x /usr/local/bin/addcitydb && \
58 | chmod u+x /usr/local/bin/purgedb
59 |
--------------------------------------------------------------------------------
/v3.1.0/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <
13 | -- M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen
14 | --
15 | -- Licensed under the Apache License, Version 2.0 (the "License");
16 | -- you may not use this file except in compliance with the License.
17 | -- You may obtain a copy of the License at
18 | --
19 | -- http://www.apache.org/licenses/LICENSE-2.0
20 | --
21 | -- Unless required by applicable law or agreed to in writing, software
22 | -- distributed under the License is distributed on an "AS IS" BASIS,
23 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | -- See the License for the specific language governing permissions and
25 | -- limitations under the License.
26 | --
27 | -- Modifications --------------------------------------------------------------
28 | -- The original script has been modified to receive SRSNO and SRSNAME as parameter
29 | -- using the psql "-v" switch instead of prompting for user input.
30 | --
31 | -- Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich
32 | -- b.willenborg@tum.de
33 | -------------------------------------------------------------------------------
34 |
35 | -- This script is called from CREATE_DB.bat
36 | \pset footer off
37 | SET client_min_messages TO WARNING;
38 | \set ON_ERROR_STOP ON
39 |
40 | \echo
41 | --\prompt 'Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin): ' SRS_NO
42 | --\prompt 'Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783): ' GMLSRSNAME
43 |
44 | \set SRSNO :srsno
45 | \set SRSNO :SRS_NO
46 | \set SRS_NO :srsno
47 | \set GMLSRSNAME :gmlsrsname
48 |
49 | -- \echo 'SRSNO ' :'SRSNO'
50 | -- \echo 'SRS_NO ' :SRS_NO
51 | -- \echo 'srsname ' :srsname
52 | -- \echo 'GMLSRSNAME ' :GMLSRSNAME
53 |
54 | --// check if the PostGIS extension is available
55 | SELECT postgis_version();
56 |
57 | --// create TABLES, SEQUENCES, CONSTRAINTS, INDEXES
58 | \echo
59 | \echo 'Setting up database schema of 3DCityDB instance ...'
60 | \i SCHEMA/SCHEMA.sql
61 |
62 | --// fill tables OBJECTCLASS
63 | \i UTIL/CREATE_DB/OBJECTCLASS_INSTANCES.sql
64 |
65 | --// create CITYDB_PKG (additional schema with PL/pgSQL-Functions)
66 | \echo
67 | \echo 'Creating additional schema ''citydb_pkg'' ...'
68 | \i CREATE_CITYDB_PKG.sql
69 |
70 | --// update search_path on database level
71 | ALTER DATABASE :"DBNAME" SET search_path TO citydb,citydb_pkg,public;
72 |
73 | \echo
74 | \echo '3DCityDB creation complete!'
75 |
76 | --// checks if the chosen SRID is provided by the spatial_ref_sys table
77 | \echo
78 | \echo 'Checking spatial reference system ...'
79 | SELECT citydb_pkg.check_srid(:SRS_NO);
80 |
81 | \echo 'Setting spatial reference system of 3DCityDB instance ...'
82 | INSERT INTO citydb.DATABASE_SRS(SRID,GML_SRS_NAME) VALUES (:SRS_NO,:'GMLSRSNAME');
83 | SELECT citydb_pkg.change_schema_srid(:SRS_NO,:'GMLSRSNAME');
84 | \echo 'Done'
85 |
--------------------------------------------------------------------------------
/v3.1.0/alpine/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12-alpine'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ARG postgis_version='3.0.0'
17 | ENV POSTGIS_VERSION=${postgis_version}
18 | ARG citydb_version='v3.1.0'
19 | ENV CITYDBVERSION=${citydb_version}
20 |
21 | # Setup fetch deps
22 | RUN set -ex && \
23 | apk update && \
24 | apk add --no-cache --virtual .fetch-deps tar openssl git
25 |
26 | # Create folders
27 | RUN set -ex && \
28 | mkdir -p 3dcitydb && \
29 | mkdir -p /docker-entrypoint-initdb.d
30 |
31 | # Fetch 3DCityDB
32 | RUN set -ex && \
33 | git clone -b "${POSTGIS_VERSION}" --depth 1 https://github.com/postgis/postgis.git postgis_temp && \
34 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
35 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
36 |
37 | # Setup build deps
38 | RUN set -ex && \
39 | apk add --no-cache --virtual .build-deps \
40 | autoconf \
41 | automake \
42 | file \
43 | json-c-dev \
44 | libtool \
45 | libxml2-dev \
46 | make \
47 | perl \
48 | clang-dev \
49 | g++ \
50 | gcc \
51 | gdal-dev \
52 | geos-dev \
53 | llvm10-dev \
54 | proj-dev \
55 | protobuf-c-dev
56 |
57 | # Build PostGIS
58 | RUN set -ex && \
59 | cd postgis_temp && \
60 | ./autogen.sh && \
61 | ./configure && make -j$(nproc) && make install && \
62 | cd ..
63 |
64 | # Setup runtime deps
65 | RUN set -ex && \
66 | apk add --no-cache --virtual .postgis-rundeps \
67 | json-c \
68 | geos \
69 | gdal \
70 | proj \
71 | libstdc++ \
72 | protobuf-c
73 |
74 | # Cleanup
75 | RUN set -ex && \
76 | apk del .fetch-deps .build-deps && \
77 | rm -rf postgis_temp 3dcitydb_temp
78 |
79 | # Copy scripts
80 | COPY CREATE_DB.sql /3dcitydb/
81 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
82 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
83 |
84 | # Set permissions
85 | RUN set -ex && \
86 | ln -s usr/local/bin/addcitydb / && \
87 | ln -s usr/local/bin/dropcitydb / && \
88 | ln -s usr/local/bin/purgedb / && \
89 | chmod u+x /usr/local/bin/dropcitydb && \
90 | chmod u+x /usr/local/bin/addcitydb && \
91 | chmod u+x /usr/local/bin/purgedb
92 |
--------------------------------------------------------------------------------
/v3.1.0/alpine/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v3.1.0/alpine/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v3.1.0/dropcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Drop 3DCityDB ---------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 1 args passed?
11 | if [ "$#" -ne 1 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: dropcitydb CITYDBNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v3.1.0/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v3.2.0/3dcitydb.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # 3DCityDB setup --------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # Warn, if $POSTGRES_USER and $POSTGRES_PASSWORD are at their defaults
11 | if [ -z ${POSTGRES_USER+x} ] || [ "$POSTGRES_USER" = "postgres" ] ; then
12 | export POSTGRES_USER="postgres";
13 | echo
14 | echo "!!! WARNING !!! ################################################################"
15 | echo " POSTGRES_USER is at its default setting."
16 | echo " POSTGRES_USER=${POSTGRES_USER}."
17 | echo " Consider changing the default username for security reasons!"
18 | echo
19 | echo " To change the default POSTGRES_USER, use the docker run \"-e\" switch."
20 | echo " Example: \"docker run -e \"POSTGRES_USER=newuser\" tumgis/3dcitydb-postgis\""
21 | echo "################################################################################"
22 | fi
23 |
24 | # make sure a default non empty password is set
25 | if [ -z ${POSTGRES_PASSWORD+x} ] || [ "$POSTGRES_PASSWORD" = "postgres" ] || [ "$POSTGRES_PASSWORD" = "" ] ; then
26 | export POSTGRES_PASSWORD="postgres";
27 | echo
28 | echo "!!! WARNING !!! ################################################################"
29 | echo " POSTGRES_PASSWORD is at its default setting."
30 | echo " POSTGRES_PASSWORD=${POSTGRES_PASSWORD}."
31 | echo " Consider changing the default password for security reasons!"
32 | echo
33 | echo " To change the default POSTGRES_PASSWORD, use the docker run \"-e\" switch."
34 | echo " Example: \"docker run -e \"POSTGRES_PASSWORD=newuser\" tumgis/3dcitydb-postgis\""
35 | echo "################################################################################"
36 | fi
37 |
38 | # Perform all actions as $POSTGRES_USER with password $POSTGRES_PASSWORD
39 | export PGUSER="$POSTGRES_USER"
40 | export PGPASSWORD="$POSTGRES_PASSWORD"
41 |
42 | # Set default env: POSTGRES_PASSWORD, CITYDBNAME, SRID, SRSNAME
43 | echo
44 | echo "# Setting up tumgis/3dcitydb-postgis environment ... ###########################"
45 | if [ -z ${CITYDBNAME+x} ]; then
46 | export CITYDBNAME="citydb";
47 | echo "NOTE:"
48 | echo " CITYDBNAME has not been set. Using default CITYDBNAME=${CITYDBNAME}."
49 | echo " To change the default CITYDBNAME, use the docker run \"-e\" switch."
50 | echo " Example: \"docker run -e \"CITYDBNAME=myCustomDatabaseName\" tumgis/3dcitydb-postgis\""
51 | fi
52 |
53 | if [ -z ${SRID+x} ]; then
54 | export SRID=4326;
55 | echo
56 | echo "NOTE:"
57 | echo " SRID has not been set. Using default SRID=${SRID}."
58 | echo " To change the default SRID, use the docker run \"-e\" switch."
59 | echo " Example: \"docker run -e \"SRID=31468\" tumgis/3dcitydb-postgis\""
60 | fi
61 |
62 | if [ -z ${SRSNAME+x} ]; then
63 | export SRSNAME="urn:ogc:def:crs:EPSG::4326";
64 | echo
65 | echo "";
66 | echo "NOTE:"
67 | echo " SRSNAME has not been set. Using default SRSNAME=\"${SRSNAME}\"."
68 | echo " To change the default SRSNAME, use the docker run \"-e\" switch."
69 | echo " Example: \"docker run -e \"SRSNAME=urn:adv:crs:DE_DHDN_3GK4*DE_DHN92_NH\" tumgis/3dcitydb-postgis\""
70 | fi
71 |
72 | echo
73 | echo "# Setting up 3DCityDB environment ...done! #####################################"
74 |
75 | # Create database
76 | echo
77 | echo "# Setting up 3DCityDB ... ######################################################"
78 | echo
79 | echo "Creating database $CITYDBNAME ..."
80 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
81 | echo "Creating database $CITYDBNAME ...done!"
82 |
83 | # Setup PostGIS extension
84 | echo
85 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
86 | "${psql[@]}" -d "$CITYDBNAME" <<-EOSQL
87 | CREATE EXTENSION IF NOT EXISTS postgis;
88 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
89 | EOSQL
90 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
91 |
92 | # setup 3dcitydb
93 | echo
94 | echo "Setting up 3DCityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
95 | cd /3dcitydb
96 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
97 | echo "Setting up 3DCityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
98 | echo
99 | echo "# Setting up 3DCityDB ...done! #################################################"
100 |
101 | # echo version info and maintainer
102 | cat <
13 | -- M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen
14 | --
15 | -- Licensed under the Apache License, Version 2.0 (the "License");
16 | -- you may not use this file except in compliance with the License.
17 | -- You may obtain a copy of the License at
18 | --
19 | -- http://www.apache.org/licenses/LICENSE-2.0
20 | --
21 | -- Unless required by applicable law or agreed to in writing, software
22 | -- distributed under the License is distributed on an "AS IS" BASIS,
23 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | -- See the License for the specific language governing permissions and
25 | -- limitations under the License.
26 | --
27 | -- Modifications --------------------------------------------------------------
28 | -- The original script has been modified to receive SRSNO and SRSNAME as parameter
29 | -- using the psql "-v" switch instead of prompting for user input.
30 | --
31 | -- Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich
32 | -- b.willenborg@tum.de
33 | -------------------------------------------------------------------------------
34 |
35 | -- This script is called from CREATE_DB.bat
36 | \pset footer off
37 | SET client_min_messages TO WARNING;
38 | \set ON_ERROR_STOP ON
39 |
40 | \echo
41 | --\prompt 'Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin): ' SRS_NO
42 | --\prompt 'Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783): ' GMLSRSNAME
43 |
44 | \set SRSNO :srsno
45 | \set SRSNO :SRS_NO
46 | \set SRS_NO :srsno
47 | \set GMLSRSNAME :gmlsrsname
48 |
49 | -- \echo 'SRSNO ' :'SRSNO'
50 | -- \echo 'SRS_NO ' :SRS_NO
51 | -- \echo 'srsname ' :srsname
52 | -- \echo 'GMLSRSNAME ' :GMLSRSNAME
53 |
54 | --// check if the PostGIS extension is available
55 | SELECT postgis_version();
56 |
57 | --// create TABLES, SEQUENCES, CONSTRAINTS, INDEXES
58 | \echo
59 | \echo 'Setting up database schema of 3DCityDB instance ...'
60 | \i SCHEMA/SCHEMA.sql
61 |
62 | --// fill tables OBJECTCLASS
63 | \i UTIL/CREATE_DB/OBJECTCLASS_INSTANCES.sql
64 |
65 | --// create CITYDB_PKG (additional schema with PL/pgSQL-Functions)
66 | \echo
67 | \echo 'Creating additional schema ''citydb_pkg'' ...'
68 | \i CREATE_CITYDB_PKG.sql
69 |
70 | --// update search_path on database level
71 | ALTER DATABASE :"DBNAME" SET search_path TO citydb,citydb_pkg,public;
72 |
73 | \echo
74 | \echo '3DCityDB creation complete!'
75 |
76 | --// checks if the chosen SRID is provided by the spatial_ref_sys table
77 | \echo
78 | \echo 'Checking spatial reference system ...'
79 | SELECT citydb_pkg.check_srid(:SRS_NO);
80 |
81 | \echo 'Setting spatial reference system of 3DCityDB instance ...'
82 | INSERT INTO citydb.DATABASE_SRS(SRID,GML_SRS_NAME) VALUES (:SRS_NO,:'GMLSRSNAME');
83 | SELECT citydb_pkg.change_schema_srid(:SRS_NO,:'GMLSRSNAME');
84 | \echo 'Done'
85 |
--------------------------------------------------------------------------------
/v3.2.0/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ENV POSTGIS_MAJOR='3'
17 | ARG citydb_version='v3.2.0'
18 | ENV CITYDBVERSION=${citydb_version}
19 |
20 | ARG BUILD_PACKAGES='ca-certificates git'
21 | ARG RUNTIME_PACKAGES="postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
23 | postgis"
24 |
25 | # Setup build and runtime deps
26 | RUN set -x && \
27 | apt-get update && \
28 | apt-get install -y --no-install-recommends $BUILD_PACKAGES $RUNTIME_PACKAGES
29 |
30 | # Create folders
31 | RUN set -x && \
32 | mkdir -p 3dcitydb && \
33 | mkdir -p /docker-entrypoint-initdb.d
34 |
35 | # Clone 3DCityDB
36 | RUN set -x && \
37 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
38 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
39 |
40 | # Cleanup
41 | RUN set -x && \
42 | rm -rf 3dcitydb_temp && \
43 | apt-get purge -y --auto-remove $BUILD_PACKAGES && \
44 | rm -rf /var/lib/apt/lists/*
45 |
46 | # Copy scripts
47 | COPY CREATE_DB.sql /3dcitydb/
48 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
49 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
50 |
51 | # Set permissions
52 | RUN set -ex && \
53 | ln -s usr/local/bin/addcitydb / && \
54 | ln -s usr/local/bin/dropcitydb / && \
55 | ln -s usr/local/bin/purgedb / && \
56 | chmod u+x /usr/local/bin/dropcitydb && \
57 | chmod u+x /usr/local/bin/addcitydb && \
58 | chmod u+x /usr/local/bin/purgedb
59 |
--------------------------------------------------------------------------------
/v3.2.0/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <
13 | -- M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen
14 | --
15 | -- Licensed under the Apache License, Version 2.0 (the "License");
16 | -- you may not use this file except in compliance with the License.
17 | -- You may obtain a copy of the License at
18 | --
19 | -- http://www.apache.org/licenses/LICENSE-2.0
20 | --
21 | -- Unless required by applicable law or agreed to in writing, software
22 | -- distributed under the License is distributed on an "AS IS" BASIS,
23 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | -- See the License for the specific language governing permissions and
25 | -- limitations under the License.
26 | --
27 | -- Modifications --------------------------------------------------------------
28 | -- The original script has been modified to receive SRSNO and SRSNAME as parameter
29 | -- using the psql "-v" switch instead of prompting for user input.
30 | --
31 | -- Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich
32 | -- b.willenborg@tum.de
33 | -------------------------------------------------------------------------------
34 |
35 | -- This script is called from CREATE_DB.bat
36 | \pset footer off
37 | SET client_min_messages TO WARNING;
38 | \set ON_ERROR_STOP ON
39 |
40 | \echo
41 | --\prompt 'Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin): ' SRS_NO
42 | --\prompt 'Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783): ' GMLSRSNAME
43 |
44 | \set SRSNO :srsno
45 | \set SRSNO :SRS_NO
46 | \set SRS_NO :srsno
47 | \set GMLSRSNAME :gmlsrsname
48 |
49 | -- \echo 'SRSNO ' :'SRSNO'
50 | -- \echo 'SRS_NO ' :SRS_NO
51 | -- \echo 'srsname ' :srsname
52 | -- \echo 'GMLSRSNAME ' :GMLSRSNAME
53 |
54 | --// check if the PostGIS extension is available
55 | SELECT postgis_version();
56 |
57 | --// create TABLES, SEQUENCES, CONSTRAINTS, INDEXES
58 | \echo
59 | \echo 'Setting up database schema of 3DCityDB instance ...'
60 | \i SCHEMA/SCHEMA.sql
61 |
62 | --// fill tables OBJECTCLASS
63 | \i UTIL/CREATE_DB/OBJECTCLASS_INSTANCES.sql
64 |
65 | --// create CITYDB_PKG (additional schema with PL/pgSQL-Functions)
66 | \echo
67 | \echo 'Creating additional schema ''citydb_pkg'' ...'
68 | \i CREATE_CITYDB_PKG.sql
69 |
70 | --// update search_path on database level
71 | ALTER DATABASE :"DBNAME" SET search_path TO citydb,citydb_pkg,public;
72 |
73 | \echo
74 | \echo '3DCityDB creation complete!'
75 |
76 | --// checks if the chosen SRID is provided by the spatial_ref_sys table
77 | \echo
78 | \echo 'Checking spatial reference system ...'
79 | SELECT citydb_pkg.check_srid(:SRS_NO);
80 |
81 | \echo 'Setting spatial reference system of 3DCityDB instance ...'
82 | INSERT INTO citydb.DATABASE_SRS(SRID,GML_SRS_NAME) VALUES (:SRS_NO,:'GMLSRSNAME');
83 | SELECT citydb_pkg.change_schema_srid(:SRS_NO,:'GMLSRSNAME');
84 | \echo 'Done'
85 |
--------------------------------------------------------------------------------
/v3.2.0/alpine/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12-alpine'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ARG postgis_version='3.0.0'
17 | ENV POSTGIS_VERSION=${postgis_version}
18 | ARG citydb_version='v3.2.0'
19 | ENV CITYDBVERSION=${citydb_version}
20 |
21 | # Setup fetch deps
22 | RUN set -ex && \
23 | apk update && \
24 | apk add --no-cache --virtual .fetch-deps tar openssl git
25 |
26 | # Create folders
27 | RUN set -ex && \
28 | mkdir -p 3dcitydb && \
29 | mkdir -p /docker-entrypoint-initdb.d
30 |
31 | # Fetch 3DCityDB
32 | RUN set -ex && \
33 | git clone -b "${POSTGIS_VERSION}" --depth 1 https://github.com/postgis/postgis.git postgis_temp && \
34 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
35 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
36 |
37 | # Setup build deps
38 | RUN set -ex && \
39 | apk add --no-cache --virtual .build-deps \
40 | autoconf \
41 | automake \
42 | file \
43 | json-c-dev \
44 | libtool \
45 | libxml2-dev \
46 | make \
47 | perl \
48 | clang-dev \
49 | g++ \
50 | gcc \
51 | gdal-dev \
52 | geos-dev \
53 | llvm10-dev \
54 | proj-dev \
55 | protobuf-c-dev
56 |
57 | # Build PostGIS
58 | RUN set -ex && \
59 | cd postgis_temp && \
60 | ./autogen.sh && \
61 | ./configure && make -j$(nproc) && make install && \
62 | cd ..
63 |
64 | # Setup runtime deps
65 | RUN set -ex && \
66 | apk add --no-cache --virtual .postgis-rundeps \
67 | json-c \
68 | geos \
69 | gdal \
70 | proj \
71 | libstdc++ \
72 | protobuf-c
73 |
74 | # Cleanup
75 | RUN set -ex && \
76 | apk del .fetch-deps .build-deps && \
77 | rm -rf postgis_temp 3dcitydb_temp
78 |
79 | # Copy scripts
80 | COPY CREATE_DB.sql /3dcitydb/
81 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
82 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
83 |
84 | # Set permissions
85 | RUN set -ex && \
86 | ln -s usr/local/bin/addcitydb / && \
87 | ln -s usr/local/bin/dropcitydb / && \
88 | ln -s usr/local/bin/purgedb / && \
89 | chmod u+x /usr/local/bin/dropcitydb && \
90 | chmod u+x /usr/local/bin/addcitydb && \
91 | chmod u+x /usr/local/bin/purgedb
92 |
--------------------------------------------------------------------------------
/v3.2.0/alpine/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v3.2.0/alpine/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v3.2.0/dropcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Drop 3DCityDB ---------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 1 args passed?
11 | if [ "$#" -ne 1 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: dropcitydb CITYDBNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v3.2.0/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v3.3.0/3dcitydb.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # 3DCityDB setup --------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # Warn, if $POSTGRES_USER and $POSTGRES_PASSWORD are at their defaults
11 | if [ -z ${POSTGRES_USER+x} ] || [ "$POSTGRES_USER" = "postgres" ] ; then
12 | export POSTGRES_USER="postgres";
13 | echo
14 | echo "!!! WARNING !!! ################################################################"
15 | echo " POSTGRES_USER is at its default setting."
16 | echo " POSTGRES_USER=${POSTGRES_USER}."
17 | echo " Consider changing the default username for security reasons!"
18 | echo
19 | echo " To change the default POSTGRES_USER, use the docker run \"-e\" switch."
20 | echo " Example: \"docker run -e \"POSTGRES_USER=newuser\" tumgis/3dcitydb-postgis\""
21 | echo "################################################################################"
22 | fi
23 |
24 | # make sure a default non empty password is set
25 | if [ -z ${POSTGRES_PASSWORD+x} ] || [ "$POSTGRES_PASSWORD" = "postgres" ] || [ "$POSTGRES_PASSWORD" = "" ] ; then
26 | export POSTGRES_PASSWORD="postgres";
27 | echo
28 | echo "!!! WARNING !!! ################################################################"
29 | echo " POSTGRES_PASSWORD is at its default setting."
30 | echo " POSTGRES_PASSWORD=${POSTGRES_PASSWORD}."
31 | echo " Consider changing the default password for security reasons!"
32 | echo
33 | echo " To change the default POSTGRES_PASSWORD, use the docker run \"-e\" switch."
34 | echo " Example: \"docker run -e \"POSTGRES_PASSWORD=newuser\" tumgis/3dcitydb-postgis\""
35 | echo "################################################################################"
36 | fi
37 |
38 | # Perform all actions as $POSTGRES_USER with password $POSTGRES_PASSWORD
39 | export PGUSER="$POSTGRES_USER"
40 | export PGPASSWORD="$POSTGRES_PASSWORD"
41 |
42 | # Set default env: POSTGRES_PASSWORD, CITYDBNAME, SRID, SRSNAME
43 | echo
44 | echo "# Setting up tumgis/3dcitydb-postgis environment ... ###########################"
45 | if [ -z ${CITYDBNAME+x} ]; then
46 | export CITYDBNAME="citydb";
47 | echo "NOTE:"
48 | echo " CITYDBNAME has not been set. Using default CITYDBNAME=${CITYDBNAME}."
49 | echo " To change the default CITYDBNAME, use the docker run \"-e\" switch."
50 | echo " Example: \"docker run -e \"CITYDBNAME=myCustomDatabaseName\" tumgis/3dcitydb-postgis\""
51 | fi
52 |
53 | if [ -z ${SRID+x} ]; then
54 | export SRID=4326;
55 | echo
56 | echo "NOTE:"
57 | echo " SRID has not been set. Using default SRID=${SRID}."
58 | echo " To change the default SRID, use the docker run \"-e\" switch."
59 | echo " Example: \"docker run -e \"SRID=31468\" tumgis/3dcitydb-postgis\""
60 | fi
61 |
62 | if [ -z ${SRSNAME+x} ]; then
63 | export SRSNAME="urn:ogc:def:crs:EPSG::4326";
64 | echo
65 | echo "";
66 | echo "NOTE:"
67 | echo " SRSNAME has not been set. Using default SRSNAME=\"${SRSNAME}\"."
68 | echo " To change the default SRSNAME, use the docker run \"-e\" switch."
69 | echo " Example: \"docker run -e \"SRSNAME=urn:adv:crs:DE_DHDN_3GK4*DE_DHN92_NH\" tumgis/3dcitydb-postgis\""
70 | fi
71 |
72 | echo
73 | echo "# Setting up 3DCityDB environment ...done! #####################################"
74 |
75 | # Create database
76 | echo
77 | echo "# Setting up 3DCityDB ... ######################################################"
78 | echo
79 | echo "Creating database $CITYDBNAME ..."
80 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
81 | echo "Creating database $CITYDBNAME ...done!"
82 |
83 | # Setup PostGIS extension
84 | echo
85 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
86 | "${psql[@]}" -d "$CITYDBNAME" <<-EOSQL
87 | CREATE EXTENSION IF NOT EXISTS postgis;
88 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
89 | EOSQL
90 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
91 |
92 | # setup 3dcitydb
93 | echo
94 | echo "Setting up 3DCityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
95 | cd /3dcitydb
96 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
97 | echo "Setting up 3DCityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
98 | echo
99 | echo "# Setting up 3DCityDB ...done! #################################################"
100 |
101 | # echo version info and maintainer
102 | cat <
13 | -- M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen
14 | --
15 | -- Licensed under the Apache License, Version 2.0 (the "License");
16 | -- you may not use this file except in compliance with the License.
17 | -- You may obtain a copy of the License at
18 | --
19 | -- http://www.apache.org/licenses/LICENSE-2.0
20 | --
21 | -- Unless required by applicable law or agreed to in writing, software
22 | -- distributed under the License is distributed on an "AS IS" BASIS,
23 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | -- See the License for the specific language governing permissions and
25 | -- limitations under the License.
26 | --
27 | -- Modifications --------------------------------------------------------------
28 | -- The original script has been modified to receive SRSNO and SRSNAME as parameter
29 | -- using the psql "-v" switch instead of prompting for user input.
30 | --
31 | -- Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich
32 | -- b.willenborg@tum.de
33 | -------------------------------------------------------------------------------
34 |
35 | -- This script is called from CREATE_DB.bat
36 | \pset footer off
37 | SET client_min_messages TO WARNING;
38 | \set ON_ERROR_STOP ON
39 |
40 | \echo
41 | --\prompt 'Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin): ' SRS_NO
42 | --\prompt 'Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783): ' GMLSRSNAME
43 |
44 | \set SRSNO :srsno
45 | \set SRSNO :SRS_NO
46 | \set SRS_NO :srsno
47 | \set GMLSRSNAME :gmlsrsname
48 |
49 | -- \echo 'SRSNO ' :'SRSNO'
50 | -- \echo 'SRS_NO ' :SRS_NO
51 | -- \echo 'srsname ' :srsname
52 | -- \echo 'GMLSRSNAME ' :GMLSRSNAME
53 |
54 | --// check if the PostGIS extension is available
55 | SELECT postgis_version();
56 |
57 | --// create TABLES, SEQUENCES, CONSTRAINTS, INDEXES
58 | \echo
59 | \echo 'Setting up database schema of 3DCityDB instance ...'
60 | \i SCHEMA/SCHEMA.sql
61 |
62 | --// fill tables OBJECTCLASS
63 | \i UTIL/CREATE_DB/OBJECTCLASS_INSTANCES.sql
64 |
65 | --// create CITYDB_PKG (additional schema with PL/pgSQL-Functions)
66 | \echo
67 | \echo 'Creating additional schema ''citydb_pkg'' ...'
68 | \i CREATE_CITYDB_PKG.sql
69 |
70 | --// update search_path on database level
71 | ALTER DATABASE :"DBNAME" SET search_path TO citydb,citydb_pkg,public;
72 |
73 | \echo
74 | \echo '3DCityDB creation complete!'
75 |
76 | --// checks if the chosen SRID is provided by the spatial_ref_sys table
77 | \echo
78 | \echo 'Checking spatial reference system ...'
79 | SELECT citydb_pkg.check_srid(:SRS_NO);
80 |
81 | \echo 'Setting spatial reference system of 3DCityDB instance ...'
82 | INSERT INTO citydb.DATABASE_SRS(SRID,GML_SRS_NAME) VALUES (:SRS_NO,:'GMLSRSNAME');
83 | SELECT citydb_pkg.change_schema_srid(:SRS_NO,:'GMLSRSNAME');
84 | \echo 'Done'
85 |
--------------------------------------------------------------------------------
/v3.3.0/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ENV POSTGIS_MAJOR='3'
17 | ARG citydb_version='v3.3.0'
18 | ENV CITYDBVERSION=${citydb_version}
19 |
20 | ARG BUILD_PACKAGES='ca-certificates git'
21 | ARG RUNTIME_PACKAGES="postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
23 | postgis"
24 |
25 | # Setup build and runtime deps
26 | RUN set -x && \
27 | apt-get update && \
28 | apt-get install -y --no-install-recommends $BUILD_PACKAGES $RUNTIME_PACKAGES
29 |
30 | # Create folders
31 | RUN set -x && \
32 | mkdir -p 3dcitydb && \
33 | mkdir -p /docker-entrypoint-initdb.d
34 |
35 | # Clone 3DCityDB
36 | RUN set -x && \
37 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
38 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
39 |
40 | # Cleanup
41 | RUN set -x && \
42 | rm -rf 3dcitydb_temp && \
43 | apt-get purge -y --auto-remove $BUILD_PACKAGES && \
44 | rm -rf /var/lib/apt/lists/*
45 |
46 | # Copy scripts
47 | COPY CREATE_DB.sql /3dcitydb/
48 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
49 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
50 |
51 | # Set permissions
52 | RUN set -ex && \
53 | ln -s usr/local/bin/addcitydb / && \
54 | ln -s usr/local/bin/dropcitydb / && \
55 | ln -s usr/local/bin/purgedb / && \
56 | chmod u+x /usr/local/bin/dropcitydb && \
57 | chmod u+x /usr/local/bin/addcitydb && \
58 | chmod u+x /usr/local/bin/purgedb
59 |
--------------------------------------------------------------------------------
/v3.3.0/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <
13 | -- M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen
14 | --
15 | -- Licensed under the Apache License, Version 2.0 (the "License");
16 | -- you may not use this file except in compliance with the License.
17 | -- You may obtain a copy of the License at
18 | --
19 | -- http://www.apache.org/licenses/LICENSE-2.0
20 | --
21 | -- Unless required by applicable law or agreed to in writing, software
22 | -- distributed under the License is distributed on an "AS IS" BASIS,
23 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | -- See the License for the specific language governing permissions and
25 | -- limitations under the License.
26 | --
27 | -- Modifications --------------------------------------------------------------
28 | -- The original script has been modified to receive SRSNO and SRSNAME as parameter
29 | -- using the psql "-v" switch instead of prompting for user input.
30 | --
31 | -- Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich
32 | -- b.willenborg@tum.de
33 | -------------------------------------------------------------------------------
34 |
35 | -- This script is called from CREATE_DB.bat
36 | \pset footer off
37 | SET client_min_messages TO WARNING;
38 | \set ON_ERROR_STOP ON
39 |
40 | \echo
41 | --\prompt 'Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin): ' SRS_NO
42 | --\prompt 'Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783): ' GMLSRSNAME
43 |
44 | \set SRSNO :srsno
45 | \set SRSNO :SRS_NO
46 | \set SRS_NO :srsno
47 | \set GMLSRSNAME :gmlsrsname
48 |
49 | -- \echo 'SRSNO ' :'SRSNO'
50 | -- \echo 'SRS_NO ' :SRS_NO
51 | -- \echo 'srsname ' :srsname
52 | -- \echo 'GMLSRSNAME ' :GMLSRSNAME
53 |
54 | --// check if the PostGIS extension is available
55 | SELECT postgis_version();
56 |
57 | --// create TABLES, SEQUENCES, CONSTRAINTS, INDEXES
58 | \echo
59 | \echo 'Setting up database schema of 3DCityDB instance ...'
60 | \i SCHEMA/SCHEMA.sql
61 |
62 | --// fill tables OBJECTCLASS
63 | \i UTIL/CREATE_DB/OBJECTCLASS_INSTANCES.sql
64 |
65 | --// create CITYDB_PKG (additional schema with PL/pgSQL-Functions)
66 | \echo
67 | \echo 'Creating additional schema ''citydb_pkg'' ...'
68 | \i CREATE_CITYDB_PKG.sql
69 |
70 | --// update search_path on database level
71 | ALTER DATABASE :"DBNAME" SET search_path TO citydb,citydb_pkg,public;
72 |
73 | \echo
74 | \echo '3DCityDB creation complete!'
75 |
76 | --// checks if the chosen SRID is provided by the spatial_ref_sys table
77 | \echo
78 | \echo 'Checking spatial reference system ...'
79 | SELECT citydb_pkg.check_srid(:SRS_NO);
80 |
81 | \echo 'Setting spatial reference system of 3DCityDB instance ...'
82 | INSERT INTO citydb.DATABASE_SRS(SRID,GML_SRS_NAME) VALUES (:SRS_NO,:'GMLSRSNAME');
83 | SELECT citydb_pkg.change_schema_srid(:SRS_NO,:'GMLSRSNAME');
84 | \echo 'Done'
85 |
--------------------------------------------------------------------------------
/v3.3.0/alpine/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12-alpine'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ARG postgis_version='3.0.0'
17 | ENV POSTGIS_VERSION=${postgis_version}
18 | ARG citydb_version='v3.3.0'
19 | ENV CITYDBVERSION=${citydb_version}
20 |
21 | # Setup fetch deps
22 | RUN set -ex && \
23 | apk update && \
24 | apk add --no-cache --virtual .fetch-deps tar openssl git
25 |
26 | # Create folders
27 | RUN set -ex && \
28 | mkdir -p 3dcitydb && \
29 | mkdir -p /docker-entrypoint-initdb.d
30 |
31 | # Fetch 3DCityDB
32 | RUN set -ex && \
33 | git clone -b "${POSTGIS_VERSION}" --depth 1 https://github.com/postgis/postgis.git postgis_temp && \
34 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
35 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
36 |
37 | # Setup build deps
38 | RUN set -ex && \
39 | apk add --no-cache --virtual .build-deps \
40 | autoconf \
41 | automake \
42 | file \
43 | json-c-dev \
44 | libtool \
45 | libxml2-dev \
46 | make \
47 | perl \
48 | clang-dev \
49 | g++ \
50 | gcc \
51 | gdal-dev \
52 | geos-dev \
53 | llvm10-dev \
54 | proj-dev \
55 | protobuf-c-dev
56 |
57 | # Build PostGIS
58 | RUN set -ex && \
59 | cd postgis_temp && \
60 | ./autogen.sh && \
61 | ./configure && make -j$(nproc) && make install && \
62 | cd ..
63 |
64 | # Setup runtime deps
65 | RUN set -ex && \
66 | apk add --no-cache --virtual .postgis-rundeps \
67 | json-c \
68 | geos \
69 | gdal \
70 | proj \
71 | libstdc++ \
72 | protobuf-c
73 |
74 | # Cleanup
75 | RUN set -ex && \
76 | apk del .fetch-deps .build-deps && \
77 | rm -rf postgis_temp 3dcitydb_temp
78 |
79 | # Copy scripts
80 | COPY CREATE_DB.sql /3dcitydb/
81 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
82 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
83 |
84 | # Set permissions
85 | RUN set -ex && \
86 | ln -s usr/local/bin/addcitydb / && \
87 | ln -s usr/local/bin/dropcitydb / && \
88 | ln -s usr/local/bin/purgedb / && \
89 | chmod u+x /usr/local/bin/dropcitydb && \
90 | chmod u+x /usr/local/bin/addcitydb && \
91 | chmod u+x /usr/local/bin/purgedb
92 |
--------------------------------------------------------------------------------
/v3.3.0/alpine/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v3.3.0/alpine/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v3.3.0/dropcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Drop 3DCityDB ---------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 1 args passed?
11 | if [ "$#" -ne 1 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: dropcitydb CITYDBNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v3.3.0/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v3.3.1/CREATE_DB.sql:
--------------------------------------------------------------------------------
1 | -- 3D City Database - The Open Source CityGML Database
2 | -- http://www.3dcitydb.org/
3 | --
4 | -- Copyright 2013 - 2016
5 | -- Chair of Geoinformatics
6 | -- Technical University of Munich, Germany
7 | -- https://www.gis.bgu.tum.de/
8 | --
9 | -- The 3D City Database is jointly developed with the following
10 | -- cooperation partners:
11 | --
12 | -- virtualcitySYSTEMS GmbH, Berlin
13 | -- M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen
14 | --
15 | -- Licensed under the Apache License, Version 2.0 (the "License");
16 | -- you may not use this file except in compliance with the License.
17 | -- You may obtain a copy of the License at
18 | --
19 | -- http://www.apache.org/licenses/LICENSE-2.0
20 | --
21 | -- Unless required by applicable law or agreed to in writing, software
22 | -- distributed under the License is distributed on an "AS IS" BASIS,
23 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | -- See the License for the specific language governing permissions and
25 | -- limitations under the License.
26 | --
27 | -- Modifications --------------------------------------------------------------
28 | -- The original script has been modified to receive SRSNO and SRSNAME as parameter
29 | -- using the psql "-v" switch instead of prompting for user input.
30 | --
31 | -- Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich
32 | -- b.willenborg@tum.de
33 | -------------------------------------------------------------------------------
34 |
35 | -- This script is called from CREATE_DB.bat
36 | \pset footer off
37 | SET client_min_messages TO WARNING;
38 | \set ON_ERROR_STOP ON
39 |
40 | \echo
41 | --\prompt 'Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin): ' SRS_NO
42 | --\prompt 'Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783): ' GMLSRSNAME
43 |
44 | \set SRSNO :srsno
45 | \set SRSNO :SRS_NO
46 | \set SRS_NO :srsno
47 | \set GMLSRSNAME :gmlsrsname
48 |
49 | -- \echo 'SRSNO ' :'SRSNO'
50 | -- \echo 'SRS_NO ' :SRS_NO
51 | -- \echo 'srsname ' :srsname
52 | -- \echo 'GMLSRSNAME ' :GMLSRSNAME
53 |
54 | --// check if the PostGIS extension is available
55 | SELECT postgis_version();
56 |
57 | --// create TABLES, SEQUENCES, CONSTRAINTS, INDEXES
58 | \echo
59 | \echo 'Setting up database schema of 3DCityDB instance ...'
60 | \i SCHEMA/SCHEMA.sql
61 |
62 | --// fill tables OBJECTCLASS
63 | \i UTIL/CREATE_DB/OBJECTCLASS_INSTANCES.sql
64 |
65 | --// create CITYDB_PKG (additional schema with PL/pgSQL-Functions)
66 | \echo
67 | \echo 'Creating additional schema ''citydb_pkg'' ...'
68 | \i CREATE_CITYDB_PKG.sql
69 |
70 | --// update search_path on database level
71 | ALTER DATABASE :"DBNAME" SET search_path TO citydb,citydb_pkg,public;
72 |
73 | \echo
74 | \echo '3DCityDB creation complete!'
75 |
76 | --// checks if the chosen SRID is provided by the spatial_ref_sys table
77 | \echo
78 | \echo 'Checking spatial reference system ...'
79 | SELECT citydb_pkg.check_srid(:SRS_NO);
80 |
81 | \echo 'Setting spatial reference system of 3DCityDB instance ...'
82 | INSERT INTO citydb.DATABASE_SRS(SRID,GML_SRS_NAME) VALUES (:SRS_NO,:'GMLSRSNAME');
83 | SELECT citydb_pkg.change_schema_srid(:SRS_NO,:'GMLSRSNAME');
84 | \echo 'Done'
85 |
--------------------------------------------------------------------------------
/v3.3.1/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ENV POSTGIS_MAJOR='3'
17 | ARG citydb_version='v3.3.1'
18 | ENV CITYDBVERSION=${citydb_version}
19 |
20 | ARG BUILD_PACKAGES='ca-certificates git'
21 | ARG RUNTIME_PACKAGES="postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
23 | postgis"
24 |
25 | # Setup build and runtime deps
26 | RUN set -x && \
27 | apt-get update && \
28 | apt-get install -y --no-install-recommends $BUILD_PACKAGES $RUNTIME_PACKAGES
29 |
30 | # Create folders
31 | RUN set -x && \
32 | mkdir -p 3dcitydb && \
33 | mkdir -p /docker-entrypoint-initdb.d
34 |
35 | # Clone 3DCityDB
36 | RUN set -x && \
37 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
38 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
39 |
40 | # Cleanup
41 | RUN set -x && \
42 | rm -rf 3dcitydb_temp && \
43 | apt-get purge -y --auto-remove $BUILD_PACKAGES && \
44 | rm -rf /var/lib/apt/lists/*
45 |
46 | # Copy scripts
47 | COPY CREATE_DB.sql /3dcitydb/
48 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
49 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
50 |
51 | # Set permissions
52 | RUN set -ex && \
53 | ln -s usr/local/bin/addcitydb / && \
54 | ln -s usr/local/bin/dropcitydb / && \
55 | ln -s usr/local/bin/purgedb / && \
56 | chmod u+x /usr/local/bin/dropcitydb && \
57 | chmod u+x /usr/local/bin/addcitydb && \
58 | chmod u+x /usr/local/bin/purgedb
59 |
--------------------------------------------------------------------------------
/v3.3.1/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <
13 | -- M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen
14 | --
15 | -- Licensed under the Apache License, Version 2.0 (the "License");
16 | -- you may not use this file except in compliance with the License.
17 | -- You may obtain a copy of the License at
18 | --
19 | -- http://www.apache.org/licenses/LICENSE-2.0
20 | --
21 | -- Unless required by applicable law or agreed to in writing, software
22 | -- distributed under the License is distributed on an "AS IS" BASIS,
23 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | -- See the License for the specific language governing permissions and
25 | -- limitations under the License.
26 | --
27 | -- Modifications --------------------------------------------------------------
28 | -- The original script has been modified to receive SRSNO and SRSNAME as parameter
29 | -- using the psql "-v" switch instead of prompting for user input.
30 | --
31 | -- Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich
32 | -- b.willenborg@tum.de
33 | -------------------------------------------------------------------------------
34 |
35 | -- This script is called from CREATE_DB.bat
36 | \pset footer off
37 | SET client_min_messages TO WARNING;
38 | \set ON_ERROR_STOP ON
39 |
40 | \echo
41 | --\prompt 'Please enter a valid SRID (e.g., 3068 for DHDN/Soldner Berlin): ' SRS_NO
42 | --\prompt 'Please enter the corresponding SRSName to be used in GML exports (e.g., urn:ogc:def:crs,crs:EPSG::3068,crs:EPSG::5783): ' GMLSRSNAME
43 |
44 | \set SRSNO :srsno
45 | \set SRSNO :SRS_NO
46 | \set SRS_NO :srsno
47 | \set GMLSRSNAME :gmlsrsname
48 |
49 | -- \echo 'SRSNO ' :'SRSNO'
50 | -- \echo 'SRS_NO ' :SRS_NO
51 | -- \echo 'srsname ' :srsname
52 | -- \echo 'GMLSRSNAME ' :GMLSRSNAME
53 |
54 | --// check if the PostGIS extension is available
55 | SELECT postgis_version();
56 |
57 | --// create TABLES, SEQUENCES, CONSTRAINTS, INDEXES
58 | \echo
59 | \echo 'Setting up database schema of 3DCityDB instance ...'
60 | \i SCHEMA/SCHEMA.sql
61 |
62 | --// fill tables OBJECTCLASS
63 | \i UTIL/CREATE_DB/OBJECTCLASS_INSTANCES.sql
64 |
65 | --// create CITYDB_PKG (additional schema with PL/pgSQL-Functions)
66 | \echo
67 | \echo 'Creating additional schema ''citydb_pkg'' ...'
68 | \i CREATE_CITYDB_PKG.sql
69 |
70 | --// update search_path on database level
71 | ALTER DATABASE :"DBNAME" SET search_path TO citydb,citydb_pkg,public;
72 |
73 | \echo
74 | \echo '3DCityDB creation complete!'
75 |
76 | --// checks if the chosen SRID is provided by the spatial_ref_sys table
77 | \echo
78 | \echo 'Checking spatial reference system ...'
79 | SELECT citydb_pkg.check_srid(:SRS_NO);
80 |
81 | \echo 'Setting spatial reference system of 3DCityDB instance ...'
82 | INSERT INTO citydb.DATABASE_SRS(SRID,GML_SRS_NAME) VALUES (:SRS_NO,:'GMLSRSNAME');
83 | SELECT citydb_pkg.change_schema_srid(:SRS_NO,:'GMLSRSNAME');
84 | \echo 'Done'
85 |
--------------------------------------------------------------------------------
/v3.3.1/alpine/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12-alpine'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ARG postgis_version='3.0.0'
17 | ENV POSTGIS_VERSION=${postgis_version}
18 | ARG citydb_version='v3.3.1'
19 | ENV CITYDBVERSION=${citydb_version}
20 |
21 | # Setup fetch deps
22 | RUN set -ex && \
23 | apk update && \
24 | apk add --no-cache --virtual .fetch-deps tar openssl git
25 |
26 | # Create folders
27 | RUN set -ex && \
28 | mkdir -p 3dcitydb && \
29 | mkdir -p /docker-entrypoint-initdb.d
30 |
31 | # Fetch 3DCityDB
32 | RUN set -ex && \
33 | git clone -b "${POSTGIS_VERSION}" --depth 1 https://github.com/postgis/postgis.git postgis_temp && \
34 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
35 | mv 3dcitydb_temp/PostgreSQL/SQLScripts/* 3dcitydb
36 |
37 | # Setup build deps
38 | RUN set -ex && \
39 | apk add --no-cache --virtual .build-deps \
40 | autoconf \
41 | automake \
42 | file \
43 | json-c-dev \
44 | libtool \
45 | libxml2-dev \
46 | make \
47 | perl \
48 | clang-dev \
49 | g++ \
50 | gcc \
51 | gdal-dev \
52 | geos-dev \
53 | llvm10-dev \
54 | proj-dev \
55 | protobuf-c-dev
56 |
57 | # Build PostGIS
58 | RUN set -ex && \
59 | cd postgis_temp && \
60 | ./autogen.sh && \
61 | ./configure && make -j$(nproc) && make install && \
62 | cd ..
63 |
64 | # Setup runtime deps
65 | RUN set -ex && \
66 | apk add --no-cache --virtual .postgis-rundeps \
67 | json-c \
68 | geos \
69 | gdal \
70 | proj \
71 | libstdc++ \
72 | protobuf-c
73 |
74 | # Cleanup
75 | RUN set -ex && \
76 | apk del .fetch-deps .build-deps && \
77 | rm -rf postgis_temp 3dcitydb_temp
78 |
79 | # Copy scripts
80 | COPY CREATE_DB.sql /3dcitydb/
81 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
82 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
83 |
84 | # Set permissions
85 | RUN set -ex && \
86 | ln -s usr/local/bin/addcitydb / && \
87 | ln -s usr/local/bin/dropcitydb / && \
88 | ln -s usr/local/bin/purgedb / && \
89 | chmod u+x /usr/local/bin/dropcitydb && \
90 | chmod u+x /usr/local/bin/addcitydb && \
91 | chmod u+x /usr/local/bin/purgedb
92 |
--------------------------------------------------------------------------------
/v3.3.1/alpine/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v3.3.1/alpine/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v3.3.1/dropcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Drop 3DCityDB ---------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 1 args passed?
11 | if [ "$#" -ne 1 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: dropcitydb CITYDBNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v3.3.1/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v4.0.0/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ENV POSTGIS_MAJOR='3'
17 | ARG citydb_version='v4.0.0'
18 | ENV CITYDBVERSION=${citydb_version}
19 |
20 | ARG BUILD_PACKAGES='ca-certificates git'
21 | ARG RUNTIME_PACKAGES="postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
23 | postgis"
24 |
25 | # Setup build and runtime deps
26 | RUN set -x && \
27 | apt-get update && \
28 | apt-get install -y --no-install-recommends $BUILD_PACKAGES $RUNTIME_PACKAGES
29 |
30 | # Create folders
31 | RUN set -x && \
32 | mkdir -p 3dcitydb && \
33 | mkdir -p /docker-entrypoint-initdb.d
34 |
35 | # Clone 3DCityDB
36 | RUN set -x && \
37 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
38 | mv 3dcitydb_temp/?ostgre???/SQLScripts/* 3dcitydb
39 |
40 | # Cleanup
41 | RUN set -x && \
42 | rm -rf 3dcitydb_temp && \
43 | apt-get purge -y --auto-remove $BUILD_PACKAGES && \
44 | rm -rf /var/lib/apt/lists/*
45 |
46 | # Copy scripts
47 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
48 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
49 |
50 | # Set permissions
51 | RUN set -ex && \
52 | ln -s usr/local/bin/addcitydb / && \
53 | ln -s usr/local/bin/dropcitydb / && \
54 | ln -s usr/local/bin/purgedb / && \
55 | chmod u+x /usr/local/bin/dropcitydb && \
56 | chmod u+x /usr/local/bin/addcitydb && \
57 | chmod u+x /usr/local/bin/purgedb
58 |
--------------------------------------------------------------------------------
/v4.0.0/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v4.0.0/alpine/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v4.0.0/dropcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Drop 3DCityDB ---------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 1 args passed?
11 | if [ "$#" -ne 1 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: dropcitydb CITYDBNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v4.0.0/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v4.0.1/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ENV POSTGIS_MAJOR='3'
17 | ARG citydb_version='v4.0.1'
18 | ENV CITYDBVERSION=${citydb_version}
19 |
20 | ARG BUILD_PACKAGES='ca-certificates git'
21 | ARG RUNTIME_PACKAGES="postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
23 | postgis"
24 |
25 | # Setup build and runtime deps
26 | RUN set -x && \
27 | apt-get update && \
28 | apt-get install -y --no-install-recommends $BUILD_PACKAGES $RUNTIME_PACKAGES
29 |
30 | # Create folders
31 | RUN set -x && \
32 | mkdir -p 3dcitydb && \
33 | mkdir -p /docker-entrypoint-initdb.d
34 |
35 | # Clone 3DCityDB
36 | RUN set -x && \
37 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
38 | mv 3dcitydb_temp/?ostgre???/SQLScripts/* 3dcitydb
39 |
40 | # Cleanup
41 | RUN set -x && \
42 | rm -rf 3dcitydb_temp && \
43 | apt-get purge -y --auto-remove $BUILD_PACKAGES && \
44 | rm -rf /var/lib/apt/lists/*
45 |
46 | # Copy scripts
47 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
48 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
49 |
50 | # Set permissions
51 | RUN set -ex && \
52 | ln -s usr/local/bin/addcitydb / && \
53 | ln -s usr/local/bin/dropcitydb / && \
54 | ln -s usr/local/bin/purgedb / && \
55 | chmod u+x /usr/local/bin/dropcitydb && \
56 | chmod u+x /usr/local/bin/addcitydb && \
57 | chmod u+x /usr/local/bin/purgedb
58 |
--------------------------------------------------------------------------------
/v4.0.1/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v4.0.1/alpine/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v4.0.1/dropcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Drop 3DCityDB ---------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 1 args passed?
11 | if [ "$#" -ne 1 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: dropcitydb CITYDBNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v4.0.1/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v4.0.2/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ENV POSTGIS_MAJOR='3'
17 | ARG citydb_version='v4.0.2'
18 | ENV CITYDBVERSION=${citydb_version}
19 |
20 | ARG BUILD_PACKAGES='ca-certificates git'
21 | ARG RUNTIME_PACKAGES="postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
23 | postgis"
24 |
25 | # Setup build and runtime deps
26 | RUN set -x && \
27 | apt-get update && \
28 | apt-get install -y --no-install-recommends $BUILD_PACKAGES $RUNTIME_PACKAGES
29 |
30 | # Create folders
31 | RUN set -x && \
32 | mkdir -p 3dcitydb && \
33 | mkdir -p /docker-entrypoint-initdb.d
34 |
35 | # Clone 3DCityDB
36 | RUN set -x && \
37 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
38 | mv 3dcitydb_temp/?ostgre???/SQLScripts/* 3dcitydb
39 |
40 | # Cleanup
41 | RUN set -x && \
42 | rm -rf 3dcitydb_temp && \
43 | apt-get purge -y --auto-remove $BUILD_PACKAGES && \
44 | rm -rf /var/lib/apt/lists/*
45 |
46 | # Copy scripts
47 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
48 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
49 |
50 | # Set permissions
51 | RUN set -ex && \
52 | ln -s usr/local/bin/addcitydb / && \
53 | ln -s usr/local/bin/dropcitydb / && \
54 | ln -s usr/local/bin/purgedb / && \
55 | chmod u+x /usr/local/bin/dropcitydb && \
56 | chmod u+x /usr/local/bin/addcitydb && \
57 | chmod u+x /usr/local/bin/purgedb
58 |
--------------------------------------------------------------------------------
/v4.0.2/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v4.0.2/alpine/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v4.0.2/dropcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Drop 3DCityDB ---------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 1 args passed?
11 | if [ "$#" -ne 1 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: dropcitydb CITYDBNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v4.0.2/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v4.0.3/Dockerfile:
--------------------------------------------------------------------------------
1 | # 3DCityDB PostGIS Dockerfile #################################################
2 | # Official website https://www.3dcitydb.net
3 | # GitHub https://github.com/3dcitydb
4 | ###############################################################################
5 | # Base image
6 | ARG baseimage_tag='12'
7 | FROM postgres:${baseimage_tag}
8 |
9 | # Labels ######################################################################
10 | LABEL maintainer="Bruno Willenborg"
11 | LABEL maintainer.email="b.willenborg(at)tum.de"
12 | LABEL maintainer.organization="Chair of Geoinformatics, Technical University of Munich (TUM)"
13 | LABEL source.repo="https://github.com/tum-gis/3dcitydb-docker-postgis"
14 |
15 | # Setup PostGIS and 3DCityDB ##################################################
16 | ENV POSTGIS_MAJOR='3'
17 | ARG citydb_version='v4.0.3'
18 | ENV CITYDBVERSION=${citydb_version}
19 |
20 | ARG BUILD_PACKAGES='ca-certificates git'
21 | ARG RUNTIME_PACKAGES="postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
23 | postgis"
24 |
25 | # Setup build and runtime deps
26 | RUN set -x && \
27 | apt-get update && \
28 | apt-get install -y --no-install-recommends $BUILD_PACKAGES $RUNTIME_PACKAGES
29 |
30 | # Create folders
31 | RUN set -x && \
32 | mkdir -p 3dcitydb && \
33 | mkdir -p /docker-entrypoint-initdb.d
34 |
35 | # Clone 3DCityDB
36 | RUN set -x && \
37 | git clone -b "${CITYDBVERSION}" --depth 1 https://github.com/3dcitydb/3dcitydb.git 3dcitydb_temp && \
38 | mv 3dcitydb_temp/?ostgre???/SQLScripts/* 3dcitydb
39 |
40 | # Cleanup
41 | RUN set -x && \
42 | rm -rf 3dcitydb_temp && \
43 | apt-get purge -y --auto-remove $BUILD_PACKAGES && \
44 | rm -rf /var/lib/apt/lists/*
45 |
46 | # Copy scripts
47 | COPY 3dcitydb.sh /docker-entrypoint-initdb.d/
48 | COPY addcitydb dropcitydb purgedb /usr/local/bin/
49 |
50 | # Set permissions
51 | RUN set -ex && \
52 | ln -s usr/local/bin/addcitydb / && \
53 | ln -s usr/local/bin/dropcitydb / && \
54 | ln -s usr/local/bin/purgedb / && \
55 | chmod u+x /usr/local/bin/dropcitydb && \
56 | chmod u+x /usr/local/bin/addcitydb && \
57 | chmod u+x /usr/local/bin/purgedb
58 |
--------------------------------------------------------------------------------
/v4.0.3/addcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Create 3DCityDB -------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 3 args passed?
11 | if [ "$#" -ne 3 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: addcitydb CITYDBNAME SRID SRSNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | CITYDBNAME="$1"
19 | SRID="$2"
20 | SRSNAME="$3"
21 |
22 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
23 | if [ -z ${POSTGRES_USER+x} ]; then
24 | export PGUSER=postgres;
25 | else
26 | export PGUSER="$POSTGRES_USER";
27 | fi
28 |
29 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
30 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
31 | export PGPASSWORD=postgres;
32 | else
33 | export PGPASSWORD="$POSTGRES_PASSWORD"
34 | fi
35 |
36 | # check if PGUSER and PGPASS are set
37 | echo
38 | echo "# Setting up 3DCityDB ... ######################################################"
39 | echo "Creating database $CITYDBNAME ..."
40 | echo "CREATE DATABASE \"$CITYDBNAME\";" | "${psql[@]}"
41 | echo "Creating database $CITYDBNAME ... done!"
42 | echo
43 |
44 | # Setup PostGIS extension
45 | echo "Create PostGIS extensions in database $CITYDBNAME ..."
46 | "${psql[@]}" --dbname="$CITYDBNAME" <<-'EOSQL'
47 | CREATE EXTENSION IF NOT EXISTS postgis;
48 | CREATE EXTENSION IF NOT EXISTS postgis_raster;
49 | EOSQL
50 | echo "Create PostGIS extensions in database $CITYDBNAME ...done!"
51 | echo
52 |
53 | # setup 3dcitydb
54 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ..."
55 | cd /3dcitydb
56 | "${psql[@]}" -d "$CITYDBNAME" -f "CREATE_DB.sql" -v srsno="$SRID" -v gmlsrsname="$SRSNAME" > /dev/null
57 | echo "Setting up 3DcityDB version $CITYDBVERSION database schema in $CITYDBNAME ...done!"
58 | echo
59 | echo "# Setting up 3DCityDB ... done! ################################################"
60 |
61 | # echo version info and maintainer
62 | cat <&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v4.0.3/alpine/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------
/v4.0.3/dropcitydb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Drop 3DCityDB ---------------------------------------------------------------
3 |
4 | # Print commands and their arguments as they are executed
5 | set -e;
6 |
7 | # psql should stop on error
8 | psql=( psql -v ON_ERROR_STOP=1 )
9 |
10 | # 1 args passed?
11 | if [ "$#" -ne 1 ]; then
12 | printf "Error: Wrong number of arguments passed.\n"
13 | echo "Usage: dropcitydb CITYDBNAME" >&2
14 | exit 1
15 | fi
16 |
17 | # parse arguments
18 | DBNAME="$1"
19 |
20 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
21 | if [ -z ${POSTGRES_USER+x} ]; then
22 | export PGUSER=postgres;
23 | else
24 | export PGUSER="$POSTGRES_USER";
25 | fi
26 |
27 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
28 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
29 | export PGPASSWORD=postgres;
30 | else
31 | export PGPASSWORD="$POSTGRES_PASSWORD"
32 | fi
33 |
34 | # drop citydb
35 | echo
36 | echo "Dropping database $DBNAME ..."
37 | "${psql[@]}" -d "$DBNAME" -f /3dcitydb/DROP_DB.sql
38 | echo "Dropping database $DBNAME ... done!"
39 |
--------------------------------------------------------------------------------
/v4.0.3/purgedb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Purge 3DCityDB --------------------------------------------------------------
3 |
4 |
5 | # Print commands and their arguments as they are executed
6 | set -e;
7 |
8 | # psql should stop on error
9 | psql=( psql -v ON_ERROR_STOP=1 )
10 |
11 | # 1 args passed?
12 | if [ "$#" -ne 1 ]; then
13 | printf "Error: Wrong number of arguments passed.\n"
14 | echo "Usage: purgedb DBNAME" >&2
15 | exit 1
16 | fi
17 |
18 | # parse arguments
19 | DBNAME="$1"
20 |
21 | # Perform all actions as $POSTGRES_USER if set, else use default user = postgres
22 | if [ -z ${POSTGRES_USER+x} ]; then
23 | export PGUSER=postgres;
24 | else
25 | export PGUSER="$POSTGRES_USER";
26 | fi
27 |
28 | # Use $POSTGRES_PASSWORD if set, else use default password = postgres
29 | if [ -z ${POSTGRES_PASSWORD+x} ]; then
30 | export PGPASSWORD=postgres;
31 | else
32 | export PGPASSWORD="$POSTGRES_PASSWORD"
33 | fi
34 |
35 | # drop citydb
36 | echo
37 | echo "Purging database $DBNAME ..."
38 | echo "DROP DATABASE \"$DBNAME\";" | "${psql[@]}"
39 | echo "Purging database $DBNAME ... done!"
40 |
--------------------------------------------------------------------------------