Skip to content

Deployment Guide

Luke Vincent edited this page Jul 2, 2024 · 3 revisions

New Environment

Requirements/Dependencies

Install Docker

Follow instructions here

Configure Logging

Suggested to use journald to store all the logs locally.

Update the docker daemon file to set the Logging Driver to use journald instead of storing in json files. The daemon.json file can be found in /etc/Docker/ directory, if it doesn't exist then create it.

{
  "log-driver": "journald"
}

Restart Docker

Logs can now be accessed using the following command, for example. You can replace backend-api with any container name

sudo journalctl CONTAINER_NAME=backend-api

Liquibase

Liquibase is a tool that allows for easy creation and updating of databases via some chargelog files. It can automatically migrate a database to the latest version.

To install liquibase, copy across and run the install_liquibase.sh script found in deployment/database

This will also install the dependencies required to install liquibase to work with mongoDb if required

  • Java
  • cUrl
  • mongoDb plugins

Setup NGINX

This is the webserver that controls access to the various container run services

Install NGINX

Run the following commands to install NGINX on Ubuntu

sudo apt update
sudo apt install nginx

When finished you should be able to hit port 80 on the server and see a template NGINX page, if you do NGINX has been successfully installed.

Create server files

Create a file to config the reverse proxy. Call the file vairify and create it in /etc/nginx/sites-available/

Copy the following into the file

server {
        server_name vairify;

        listen 80;

        location /api/ {
                proxy_pass http://localhost:8000/;
        }

        location / {
                proxy_pass http://localhost:8001/;
        }
}

This opens up two endpoints to the outside world on port 80.

The first listed is /api/ which is where the API endpoints will be hosted that the main UI requires. These requests get re-directed to port 8000 locally The second is for the UI, anything that hits the base URI will get directed to port 8001 locally and will return the UI.

Python

Run the following commands to install python

sudo apt update && sudo apt upgrade
sudo apt install python3-pip
sudo apt install python3-venv

Run deploy script

Create directory mkdir /usr/config/

Run the github action deploy ssh on to the server and run in /usr/config

sudo docker compose stop
sudo docker compose up db -d

The mongo database should now be running in a container

Configuring database

Run Liquibase

Copy liquibase directory found at deployment/database

Create file liquibase.properties and add url property

i.e. url: mongodb://localhost:27017/air_quality_dashboard_db

Run liquibase update --changelog-file master_changelog.xml

Run seed script

Copy from deployment/database to the server the files

add_cities_to_locations.py
CAMS_locations_V1.csv
seed_database_locations.sh

Run the seed_database_locations.sh shell script

Run everything

in /usr/config run to start the remaining services

sudo docker compose up -d

Deploy Changes

When a change has been made to one of the services and it needs deploying to server run the following github actions

  • run the relavant github action to create new image of updated service
  • run deploy github action

vAirify Wiki

Home

Getting Started and Overview

Investigations and Notebooks

Testing

Manual Test Charters

Clone this wiki locally