Skip to content

Commit 838664c

Browse files
committed
added git hooks for alpine version
1 parent 6a4281a commit 838664c

9 files changed

+412
-0
lines changed

alpine/Dockerfile

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# 3DCityDB Web Map Client Dockerfile ###########################################
2+
# Official website https://www.3dcitydb.net
3+
# GitHub https://github.com/3dcitydb/3dcitydb-web-map
4+
###############################################################################
5+
# Base image
6+
ARG baseimage_tag='10-alpine'
7+
FROM node:${baseimage_tag}
8+
# Maintainer ##################################################################
9+
# Bruno Willenborg
10+
# Chair of Geoinformatics
11+
# Department of Civil, Geo and Environmental Engineering
12+
# Technical University of Munich (TUM)
13+
14+
MAINTAINER Bruno Willenborg, Chair of Geoinformatics, Technical University of Munich (TUM) <[email protected]>
15+
16+
# Setup 3DCityDB Web Map Client ###############################################
17+
ARG webmapclient_version='v1.6.0'
18+
RUN set -x && \
19+
apk update && \
20+
apk add --no-cache --virtual .fetch-deps openssl git && \
21+
git clone -b "${webmapclient_version}" --depth 1 https://github.com/3dcitydb/3dcitydb-web-map.git /var/www && \
22+
cd /var/www && \
23+
rm -rf ./.git ./.gitignore ./LICENSE ./README.md ./build.xml \
24+
./node_modules ./server.js $(ls -1 --ignore=ajax-loader.gif --ignore=favicon.png \
25+
--ignore=GPS_off.png --ignore=GPS_on.png --ignore=GPS_on_ori.png --ignore=GPS_on_pos_ori.png \
26+
./theme/img) && \
27+
mkdir -p /var/www/data && \
28+
apk del .fetch-deps
29+
30+
WORKDIR /var/www/
31+
COPY package.json ./
32+
COPY html/* ./
33+
COPY server.js ./
34+
RUN set -x \
35+
&& npm install --production
36+
37+
RUN set -x \
38+
&& chown -R node:node /var/www/
39+
40+
VOLUME /var/www/
41+
USER node
42+
EXPOSE 8000
43+
CMD [ "node", "server.js", "--public"]

alpine/html/CityDBonDocker-big.png

132 KB
Loading

alpine/html/TUM_Logo_blau_rgb_s.svg

+12
Loading

alpine/html/index.html

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>3DCityDB Web-Map-Client Docker</title>
5+
<style>
6+
body {
7+
background-color: #D3D3D3;
8+
font-family: Arial, Helvetica, sans-serif;
9+
#text-align: center;
10+
}
11+
12+
ul {
13+
list-style-type: none;
14+
margin: 0;
15+
padding: 0;
16+
#overflow: hidden;
17+
background-color: #333;
18+
#display:inline-block;
19+
}
20+
21+
li a {
22+
display: block;
23+
color: white;
24+
text-align: center;
25+
padding: 14px 16px;
26+
text-decoration: none;
27+
border-top: 1px solid #bbb;
28+
border-bottom: 1px solid #bbb;
29+
}
30+
31+
li a:hover {
32+
background-color: #111;
33+
}
34+
35+
.container
36+
{
37+
display: flex;
38+
align-items: center;
39+
justify-content: center;
40+
}
41+
42+
.containerimg
43+
{
44+
text-align:center;
45+
align-items: center;
46+
vertical-align: middle;
47+
}
48+
49+
div img {
50+
vertical-align:middle;
51+
}
52+
53+
p.blocktext {
54+
margin-left: auto;
55+
margin-right: auto;
56+
width: 80%;
57+
}
58+
59+
h2, h4 {
60+
margin-left: auto;
61+
margin-right: auto;
62+
text-align: center;
63+
}
64+
65+
#theimg {
66+
height: auto;
67+
width: auto;
68+
max-width: 100px;
69+
}
70+
</style>
71+
</head>
72+
<meta charset="utf-8">
73+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
74+
<body>
75+
<h2>3DCityDB Web-Map-Client Docker</h2>
76+
<div class="containerimg">
77+
<a href="https://www.3dcitydb.org/"><img id="theimg" src="CityDBonDocker-big.png" /></a>
78+
<span style="display:inline-block; width: 10px;"></span>
79+
<a href="https://www.gis.bgu.tum.de/"><img id="theimg" src="TUM_Logo_blau_rgb_s.svg" /></a>
80+
</div>
81+
<h4>Welcome to the 3D City Database (3DCityDB) Web-Map-Client Docker Image!</h4>
82+
<p class="blocktext">To start the <em>3D Web-Map-Client</em>, browse your <em>data directory</em>, or view the <em>examples</em> use the buttons below.
83+
</p>
84+
<p class="blocktext">
85+
Use the data directory listing to copy the required URLs for setting up a Web-Map-Client project using your Browser's <em>"Right click"</em> &rarr; <em>"Copy link address"</em> feature.<br />
86+
How to add data for usage within the 3DCityDB Web-Map-Client to the data directory is described <a href="" target="_blank">here</a>.
87+
</p>
88+
<p class="blocktext">
89+
If you require assistance using the 3DCityDB Web-Map-Client please take a look at the comprehensive documentation available at the official <a target="_blank" href="https://3dcitydb.org/">3DCityDB Homepage</a> or take a look at the <a target="_blank" href="http://www.gis.bgu.tum.de/en/projects/3dcitydb/#c1425">learning material</a>.
90+
The documentation for the <em>3DCityDB Web-Map-Client Docker Image</em> is available on <a href="https://github.com/tum-gis/3dcitydb-web-map-docker" target="_blank">GitHub</a>.
91+
</p>
92+
<div class="container">
93+
<ul>
94+
<li>
95+
<a href="3dwebclient/" target="_blank">3D Web-Map-Client</a>
96+
</li>
97+
<li>
98+
<a href="data/" target="_blank">Data</a>
99+
</li>
100+
<li>
101+
<a href="examples/" target="_blank">Examples</a>
102+
</li>
103+
</ul>
104+
</div>
105+
</body>
106+
</html>

alpine/images/data-listing-01.png

13.4 KB
Loading

alpine/package.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "3d-city-db-web-map-client-docker",
3+
"version": "1.0.0",
4+
"description": "Modified version of the 3DCityDB Web-Map-Client supporting directory listings.",
5+
"homepage": "https://3dcitydb.org/",
6+
"license": "Apache-2.0",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/tum-gis/3dcitydb-web-map-docker"
10+
},
11+
"dependencies": {
12+
"express": "~4.16.x",
13+
"compression": "1.7.3",
14+
"request": "2.87.0",
15+
"yargs": "12.0.1",
16+
"serve-index": "1.9.1"
17+
},
18+
"engines": {
19+
"node": ">=0.10.x"
20+
}
21+
}

alpine/server.js

+203
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
/*
2+
* 3DCityDB-Web-Map
3+
* http://www.3dcitydb.org/
4+
*
5+
* Copyright 2015 - 2017
6+
* Chair of Geoinformatics
7+
* Technical University of Munich, Germany
8+
* https://www.gis.bgu.tum.de/
9+
*
10+
* The 3DCityDB-Web-Map is jointly developed with the following
11+
* cooperation partners:
12+
*
13+
* virtualcitySYSTEMS GmbH, Berlin <http://www.virtualcitysystems.de/>
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+
28+
/**
29+
* A simple JavaScript based HTTP server forked from the cesium-starter-app project at https://github.com/pjcozzi/cesium-starter-app.
30+
**/
31+
32+
(function() {
33+
"use strict";
34+
/*global console,require,__dirname,process*/
35+
/*jshint es3:false*/
36+
37+
var express = require('express');
38+
var compression = require('compression');
39+
var url = require('url');
40+
var request = require('request');
41+
var serveIndex = require('serve-index');
42+
43+
var yargs = require('yargs').options({
44+
'port' : {
45+
'default' : 8000,
46+
'description' : 'Port to listen on.'
47+
},
48+
'public' : {
49+
'type' : 'boolean',
50+
'description' : 'Run a public server that listens on all interfaces.'
51+
},
52+
'upstream-proxy' : {
53+
'description' : 'A standard proxy server that will be used to retrieve data. Specify a URL including port, e.g. "http://proxy:8000".'
54+
},
55+
'bypass-upstream-proxy-hosts' : {
56+
'description' : 'A comma separated list of hosts that will bypass the specified upstream_proxy, e.g. "lanhost1,lanhost2"'
57+
},
58+
'help' : {
59+
'alias' : 'h',
60+
'type' : 'boolean',
61+
'description' : 'Show this help.'
62+
}
63+
});
64+
var argv = yargs.argv;
65+
66+
if (argv.help) {
67+
return yargs.showHelp();
68+
}
69+
70+
// eventually this mime type configuration will need to change
71+
// https://github.com/visionmedia/send/commit/d2cb54658ce65948b0ed6e5fb5de69d022bef941
72+
var mime = express.static.mime;
73+
mime.define({
74+
'application/json' : ['czml', 'json', 'geojson', 'topojson'],
75+
'model/vnd.gltf+json' : ['gltf'],
76+
'model/vnd.gltf.binary' : ['bgltf'],
77+
'text/plain' : ['glsl']
78+
});
79+
80+
var app = express();
81+
app.use(compression());
82+
app.use(express.static(__dirname));
83+
app.use('/data', express.static('data'), serveIndex('data', {'icons': true, 'view': 'details'}));
84+
85+
app.use('/examples', express.static('examples'), serveIndex('examples', {'icons': true, 'view': 'details'}));
86+
87+
88+
function getRemoteUrlFromParam(req) {
89+
var remoteUrl = req.params[0];
90+
if (remoteUrl) {
91+
// add http:// to the URL if no protocol is present
92+
if (!/^https?:\/\//.test(remoteUrl)) {
93+
remoteUrl = 'http://' + remoteUrl;
94+
}
95+
remoteUrl = url.parse(remoteUrl);
96+
// copy query string
97+
remoteUrl.search = url.parse(req.url).search;
98+
}
99+
return remoteUrl;
100+
}
101+
102+
var dontProxyHeaderRegex = /^(?:Host|Proxy-Connection|Connection|Keep-Alive|Transfer-Encoding|TE|Trailer|Proxy-Authorization|Proxy-Authenticate|Upgrade)$/i;
103+
104+
function filterHeaders(req, headers) {
105+
var result = {};
106+
// filter out headers that are listed in the regex above
107+
Object.keys(headers).forEach(function(name) {
108+
if (!dontProxyHeaderRegex.test(name)) {
109+
result[name] = headers[name];
110+
}
111+
});
112+
return result;
113+
}
114+
115+
var upstreamProxy = argv['upstream-proxy'];
116+
var bypassUpstreamProxyHosts = {};
117+
if (argv['bypass-upstream-proxy-hosts']) {
118+
argv['bypass-upstream-proxy-hosts'].split(',').forEach(function(host) {
119+
bypassUpstreamProxyHosts[host.toLowerCase()] = true;
120+
});
121+
}
122+
123+
app.get('/proxy/*', function(req, res, next) {
124+
// look for request like http://localhost:8080/proxy/http://example.com/file?query=1
125+
var remoteUrl = getRemoteUrlFromParam(req);
126+
if (!remoteUrl) {
127+
// look for request like http://localhost:8080/proxy/?http%3A%2F%2Fexample.com%2Ffile%3Fquery%3D1
128+
remoteUrl = Object.keys(req.query)[0];
129+
if (remoteUrl) {
130+
remoteUrl = url.parse(remoteUrl);
131+
}
132+
}
133+
134+
if (!remoteUrl) {
135+
return res.status(400).send('No url specified.');
136+
}
137+
138+
if (!remoteUrl.protocol) {
139+
remoteUrl.protocol = 'http:';
140+
}
141+
142+
var proxy;
143+
if (upstreamProxy && !(remoteUrl.host in bypassUpstreamProxyHosts)) {
144+
proxy = upstreamProxy;
145+
}
146+
147+
// encoding : null means "body" passed to the callback will be raw bytes
148+
149+
request.get({
150+
url : url.format(remoteUrl),
151+
headers : filterHeaders(req, req.headers),
152+
encoding : null,
153+
proxy : proxy
154+
}, function(error, response, body) {
155+
var code = 500;
156+
157+
if (response) {
158+
code = response.statusCode;
159+
res.header(filterHeaders(req, response.headers));
160+
}
161+
162+
res.status(code).send(body);
163+
});
164+
});
165+
166+
var server = app.listen(argv.port, argv.public ? undefined : 'localhost', function() {
167+
console.log('Cesium development server running publicly. Connect to localhost:%d/', server.address().port);
168+
});
169+
170+
server.on('error', function (e) {
171+
if (e.code === 'EADDRINUSE') {
172+
console.log('Error: Port %d is already in use, select a different port.', argv.port);
173+
console.log('Example: node server.js --port %d', argv.port + 1);
174+
} else if (e.code === 'EACCES') {
175+
console.log('Error: This process does not have permission to listen on port %d.', argv.port);
176+
if (argv.port < 1024) {
177+
console.log('Try a port number higher than 1024.');
178+
}
179+
}
180+
console.log(e);
181+
process.exit(1);
182+
});
183+
184+
server.on('close', function() {
185+
console.log('Cesium development server stopped.');
186+
});
187+
188+
var isFirstSig = true;
189+
process.on('SIGINT', function() {
190+
if (isFirstSig) {
191+
console.log('Cesium development server shutting down.');
192+
server.close(function() {
193+
process.exit(0);
194+
});
195+
isFirstSig = false;
196+
} else {
197+
console.log('Cesium development server force kill.');
198+
process.exit(1);
199+
}
200+
});
201+
202+
})();
203+

0 commit comments

Comments
 (0)