Skip to content

Commit fea07f0

Browse files
committed
Reworked build and deploy using TravisCI
1 parent c4767e6 commit fea07f0

File tree

3 files changed

+172
-61
lines changed

3 files changed

+172
-61
lines changed

.travis.yml

+48-43
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,62 @@ services:
55
- docker
66

77
env:
8-
# debian versions
9-
- webmapclient_version: v1.1.0
10-
baseimage_tag: 10
11-
tag: v1.1.0
12-
dockerfile: .
13-
- webmapclient_version: v1.4.0
14-
baseimage_tag: 10
15-
tag: v1.4.0
16-
dockerfile: .
17-
- webmapclient_version: v1.6.0
18-
baseimage_tag: 10
19-
tag: v1.6.0
20-
dockerfile: .
21-
- webmapclient_version: master
22-
baseimage_tag: 10
23-
tag: experimental
24-
dockerfile: .
25-
# alpine versions
26-
- webmapclient_version: v1.1.0
27-
baseimage_tag: 10-alpine
28-
tag: v1.1.0-alpine
29-
dockerfile: alpine
30-
- webmapclient_version: v1.4.0
31-
baseimage_tag: 10-alpine
32-
tag: v1.4.0-alpine
33-
dockerfile: alpine
34-
- webmapclient_version: v1.6.0
35-
baseimage_tag: 10-alpine
36-
tag: v1.6.0-alpine
37-
dockerfile: alpine
38-
- webmapclient_version: master
39-
baseimage_tag: 10-alpine
40-
tag: experimental-alpine
41-
dockerfile: alpine
8+
global:
9+
- repo_name=tumgis
10+
- image_name=3dcitydb-web-map
4211

43-
before_install:
44-
- docker build --build-arg baseimage_tag=${baseimage_tag} --build-arg webmapclient_webmapclient_version=${webmapclient_version} -t tumgis/3dcitydb-web-map:${tag} ${dockerfile}
12+
matrix:
13+
# debian versions
14+
- webmapclient_version: v1.1.0
15+
baseimage_tag: 10
16+
tag: v1.1.0
17+
dockerfile: .
18+
- webmapclient_version: v1.4.0
19+
baseimage_tag: 10
20+
tag: v1.4.0
21+
dockerfile: .
22+
- webmapclient_version: v1.6.0
23+
baseimage_tag: 10
24+
tag: v1.6.0,latest
25+
dockerfile: .
26+
- webmapclient_version: master
27+
baseimage_tag: 10
28+
tag: experimental
29+
dockerfile: .
30+
# alpine versions
31+
- webmapclient_version: v1.1.0
32+
baseimage_tag: 10-alpine
33+
tag: v1.1.0
34+
dockerfile: alpine
35+
- webmapclient_version: v1.4.0
36+
baseimage_tag: 10-alpine
37+
tag: v1.4.0
38+
dockerfile: alpine
39+
- webmapclient_version: v1.6.0
40+
baseimage_tag: 10-alpine
41+
tag: v1.6.0,latest
42+
dockerfile: alpine
43+
- webmapclient_version: master
44+
baseimage_tag: 10-alpine
45+
tag: experimental
46+
dockerfile: alpine
4547

4648
before_script:
47-
- docker run --name webcl -d -p 8000:8000 tumgis/3dcitydb-web-map:${tag}
49+
- chmod +x ./travis.sh
50+
- ./travis.sh build
51+
- ./travis.sh runContainer
4852

4953
script:
5054
- sleep 3
5155
- docker logs webcl
52-
- curl "http://127.0.0.1:8000/3dwebclient/" -s | grep '<title>3DCityDB-Web-Map-Client</title>'
53-
54-
after_success:
55-
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
56-
- docker push tumgis/3dcitydb-web-map:${tag}
57-
56+
- curl "http://127.0.0.1:8000/3dwebclient/" -s | grep '<title>3DCityDB-Web-Map-Client</title>'
57+
- ./travis.sh deploy
58+
59+
after_script:
60+
- ./travis.sh cleanup
61+
5862
notifications:
5963
slack: tum-gis:Z32lHXJDXaycOn4643NHSXaT
6064
on_success: change
6165
on_failure: always
66+

README.md

+39-18
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,49 @@
11
[![Build Status](https://img.shields.io/travis/tum-gis/3dcitydb-web-map-docker/master.svg?label=master)](https://travis-ci.org/tum-gis/3dcitydb-web-map-docker) [![Build Status](https://img.shields.io/travis/tum-gis/3dcitydb-web-map-docker/devel.svg?label=devel)](https://travis-ci.org/tum-gis/3dcitydb-web-map-docker)
2+
23
# 3D City Database Web Map Client Docker image
4+
35
This repo contains a Dockerfile for the [3D City Database Web-Map-Client (3D web client)](https://github.com/3dcitydb/3dcitydb-web-map/) based on the official [Node.js Docker images](https://hub.docker.com/_/node/). To get the 3D web client Docker images visit the [tumgis/3dcitydb-web-map](https://hub.docker.com/r/tumgis/3dcitydb-web-map/) DockerHub page. To get things moving fast take a look the *Quick start* section.
46

57
#### Special features
8+
69
* *Landing page* and *data listing* for convenient 3D web client project creation
710

811
#### Image versions/tags
9-
* **latest** - Latest stable version based on latest version of the 3D web client. Built from [master](https://github.com/tum-gis/3dcitydb-web-map-docker/tree/master) branch.
12+
13+
A list of all available tag is available on DockerHub [tumgis/3dcitydb-web-map/tags](https://hub.docker.com/r/tumgis/3dcitydb-web-map/tags/).
14+
The image tags are compose of several tokens, that are explained below:
15+
16+
* **latest** - Latest stable version based on latest stable release of the 3D web client. Built from [master](https://github.com/tum-gis/3dcitydb-web-map-docker/tree/master) branch.
1017
* **devel** - Development version containing latest features. Built from [devel](https://github.com/3dcitydb/3dcitydb-web-map/tree/devel) branch.
11-
* **experimental** - Development version containing latest features. Built from the latest commit of the [3DCityDB Web-Map-Client Github master branch](https://github.com/3dcitydb/3dcitydb-web-map/tree/master).
12-
* **v1.1.0**, **v1.4.0**, **v1.6.0** - Same content as **latest** image, but built with a specific version (**vX.X.X**) of the 3DCityDB Web-Map-Client.
18+
* **alpine** - Lightweight image version based on [Alpine Linux](https://alpinelinux.org/). All other images use the Debian operating system.
19+
* **experimental** - This version is built from the latest commit of the [3DCityDB Web-Map-Client Github master branch](https://github.com/3dcitydb/3dcitydb-web-map/tree/master).
20+
* **v1.1.0**, **v1.4.0**, **v1.6.0** -Built with a specific version (**vX.X.X**) of the 3DCityDB Web-Map-Client.
1321

14-
Use `docker pull tumgis/3dcitydb-web-map:TAG` to download the latest version of the image with the specified `TAG` to your system. For example: `docker pull tumgis/3dcitydb-web-map:v1.4.0`.
22+
Use `docker pull tumgis/3dcitydb-web-map:TAG` to download the latest version of the image with the specified `TAG` to your system. For example: `docker pull tumgis/3dcitydb-web-map:v1.6.0`.
1523

1624
#### More 3DCityDB Docker Images
25+
1726
Check out the Docker images for the *3D City Database* and the *3D City Database Web Feature Service (WFS)* too:
18-
* [3DCityDB Docker image](https://github.com/tum-gis/3dcitydb-postgis-docker/)
27+
28+
* [3DCityDB Docker image](https://github.com/tum-gis/3dcitydb-postgis-docker/)
1929
* [3DCityDB Web Feature Service (WFS) image](https://github.com/tum-gis/3dcitydb-wfs-docker/)
2030

21-
> **Note:** Everything in this repo is in development stage.
31+
> **Note:** Everything in this repo is in development stage.
2232
> If you experience any problems or have a suggestion/improvement please let me know by creating an issue [here](https://github.com/tum-gis/3dcitydb-web-map-docker/issues).
2333
2434
## What is the 3DCityDB-Web-Map-Client
35+
2536
The **3DCityDB-Web-Map-Client** is a web-based front-end of the 3DCityDB for high-performance 3D visualization and interactive exploration of **arbitrarily large semantic 3D city models in CityGML**. It utilizes the [Cesium Virtual Globe](http://cesiumjs.org/index.html) as its 3D geo-visualization engine based on HTML5 and Web Graphics Library (WebGL) to provide hardware acceleration and cross-platform functionalities like displaying 3D graphic contents on web browsers without the needs of additional plugins.
2637

27-
The key features and functionalities of the 3DCityDB-Web-Map-Client is summarized as follows:
38+
The key features and functionalities of the 3DCityDB-Web-Map-Client is summarized as follows:
2839

2940
* Support for efficient displaying, caching, prefetching, dynamic loading and unloading of large pre-styled 3D visualization models in the form of tiled KML/glTF datasets exported from the 3DCityDB using the Importer/Exporter
3041
* Intuitive user interface for adding and removing arbitrary number of data layers like 3D visualization model (KML/glTF), WMS imagery layer, and Cesium digital terrain model
3142
* Support for linking the 3D visualization models (KML/glTF) with the cloud-based Google Fusion Table allowing for querying the thematic data of every 3D object
3243
* Support for rich interaction with 3D visualization models (KML/glTF), for example, highlighting of 3D objects on mouseover and mouseclick as well as hiding and showing of the selected 3D objects
33-
* Support for exploring a 3D object of interest from different view perspectives using third-party mapping services like Microsoft Bing Maps with oblique view, Google Streetview, and a combined version (DualMaps)
44+
* Support for exploring a 3D object of interest from different view perspectives using third-party mapping services like Microsoft Bing Maps with oblique view, Google Streetview, and a combined version (DualMaps)
3445
* Support for on-the-fly activating and deactivating shadow visualization of 3D objects (only for glTF, KML is currently not supported yet) and Cesium digital terrain models
35-
* Support for collaborative creation and sharing of the workspace of the 3DCityDB-Web-Map-Client by means of generating a scene link including information about the current camera perspective, activation status of the shadow visualization, parameters of the current loaded data layers etc.
46+
* Support for collaborative creation and sharing of the workspace of the 3DCityDB-Web-Map-Client by means of generating a scene link including information about the current camera perspective, activation status of the shadow visualization, parameters of the current loaded data layers etc.
3647

3748
![3DCityDB](https://www.3dcitydb.org/3dcitydb/fileadmin/default/templates/images/logo.jpg "3DCityDB logo")
3849
> [3DCityDB Official Homepage](https://www.3dcitydb.net/)
@@ -41,22 +52,28 @@ The key features and functionalities of the 3DCityDB-Web-Map-Client is summarize
4152
> [3DCityDB and CityGML Hands-on Tutorial](https://www.gis.bgu.tum.de/en/projects/3dcitydb/#c1425)
4253
4354
## Quick start
55+
4456
This section describes how to get a 3DCityDB-Web-Map-Client container running as quick and easy as possible.
57+
4558
1. Install Docker on your system.
4659
This step is mandatory. Downloads and detailed instructions for various operating systems can be found here: [https://docs.docker.com/install/](https://docs.docker.com/install/)
4760
2. Run the 3D web client Docker images using [`docker run`](https://docs.docker.com/engine/reference/commandline/run/). Use the `-p <host port:docker port>` switch to specify on which port the 3D web client will listen on your host system. For instance, use `-p 80:8000` if you want to access the 3D web client on the default *http port=80*.
48-
```bash
49-
docker run -dit --name 3dwebmap-container -p 80:8000 tumgis/3dcitydb-web-map
50-
```
61+
62+
```bash
63+
docker run -dit --name 3dwebmap-container -p 80:8000 tumgis/3dcitydb-web-map
64+
```
65+
5166
3. As soon as the container has started, the 3D web client will be available on your Docker host with any common Web Browser. If you run the container locally with above port settings, the landing page is available here:
5267
[http://localhost/](http://localhost/) or [http://127.0.0.1/](http://127.0.0.1/)
5368

5469
## Hosting data AND the 3D web client
70+
5571
The 3DCityDB-Web-Map-Client Docker image allows you to host the data you want to use in the client. All data, that is visible to the `/var/www/data/` directory of a running 3D web client container will be listed in the *data listing* and can be used in the client to create web visualizations. The best way to make data available to that directory is by using a so called [bind mount](https://docs.docker.com/storage/bind-mounts/) where a *host directory* is mapped to a *container directory*. Checkout this overview on Docker's [data storge and persistence](https://github.com/tum-gis/3dcitydb-docker-postgis#data-storage-and-persistence) for more insight on *bind mounts* and other possible options.
5672
5773
The following example will explain how to host the 3DCityDB-Web-Map-Client and an example data set.
5874
We assume you have created some *glTF* data for testing using the [3DCityDB Importer/Exporter](https://www.3dcitydb.org/3dcitydb/d3dimpexp/). If this is not the case, a test dataset is available [here](https://github.com/3dcitydb/3dcitydb-web-map/tree/master/examples/glTFRailwaySceneLoD3Example/Railway_Scene_LoD3). For this example we assume the test dataset is stored at `/home/docker/data/` on your docker host:
59-
```
75+
76+
```text
6077
$ ls -lh /home/docker/data/
6178
6279
-rw-r--r-- 1 root root 9.1K Mar 15 18:36 Railway_Scene_LoD3.json
@@ -65,23 +82,26 @@ $ ls -lh /home/docker/data/
6582
drwxr-xr-x 3 root root 4.0K Mar 15 18:36 Tiles
6683
6784
```
85+
6886
To start a 3DCityDB-Web-Map-Client Docker container and *bind mount* the `/home/docker/data/` host directory to the `/var/www/data/` container directory run:
6987
7088
```bash
7189
docker run -dit --name 3dwebmap-container -p 80:8000 \
72-
-v /home/docker/data/:/var/www/data/ \
90+
-v /home/docker/data/:/var/www/data/ \
7391
tumgis/3dcitydb-web-map
7492
```
7593
7694
> **Note:**
77-
> In the example above long commands are broken to several lines for readability using the Bash (` \ `) or CMD (`^`) line continuation.
95+
> In the example above long commands are broken to several lines for readability using the Bash (`\`) or CMD (`^`) line continuation.
7896
7997
The data is now available in the data listing (e.g. `http://myDockerHost/data/`). Use your Browser's *Copy Link Address* feature to copy the URLs required in the 3D web client.
8098

8199
![Data listing view](https://github.com/tum-gis/3dcitydb-web-map-docker/blob/master/images/data-listing-01.png)
82100

83101
## How to build
102+
84103
To build a 3DCityDB-Web-Map-Client Docker image from the Dockerfile in this repo you need to download the source code from this repo and run the [`docker build`](https://docs.docker.com/engine/reference/commandline/build/) command. Follow the step below to build a 3DCityDB-Web-Map-Client Docker image or use the [`build.sh`](https://github.com/tum-gis/3dcitydb-web-map-docker/blob/master/build.sh) script.
104+
85105
```bash
86106
# 1. Download source code using git
87107
git clone https://github.com/tum-gis/3dcitydb-web-map-docker
@@ -91,9 +111,10 @@ cd 3dcitydb-web-map-docker
91111
docker build -t tumgis/3dcitydb-web-map .
92112
```
93113

94-
If the build succeeds, you are ready to run the image as described above. To list all locally available images run [`docker images`](https://docs.docker.com/engine/reference/commandline/images/).
114+
If the build succeeds, you are ready to run the image as described above. To list all locally available images run [`docker images`](https://docs.docker.com/engine/reference/commandline/images/).
95115

96116
### Build parameters
117+
97118
To build a Docker image with a custom *Tomcat base image*, a specific *3DCityDB WFS version*, or a custom *web app context path*, the [`docker build --build-arg`](https://docs.docker.com/engine/reference/commandline/build/) parameter is used.
98119

99120
| Parameter name | Description | Default value |
@@ -103,12 +124,12 @@ To build a Docker image with a custom *Tomcat base image*, a specific *3DCityDB
103124

104125
> **Note:**
105126
> The build process has been tested with the `node:10` base image and `v1.6.0` of the 3DCityDB-Web-Map-Client so far.
106-
127+
107128
Build example:
129+
108130
```bash
109131
docker build \
110132
--build-arg "baseimage_tag=9-slim" \
111133
--build-arg "webmapclient_version=master" \
112134
-t tumgis/3dcitydb-web-map:9-slim-master .
113135
```
114-

travis.sh

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
#------------------------------------------------------------------------------
3+
# FUNCTIONS -------------------------------------------------------------------
4+
#------------------------------------------------------------------------------
5+
6+
# compose Docker image tag ----------------------------------------------------
7+
getTag() {
8+
temp=""
9+
10+
# find tag prefix: master -> "", devel -> "devel"
11+
if [[ "$TRAVIS_BRANCH" == "devel" ]]; then
12+
temp="devel-"
13+
fi
14+
15+
os=""
16+
# determine os debian -> "", alpine -> "alpine"
17+
if [[ "$dockerfile" == "alpine" ]]; then
18+
temp="${temp}alpine-"
19+
fi
20+
21+
# append tag
22+
temp="${temp}${1}"
23+
echo "$temp"
24+
}
25+
26+
# compose full image name (repo + image name + tag) ---------------------------
27+
getImageName() {
28+
echo "${repo_name}/${image_name}:$(getTag ${1})"
29+
}
30+
31+
# build Docker image ----------------------------------------------------------
32+
build() {
33+
# build image
34+
docker build --build-arg baseimage_tag=${baseimage_tag} \
35+
--build-arg webmapclient_version=${webmapclient_version} \
36+
-t "temp:temp" \
37+
${dockerfile}
38+
}
39+
40+
# run Docker container --------------------------------------------------------
41+
runContainer() {
42+
docker run --name webcl -d -p 8000:8000 "temp:temp"
43+
}
44+
45+
# deploy ----------------------------------------------------------------------
46+
deploy() {
47+
# deploy if not a pull request and branch is master or devel
48+
if [[ "$TRAVIS_PULL_REQUEST" == "false" && \
49+
( "$TRAVIS_BRANCH" == "master" || "$TRAVIS_BRANCH" == "devel" ) ]]; then
50+
51+
# login to docker hub
52+
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
53+
54+
# create tags and push to docker hub
55+
for str in ${tag//,/ } ; do
56+
docker tag "temp:temp" "$(getImageName ${str})"
57+
docker push "$(getImageName ${str})"
58+
done
59+
fi
60+
}
61+
62+
# cleanup ---------------------------------------------------------------------
63+
cleanup() {
64+
docker rm -fv webcl
65+
docker rmi -f "temp:temp"
66+
# create tags and remove images
67+
for str in ${tag//,/ } ; do
68+
docker rmi -f "$(getImageName ${str})"
69+
done
70+
}
71+
72+
#------------------------------------------------------------------------------
73+
# MAIN SCRIPT -----------------------------------------------------------------
74+
#------------------------------------------------------------------------------
75+
76+
# Check if the function exists (bash specific)
77+
if declare -f "$1" > /dev/null
78+
then
79+
# call arguments verbatim
80+
"$@"
81+
else
82+
# Show a helpful error
83+
echo "'$1' is not a known function name" >&2
84+
exit 1
85+
fi

0 commit comments

Comments
 (0)