Guide: Deploying Services - Jaron-U/GIS-based-Analysis-Tool-for-Disaster-Recovery GitHub Wiki

Overview

This guide documents how we deployed an instance of the Open-Routing Service (which we used for routing computation) as well as how we deployed the web-map. Below you can see a crude ascii diagram of our basic tech-stack (ascii diagram generated with the help of ASCIIflow)

Basically, our web-services comprised of two docker containers behind an nginx proxy which we ran on a Digital Ocean droplet (Linux cloud VM).

┌──────────────────────────────────────────────────────────────────────────────┐
│                                                                              │
│     ┌─────────────────────────┐                   Digital Ocean Droplet      │
│     │                         │                                              │
│     │ nginx docker container  │                                              │
│     │  ┌─────────────────┐    │                                              │
│     │  │ web-map (flask) │    │                                              │
│     │  └─────────────────┘    │                                              │
│     │                         │                                              │
│     └─────────────────────┬───┘                                              │
│                           │                        ┌────────────┐            │
│                           └────────────────────────►            │            │
│                                                    │   nginx    │            │
│                           ┌────────────────────────►            │            │
│                           │                        └────────────┘            │
│                           │                                                  │
│     ┌─────────────────────┴───┐                                              │
│     │                         │                                              │
│     │                         │                                              │
│     │   Open Routing Service  │                                              │
│     │                         │                                              │
│     │                         │                                              │
│     └─────────────────────────┘                                              │
│                                                                              │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

Infrastructure (VM Config)

For our use-case, we deployed our software on a Digital Ocean Droplet with about 2GB of memory and otherwise minimum specifications (approximately $12 per month). However, any server which you can setup nginx & docker should work for deployment purposes.

For setting up the open-routing service, the amount of allotted memory matters a significant bit for how much data you want the service to handle (since all the computed graph data mostly resides in memory). The Open Routing Service has some good explanations here about the proper system requirements, but for our use-case, we could configure the software to run with the data extract of Oregon (205 MB) with about 1.7 GB of memory in use by the service.

UFW

We used ufw (the default ubuntu firewall utility) to open/close ports for our VM so we could minimize the open ports on our machine. We enabled only ports 22 (for ssh) 8080 (where we served the open-routing-service) and 443 (for https). The article linked here explains the intricacies of using the utility.

Open Routing Service

For setting up the Open Routing Service, we relied on the already existing documentation on how to setup the service using Docker.

For our data-extract, we just used the state of Oregon extract provided by Geofabick here.

Web-Map

For our web-map, we used a pre-configured nginx-uWSGI docker image to easily get the web-map running on our cloud VM. The basic deployment process we used went as follows:

  1. git clone https://github.com/Jaron-U/GIS-based-Analysis-Tool-for-Disaster-Recovery and then git pull (for any subsequent changes we pushed to the code-base)

  2. built the image docker build . -t webmap

  3. Then created the docker container with docker run -d -p 127.0.0.1:9955:80 webmap

Nginx Proxy Setup

After we had the web-map running, we configured nginx as a reverse-proxy to forward the open-routing-service and our web-map to ports 443 and 8080.

We registered a domain name (safer-ways.com for about $12/year) and then configured a DNS record for map.safer-ways.com to map to our cloud VM's IP address.

To enable HTTPS (which we needed for the Browser Geolocation API to work) we used certbot to automatically configure it.