Skip to content

Deployment

Tim Baccaert edited this page Jul 24, 2017 · 14 revisions

Since we're using Docker, it's actually quite trivial to deploy the entire application for production. There are two containers running simultaneously: db and server. The db container contains a PostgreSQL database containing our Database Schema. And the server container contains the Django HTTP server running on port 8000.

Installing the containers with docker-compose

First of all, make sure your server is correctly setup with user accounts secured with ssh keys, disabled root login through ssh and added a basic firewall. You can use this guide from DigitalOcean - Initial Server Setup. You also need to install a version of Docker, which is demonstrated in this guide from DigitalOcean - How To Install and Use Docker.

The first step is to clone the latest release to your server, it's advised you place it in some location where other users can access it too. We can also set up some additional permissions.

$ sudo addgroup lopeningent-dev
$ sudo adduser <your-name-here> lopeningent-dev
$ sudo mkdir /opt/lopeningent
$ sudo chown <your-name-here>:lopeningent-dev /opt/lopeningent
$ sudo chmod 770 /opt/lopeningent
$ sudo git pull https://github.com/oSoc17/lopeningent_backend.git /opt/lopeningent

After this is done, you should have a group lopeningent-dev to which you can add users if you want to give them access to the /opt/lopeningent folder containing the latest source code of the project.

Now we can build the containers by doing the following:

$ cd /opt/lopeningent
$ docker-compose build

Once that's done we need to populate the database with the latest OSM data, there's a script for that! We can run the update.sh command inside the server container's /opt/lig-data folder, which holds the /data folder in our project.

$ docker-compose run server /opt/lig-data/update.sh

There's a big chance there will be some error when trying to populate the database, might be because the database hasn't been loaded yet. If that's the case you can try the command a second time, after that it should work.

Finally, you can start the server for the first time by using the following command. Additionally you can do it in detached mode (in the background) by using the -d flag.

$ docker-compose up -d

Might fail the first time, again, you can just run in twice and it should work.

Partners

imec - IDLab - Ghent University

Clone this wiki locally