Skip to content
Marc Romeyn edited this page Jul 20, 2015 · 3 revisions

Architecture

UML diagram of the components:

 Client ----- frontend ----- Rails server ← [msg passing] → Algorithm  
  		                         |
  	                          Postgres

Stack

Server-side:

  • Ruby on Rails
    • ActiveRecord ORM
  • Passenger
  • Postgres

TODO: Add why we chose those technologies

Algorithm-side:

  • Scala
  • SBT
  • Spray

TODO: Add why we chose those technologies

Infrastructure

There are two ways to run the project: either by running a regular installation on the local machine or by using Docker. We added support for Docker to allow for easier deploys: if a version runs on our development computers (in Docker), then it will also run on the production server.

Starting Docker Installing and running the environment on Docker is as easy as executing the following commands:

Setup: only the first time

$ git clone https://github.com/juancroca/ios.git .
$ sudo apt-get install docker docker-compose

Run

$ docker-compose build
$ docker-compose up -d

Running Docker on a Mac requires a little more user interaction. OSX does not natively support some of the kernel features Docker needs. To avoid this, one can run Docker inside a Linux virtual machine. The common way to do this is by using boot2docker. For further explanation and installation details (which may change), we refer to the site: FILL IN SITE

When issuing these commands, the latest versions of the server and algorithm are fetched from Github, installed in Docker images and started. The first time one runs these commands, all dependencies have to be downloaded, which can take quite a while. After that, the cache is used and everything runs faster.

Notice that we pass a “-d” flag; this starts Compose in daemon mode, meaning that the process will continue after the current user has logged out.

Stopping Docker

To stop docker, simply issue the following command:

$ docker-compose stop

Note that this only works in the root directory of the project. Docker-compose requires the configuration files (docker-compose.yml and the Dockerfile files) to work, which it can’t find if these commands are issued from another folder.

Deploying new versions

To fetch a new version of the server, we have to fetch and merge the new version from github:

$ git fetch && git pull

To run it, execute:

$ docker-compose build
$ docker-compose up

This will automatically kill any older versions that may be running and replace them with the updated versions. Also, this will automatically update the algorithm: our startup scripts always fetch the latest version.

View running instances To see whether all containers are up and running:

$ docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e2361743cf36 ios_ruby:latest "/sbin/my_init" 31 minutes ago Up 2 seconds 0.0.0.0:80->80/tcp, 443/tcp ios_ruby_1
305afbcf932e ios_scala:latest "sbt run jetty" 31 minutes ago Up 3 seconds 8080/tcp ios_scala_1
9993ee424f3b postgres:latest "/docker-entrypoint. 32 minutes ago Up 15 seconds 5432/tcp ios_db_1

Docker vs. local installation Communication in Docker (hosts file & passing return address)

Clone this wiki locally