Skip to content

Service docs.inasafe.org

Tim Sutton edited this page Jun 9, 2016 · 3 revisions

This is a configuration description template. Copy and paste the contents below into a new page and then fill out the details in each section as needed. The page you create should be named in the format: service-<url> e.g. service-inasafe.org. Be sure to add an entry to the service list page too at Service Directory.

Overview

Please see Service Directory for an overview of all running services.

This page describes how to setup and deploy a fresh instance of the docs.inasafe.org service

Pre-requisites

We assume the following:

  • user doing configuration has sudo rights
  • user doing configuration is in the docker group
  • git is installed on the host
  • nginx is installed on the host
  • docker is installed on the host
  • docker-compose is installed on the host

Add any other assumptions above.

Setup procedure

Add a list of bash commands here used to successfully setup and configure the service.

# going to serve from /home/data
mkdir /home/data
cd /home/data

# docs.inasafe.org == master branch == live
# git clone in a directory with the same name as the service: docs.inasafe.org
sudo git clone https://github.com/inasafe/inasafe-doc.git docs.inasafe.org

# make sure sources are writable for docker group
sudo chown -R root:docker docs.inasafe.org/
sudo chmod -R g+w docs.inasafe.org/
cd docs.inasafe.org
git checkout master
cd /home/data/docs.inasafe.org
# to check if all is ok, just build the english html
# this will pull the smaller qgis/sphinx_html image from docker hub
docker-compose run --rm html en
# you can also run the full docker command:
docker run -t -i -v /home/data/docs.inasafe.org:/inasafe-doc/ -w=/inasafe-doc --rm=true qgis/sphinx_html ./scripts/post_translate.sh en

# if all is ok, run a pdf build for ALL languages 
# this will pull (only if not already available) the rather big image qgis/sphinx_pdf from docker hub:
docker-compose run --rm pdf
# output will be in docs/output/html and docs/output/pdf

# create an nginx config
sudo cd /etc/nginx/sites-available
touch docs.inasafe.org.nginx.conf
# add the following into it:
---
server {
    listen 80;

    server_name docs.inasafe.org;
    root /home/data/docs.inasafe.org/docs/output/html;
    index index.html index.htm;

    # RD: redirecting / or /LANG to the index.html. Without it no text in header
    rewrite ^/$ /en/index.html redirect;
    rewrite ^/en/$ /en/index.html redirect;
    rewrite ^/id/$ /id/index.html redirect;
    rewrite ^/fr/$ /fr/index.html redirect;

    location / {
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }
}
---

cd ../sites-enabled
sudo ln -s ../sites-available/docs.inasafe.org.nginx.conf

# and check if all is ok:
sudo nginx -t

If the final command above shows the nginx configuration is without errors then do:

sudo /etc/init.d/nginx reload

to rebuild the docs.inasafe.org service once every hour, add a line like below to cron (via crontab -e)

# below will rebuild the service twice a day, creating a rolling log of 30 days in /tmp
55 2,14 * * * savelog -c30 /tmp/docs-build.log; cd /home/data/docs.inasafe.org;git fetch origin; git reset --hard origin/master; /usr/local/bin/docker-compose run --rm pdf > /tmp/docs-build.log 2>&1

DNS

This service is running on 5.9.160.107 (see the service list), AND served via Cloudflare: https://www.cloudflare.com/a/login and https://www.cloudflare.com/a/dns/inasafe.org

Validation

When running correctly the service will show the build time in the footer. Note that this is the server time, so check the time on the server with command

date

and check if the string "last build" shows around that date.

Be sure about the Cloudflare status, if all is cached it's possible you are looking at the cached version.

Backups

This is a static site, build from github: there are no backup scripts.

Restoring from backups

This is a static site, so nothing to restore. Just install AND build the service again from Github

Clone this wiki locally