Skip to content

Commit

Permalink
refactor and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
justb4 committed Apr 26, 2016
1 parent 6d2039f commit 94bdb46
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 28 deletions.
4 changes: 4 additions & 0 deletions docker/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ sudo chmod 777 /var/smartem/log/etl

# Postfix: choose Local System
sudo apt-get install postfix

# Set timezone right
sudo dpkg-reconfigure tzdata

# view tail -f /va
# The rest
# Github
Expand Down
31 changes: 30 additions & 1 deletion docs/platform/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,34 @@ This chapter describes the (software) architecture of the Smart Emission Data Pl
Docker
======

`Docker <https://www.docker.com>`_ **...allows you to package an application with all of its dependencies into a standardized unit for software development.**.
`Docker <https://www.docker.com>`_ is the main building block for the SE Data Platform deployment architecture.

`Docker <https://www.docker.com>`_
*...allows you to package an application with all of its dependencies into a standardized unit for software development.*.
Read more on https://docs.docker.com.

The details of Docker are not discussed here, there are ample sources on the web. One of the best,
if not the best, introductory books on Docker is `The Docker Book <https://www.dockerbook.com>`_.

Docker Strategy
---------------

Like in Object Oriented Design there are still various strategies and patterns to follow with Docker.
There is a myriad of choices how to define Docker Images, configure and run Containers etc.
Within the SE Platform the following strategies are followed:

* define only generic/reusable Docker Images, i.e. without SE-specific config/functions
* let each Docker image perform a single (server) task: Apache2, GeoServer, PostGIS, 52NSOS etc.
* keep all configuration, data, logfiles and dynamic data outside Docker container on the Docker host
* at runtime provision the Docker Container with local mappings to data, ports and other Docker containers

Docker Containers
-----------------

The following Docker Containers are deployed. Also their related Docker Image is listed.

* ``web`` - web and webapps, proxy to backend - image: ``geonovum/apache2''
* ``postgis`` - PostgreSQL w PostGIS - image: ``kartoza/postgis:9.4-2.1``
* ``stetl`` - All ETL tasks - image: ``geonovum/stetl``
* ``geoserver`` - GeoServer web app - image: ``kartoza/geoserver`` (TBD)
* ``sos52`` - 52NOrth SOS web app: ``kartoza/geoserver`` (TBD)
34 changes: 17 additions & 17 deletions docs/platform/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,15 @@ Some handly Docker commands: ::
# go into docker image named apache2 to bash prompt
sudo docker exec -it apache2 bash

Docker Images
-------------
Docker Containers
-----------------

Below the Docker images: how they are built/acquired and how they are run using local mappings, data and configs.
Below the Docker Containers: how their generic Docker Images are built/acquired and how they are run using local mappings, data and configs.

PostGIS
~~~~~~~
postgis - PostGIS Database
~~~~~~~~~~~~~~~~~~~~~~~~~~

PostGIS Docke image from Kartoza (Tim Sutton, QGIS lead),
Uses PostGIS Docker image from Kartoza (Tim Sutton, QGIS lead),
see https://hub.docker.com/r/kartoza/postgis/ and https://github.com/kartoza/docker-postgis ::

$ sudo docker pull kartoza/postgis:9.4-2.1
Expand All @@ -320,8 +320,8 @@ This shorthand script ``~/git/services/postgis/run-postgis.sh`` will (re)run the
.. literalinclude:: ../../services/postgis/run-postgis.sh
:language: bash

ETL - Last Measurements
~~~~~~~~~~~~~~~~~~~~~~~
stetl - ETL for Measurements
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Uses the ``geonovum/stetl`` image with Stetl config from GitHub. ::

Expand All @@ -342,31 +342,31 @@ local ETL-config and PostGIS:
:language: bash


Apache2
~~~~~~~
web - Web Container
~~~~~~~~~~~~~~~~~~~

Uses the generic ``geonovum/apache2`` image from GitHub. It contains the standard Apache2 server with various
modules enabled to be able to run Python and act as a proxy to bachend service. To build: ::
Uses the generic ``geonovum/apache2`` Docker Image from GitHub. It contains the standard Apache2 server with various
modules enabled to be able to run Python and act as a proxy to backend services. To build: ::

# build apache2 image
cd ~/git/docker/apache2
sudo docker build -t geonovum/apache2 .

The Bash-script at ``~/git/services/apache2/run-apache2.sh`` will re(run) the generic
The Bash-script at ``~/git/services/web/run-web.sh`` will re(run) the generic
Apache2 Docker image with mappings to local directories of the host for the Apache2 config, webcontent and logfiles.
It will also link to the PostGIS container (for the Flask Python app):
It will also link to the PostGIS Container (for the Flask Python app):

.. literalinclude:: ../../services/apache2/run-apache2.sh
.. literalinclude:: ../../services/web/run-web.sh
:language: bash

To run locally, e.g. with Vagrant, hardcode the DNS mapping in ``/etc/hosts`` : ::

127.0.0.1 local.smartemission.nl
127.0.0.1 local.api.smartemission.nl
127.0.0.1 local.data.smartemission.nl

Inspect logfiles within the host ``/var/smartem/log/apache2`` : ::

tail -f /var/smartem/log/apache2/api.smartem-error.log
tail -f /var/smartem/log/apache2/data.smartem-error.log

Debugging, start/stop Apache quickly within container: ::

Expand Down
8 changes: 4 additions & 4 deletions services/web/api/sosrest/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ <h2>HTML Rendering</h2>
<h2>Web Applicatie</h2>
<p>
Deze web applicatie is geschreven in Python met het lichtgewicht <a href="http://flask.pocoo.org/">Flask web-framework</a>. Zie ook de
<a href="https://github.com/Geonovum/sospilot/tree/master/src/smartem/sosrest/webapp">webapp code in GitHub</a>.
<a href="https://github.com/Geonovum/smartemission/tree/master/services/web/api/sosrest">webapp code in GitHub</a>.
</p>

<h2>JSONP Support</h2>
<p>
JSONP support is via the <strong>callback</strong> parameter, for example:
<a href="http://api.smartemission.nl/sosemu/api/v1/stations?callback=mycallback">http://api.smartemission.nl/sosemu/api/v1/stations?callback=mycallback</a>
<a href="/sosemu/api/v1/stations?callback=mycallback">http://data.smartemission.nl/sosemu/api/v1/stations?callback=mycallback</a>
</p>

<h2>Voorbeeld</h2>
Expand All @@ -47,8 +47,8 @@ <h2>Voorbeeld</h2>
</p>
<ul>
<li>
<a href="http://rawgit.com/Geonovum/smartemission/master/specs/sosrest-api/examples/leaflet.html">Leaflet Voorbeeld (gebruikt JSONP)</a>
en de <a href="https://github.com/Geonovum/smartemission/blob/master/specs/sosrest-api/examples/leaflet.html">code uit GitHub</a>
<a href="http://rawgit.com/Geonovum/smartemission/master/docs/specs/sosrest-api/examples/leaflet.html">Leaflet Voorbeeld (gebruikt JSONP)</a>
en de <a href="https://github.com/Geonovum/smartemission/tree/master/docs/specs/sosrest-api/examples/leaflet.html">code uit GitHub</a>
</li>
</ul>

Expand Down
14 changes: 9 additions & 5 deletions services/web/site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@
</head>
<body>
<div class="container">
<h1>Smart Emission</h1>
<h1>Smart Emission - Data Platform</h1>
<p>Dit is het Smart Emission Data Platform. Deze levert toegang tot de data uit de Smart Emission sensoren
via web services (web APIs) en een aantal apps.
Deze site en onderliggende diensten is ontwikkeld door <a href="http://Geonovum.nl">Geonovum</a>
en draait binnen het <a href="http://fiware-lab.nl">Fiware Lab NL</a>.
</p>
<p>
<i>"Het Smart Emission project draait om het in kaart brengen van luchtkwaliteit, geluid,
trillingen en meteorologische indicatoren in de stad op een fijnmazig schaalniveau,
door inwoners met zogenoemde burger-sensor-netwerken."</i> (Bron: <a
href="http://www.ru.nl/gpm/onderzoek/smart-emission-website/">SE-Website</a>)

</p>
<h2>Apps</h2>
<ul>
Expand All @@ -51,17 +55,17 @@ <h2>Apps</h2>
</ul>
<h2>APIs</h2>
<ul>
<li><a href="http://api.smartemission.nl/sosemu">SOS REST API</a> - JSON/HTML REST API voor laatste waarden</li>
<li><a href="sosemu">SOS REST API</a> - JSON/HTML REST API voor laatste waarden</li>
</ul>
<h2>Documentatie</h2>
<ul>
<li><a href="http://smartplatform.readthedocs.org/en/latest/">Smart Emission Data Platform</a> - technische documentatie Data Platform</li>
<li><a href="http://smartplatform.readthedocs.org/en/latest/">Smart Emission Data Platform</a> - Technische documentatie Data Platform</li>
</ul>
<h2>Links</h2>
<ul>
<li><a href="http://www.ru.nl/gpm/onderzoek/smart-emission-website/">Web Site</a></li>
<li><a href="http://www.ru.nl/gpm/onderzoek/research-projects/smart-emission">Project Info</a></li>
<li><a href="https://github.com/Geonovum/smartemission">Code</a></li>
<li><a href="https://github.com/Geonovum/smartemission">Code op GitHub</a></li>
</ul>
</div>
<!-- Bootstrap core JavaScript
Expand Down
3 changes: 2 additions & 1 deletion services/web/site/smartapp/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ $(document).ready(function () {
}

// URL of the Smart Emission SOS REST API
var apiUrl = 'http://api.smartemission.nl/sosemu/api/v1';
//var apiUrl = 'http://api.smartemission.nl/sosemu/api/v1';
var apiUrl = '/sosemu/api/v1';

// See http://stackoverflow.com/questions/11916780/changing-getjson-to-jsonp
// Notice the callback=? . This triggers a JSONP call
Expand Down

0 comments on commit 94bdb46

Please sign in to comment.