Public | Automated Build

Last pushed: a year ago
Short Description
Pilot application for crowd sourcing and drafting policy.
Full Description

Objective8

Development VM

You can develop and run the application in a VM to ensure that the correct versions of Objective[8]'s dependencies
are installed. You will need VirtualBox, Vagrant and Ansible installed.

First, clone the repository.

Navigate to the ops/ directory of the project and run:

vagrant up development

The first time this is run, it will provision and configure a new VM.

When the VM has started, access the virtual machine by running:

vagrant ssh

The source folder will be located at /var/objective8.

After initial setup, navigate to the source directory and apply the migrations:

cd /var/objective8
lein ragtime migrate

Running the tests

To run all tests, use this command:

lein test

Commands and aliases can be found in the project.clj file.

Designing in the browser

This allows you to rapidly design. You can create jade, modify the sass and js. These will all be live reloaded.

grunt design

Open your browser at http://192.168.50.50:2345/_routes to access it from outside the vagrant box.

Adding or updating a translation resource

Resources for translating the site into different languages are located under:
/resources/translations/<locale-identifier>.csv

To start translating into a new locale, or to update translations for
an existing locale, there is a helper leiningen task that copies keys
from the default en.csv template into a new or existing templates for
other locales. This can be run using:

lein translation-template <locale-identifier> [& <locale-identifier>]

For example:

lein translation-template es el

will generate or update /resources/translations/es.csv and
/resources/translations/el.csv.

Running the app

Add any environment variables you want to use to the start_app_vm.sh script.

To start the app, run:

lein start

And then inside the REPL run this for a fake twitter sign-in:

(reset :stub-twitter)

or this for the normal sign-in options:

(reset :default)

Deployment

First, install Docker.

To run the application you'll need the following containers:

  • Postgresql
  • Objective8
  • Nginx

First, open the objective8_docker_config_template found in the /ops directory, enter your credentials and save the file. This will be used in both postgres and objective8.

Postgres Container

To start a postgres docker container, using the relative path for your config file.

docker run -d --env-file=<docker config relative file path> -v /data --name pg_objective8 postgres

Objective8

To start the Objective[8] container without any customisations, run the following command:

docker run -d --env-file=<relative path to objective8 docker config> -p 8080:8080 -p 8081:8081 --link pg_objective8:postgres --name objective8 dcent/objective8

Customisations

You can optionally customise the colour scheme, favicon, the Stonecutter icon on the sign-in page and the translations. The following command will start the container with all these customisations:

docker run -d --env-file=<relative path to objective8 docker config> \
-v <absolute path to colour scheme>:/usr/src/app/assets/scss/root/_theme.scss \
-v <absolute path to custom favicon>:/usr/src/app/resources/public/favicon.ico \
-v <absolute path to stonecutter sign-in icon>:/usr/src/app/resources/public/stonecutter-sign-in-icon.png \
-v <absolute path to English custom translations>:/usr/src/app/resources/translations/custom-en.csv \
-v <absolute path to Spanish custom translations>:/usr/src/app/resources/translations/custom-es.csv \
-p 8080:8080 -p 8081:8081 --link pg_objective8:postgres --name objective8 dcent/objective8

You can omit any of the lines starting with -v if you are happy with the default settings.

Colour scheme

To start the container with a custom colour scheme, you will need a file that redefines the three colours:

$color1: #007E84;
$color2: #9C0F83;
$color3: #ffbf47;
Translations

To use your own translations within the app, you need to create .csv files for each language you wish to change. Find the existing translations here.
You will need to copy over the first two values for the translation and then enter your own text after another comma. For example, to change the subtitle on the learn more page, take the relevant line from the en.csv file:

learn-more,sub-title,What are the basics?

and save this into your csv file:

learn-more,sub-title,Objectivating explained!

Nginx container

Nginx is used to add SSL protection and act as a reverse proxy. to use it you need:

  • an SSL certificate and key
  • a dhparam.pem file
  • an nginx.conf file

You can acquire an SSL certificate and key online inexpensively. You should receive a pair of files, for instance objective8.crt and objective8.key. Store them in their own directory somewhere safe.

You can generate a dhparam.pem file by running:

openssl dhparam -rand – 2048 > dhparam.pem

You can create an nginx.conf file by copying the following into a new file and replacing the <> appropriately:

events {
}
http {
  server {
  listen 80;
  return 301 https://<ip address>$request_uri;
  }


  server {
    listen 443 ssl;

    ssl_certificate /etc/nginx/ssl/<file name for SSL certificate>;
    ssl_certificate_key /etc/nginx/ssl/<file name for SSL key>;

    ssl_session_cache shared:SSL:32m;
    ssl_session_timeout 10m;

    ssl_dhparam /etc/nginx/cert/dhparam.pem;
    ssl_protocols TLSv1.2 TLSv1.1 TLSv1;

    # trailing '/' after port means app doesn't know about '/as2/'
    location /as2/ {
      proxy_pass http://objective8:7000/;
    }
    # no trailing '/' after port means app knows about '/api/v1/'
    location /api/v1/ {
      proxy_pass http://objective8:8081;
    }
    location / {
      proxy_pass http://objective8:8080;
    }
  }
}

Finally, run the following command:

docker run -v <absolute path to SSL certificates and keys directory>:/etc/nginx/ssl -v <absolute path to conf file>/nginx.conf:/etc/nginx/nginx.conf -v <absolute path to dhparam file>/dhparam.pem:/etc/nginx/cert/dhparam.pem --link objective8:objective8 -p 443:443 -p 80:80 -d --name nginx nginx
Docker Pull Command
Owner
dcent
Source Repository

Comments (0)