Skip to content

CMS Installation

Grace Amondi edited this page May 10, 2021 · 4 revisions

The Mukau CMS hosts the Mukau East Africa drought observatory pages. Mukau Drought Observatory is a near-real time system that uses Earth Observation and Weather information to monitor drought conditions in the East Africa region. The Mukau pages contain drought-relevant information such as maps of indicators derived from different data sources (e.g., precipitation measurements, satellite measurements, modelled soil moisture content). Different tools, like Graphs and Compare Layers, allow for displaying and analysing the information and drought reports give an overview of the situation in case of imminent droughts.

It uses a Wagtail based content management system to manage all the content for its website. Wagtail is an open-source CMS written in Python and built on the Django framework. For indepth detail about the Mukau CMS go to Content Management System Documentation CMS .

This section describes the installation steps for the Mukau CMS component as a standalone. It also describes the steps inorder to push any changes made to the Mukau entrypoint.

Required Software

In order to install Mukau, the following softwares need to be installed first:

Mukau requires docker in order to function. Follow these instructions to install docker on Windows, and these instructions to install docker on Mac OS. If you are running Linux, follow the instructions on this page that are appropriate for the Linux distribution you are using.

Table of Contents

Introduction

The Mukau CMS hosts the Mukau East Africa drought observatory pages. Mukau Drought Observatory is a near-real time system that uses Earth Observation and Weather information to monitor drought conditions in the East Africa region. The Mukau pages contain drought-relevant information such as maps of indicators derived from different data sources (e.g., precipitation measurements, satellite measurements, modelled soil moisture content). Different tools, like Graphs and Compare Layers, allow for displaying and analysing the information and drought reports give an overview of the situation in case of imminent droughts.

THe system is a service developed as part of the Intra-ACP Climate Services Project in collaboration with the Drought Unit at the Joint Research Centre of the European Commision. THe system is an adaptation of the European Drought Observatory (EDO) adapted to the conditions in the East Africa region.

Installation

1. Clone the Repository

git clone https://github.com/icpac-igad/mukau-cms.git

2. Create .env file

To create a .env file at the root of the project execute:

cp .env.sample .env

The .env file expects the following Environment Variables:

Variable Description
PROTOCOL e.g http, https
HOST_IP IP address eg. 127.0.0.1
POSTGRES_USER_CMS cms postgres user
POSTGRES_DB_CMS cms database name
POSTGRES_HOST_CMS host for cms postgres
POSTGRES_PASSWORD_CMS password for the postgres cms database
POSTGRES_PORT_CMS cms postgres port
CMS_PORT port the cms will run on
DATABASE set to postgres
RECAPTCHA_PUBLIC_KEY
RECAPTCHA_PRIVATE_KEY
WEB_IMAGE_URI The web production image to use. This should be the URI to the image on a local or remote private registry, with the version tag e.g localhost:5000/mukau-cms:1.0

You can view the available tags for mukau-cms image at https://eahazardswatch.icpac.net/v2/mukau-cms/tags/list. This requires authentication.

3. Create a .env.prod.db file

At the root of mukau-cms execute,

cp .env.prod.db.sample .env.prod.db

The .env.prod.db file is utilized by mukau_cms_db container in the docker-compose.yml file and expects the following Environmental Variables. N.B These variables should match with those specified in the env.prod file

POSTGRES_DB=>

POSTGRES_USER=>

POSTGRES_PASSWORD=>

4. Build Docker Image

To build the docker image, run:

sudo docker-compose build

5. Start Docker Compose (in the background)

sudo docker-compose up -d

6. Migrate CMS Models (Database Tables)

sudo docker-compose exec mukau_cms_web web python manage.py migrate

7. Populate CMS Database with fixtures

sudo docker-compose exec mukau_cms_web python manage.py loaddata datadump.json

The application should now be running at http:<ip_address>:<CMS_PORT>

The CMS Admin interface can be accessed at http:<ip_address>:<CMS_PORT>/admin. Default credentials are:

Username: admin

Password: mukau@cms


Deploy Latest Development (Local) updates to Staging/Production

1. Update .env

Change the WEB_IMAGE_URI tag version in the .env file to a higher version. The convension used is that version numbers ending in an odd number (for example 1.1) are development versions, while versions ending in an even number (for example (1.2) are release versions.

For example, set this variable in the production .env:

WEB_IMAGE_URI=localhost:5000/mukau-cms:1.0

2. Build Docker Image

To build the docker image, run:

sudo docker-compose -f docker-compose-dev.yml build

3. Push New Image to private registry

Mirror local tag (MUKAU-GEOCMS) with the remote tag(MUKAU-DOCKER).

sudo docker tag <local_tag> <remote_tag>

For example:

sudo docker tag localhost:5000/mukau-cms:1.0 eahazardswatch.icpac.net/mukau-cms:1.0 

Next, login to the eahazardswatch.icpac.net registry, execute the command below and provide appropriate credentials.

sudo docker login eahazardswatch.icpac.net

Push the new image to the private registry, run:

sudo docker push <remote_tag>

For example,

sudo docker push eahazardswatch.icpac.net/mukau-cms:1.0 

Other Commands

Monitor logs

To view the status of the database, run:

sudo docker logs mukau_cms_db -f

To view the status of the mukau_cms_web app, run:

sudo docker logs mukau_cms_web -f

Making Updates

To update the application, for example after changing the WEB_IMAGE_URI variable in .env file just run again:

sudo docker-compose stop

then

sudo docker-compose up

Stop and Clean Docker

To stop and remove everything including volumes run (reset). NOTE: This will result in lose of any data save to the database

sudo docker-compose down --volumes

Access database on cmd

docker exec -it <DB_CONTAINER> psql -U <DB_USER> <DB_NAME> 

Backup postgres table

sudo docker exec -it <DB_CONTAINER> pg_dump -U <DB_USER> -t <DB_TABLE> <DB_NAME> > 'path_to_ouput.sql'

Backup postgres database

docker exec -t <DB_CONTAINER> pg_dumpall -c -U <DB_USER> | gzip > ./tmp/dump_$(date +"%Y-%m-%d_%H_%M_%S").gz

Restore database backups

gunzip < your_dump.sql.gz | docker exec -i <DB_CONTAINER> psql -U <DB_USER> -d <DB_NAME>

Access Docker Containers

Access to the running container (mukau_cms_web or any container name, the one defined in docker-compose.yml)

docker exec -it <CONTAINER> bash

Clone this wiki locally