Getting Started - OpenDataEnterprise/sdg-nri-website GitHub Wiki

SDG National Reporting Initiative Website

  1. Clone the sdg-nri-website repository.
  2. In a command-line terminal, navigate to the repository's root directory and use Bundler to install the Ruby dependencies by running bundle install.
  3. Once Bundler is finished installing dependencies, you can run a local web server simply by running bundle exec jekyll serve --config _config.yml,_config-development.yml. The --config flag allows you to specify a comma-separated list of configuration YAML files to use with the application. In this case, _config.yml is the default configuration, and config-development.yml holds environment-specific configurations (e.g. the root URL of the API to use).

PostgreSQL

There are many different ways to set up a production PostgreSQL server depending on the platforms you are using. This section will only cover setting up a local database server for development purposes on the most common platforms.

It is recommended that you use your operating system's package manager to install PostgreSQL (it should be at least version 9.6), but general-purpose installation instructions can be found on the official PostgreSQL installation documentation.

Below are instructions for installing PostgreSQL on Debian/Ubuntu Linux and Mac OS X.

Debian/Ubuntu Linux

Create a file /etc/apt/sources.list.d/pgdg.list containing the appropriate line depending upon your distribution:

  • Debian Stretch 9.x: deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main
  • Debian Jessie 8.x: deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main
  • Debian Wheezy 7.x: deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main
  • Ubuntu 17.04: deb http://apt.postgresql.org/pub/repos/apt/ zesty-pgdg main
  • Ubuntu 16.04: deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
  • Ubuntu 14.04: deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main

After the file has been added detailing the proper package repository, add the signing key used to authenticate packages from the newly configured repository, then update the list of known packages on your system:

$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt update

After the list of packages has been updated, you should be able to install PostgreSQL through the APT package manager:

$ sudo apt install postgres-10

The APT installation should set up the PostgreSQL service to automatically start and stop with your system, as well as set up a basic administrative user.

To test that the default setup has been properly initialized, run the following commands:

$ sudo su postgres
# cd
# psql

For further instructions, please see the section below, Changing Default postgres User Password.

Mac OS X

Please ensure that you have Homebrew installed. With Homebrew, installing PostgreSQL is as easy as running the following command in a terminal:

brew install postgresql

If PostgreSQL installs without a hitch, you can use the following command to set the service to automatically start up with your system:

pg_ctl -D /usr/local/var/postgres start && brew services start postgresql

You can check the installed version through postgres -V.

Start the PostgreSQL command line client by running:

psql postgres

For further instructions, please see the section below, Changing Default postgres User Password.

Changing Default postgres User Password

If you are properly logged in to the PostgreSQL command line client, you should see the following prompt:

postgres=#

If this is not the case, your installation may not have succeeded. If you do see the prompt, change the default postgres administrator account password through the following command:

postgres=# \password postgres

Since this is for development purposes, we will skip setting up multiple users and permissions, but once the password has been set, you should be ready to configure the SDG National Reporting Initiative API.

SDG National Reporting Initiative API

  1. Clone the sdg-nri-api repository.
  2. In a command-line terminal, navigate to the repository's root directory and use npm or Yarn to install the Node.js dependencies by running npm install or yarn install.
  3. In the repository's root directory, there should be a file named .env.example. Copy this file into a file named .env in the same directory, and fill out the environment variable values. The most relevant values for development are those that configure the PostgreSQL connection.
  4. Once the dependencies are finished installing and you have configured the application, you can start a local API server by running node ./bin/www.

API Configuration

Please see the API Configuration section for details on environment variable values.