Open Academic Environment (OAE) Back-End
Latest commit 839f82d Sep 5, 2018
Permalink
Failed to load latest commit information.
.circleci export-data - circleci Jul 11, 2018
3akai-ux @ 34994e3 Bump 3akai-ux from `0fada71` to `34994e3` Jul 13, 2018
bin (RequireUtil) Add require for some util, remove where unneeded Jun 9, 2014
etc first step in changing the cassandra driver Aug 2, 2017
node_modules removed code redundancy Jul 18, 2018
.coveralls.yml Initial attempt at supporting coveralls.io Jan 10, 2014
.dockerignore Initial Dockerfile and docker-compose scripts May 31, 2017
.editorconfig add editorconfig file Jul 30, 2013
.gitignore updated gitignore file Aug 2, 2017
.gitmodules Added restjsdoc as a submodule Aug 2, 2017
.snyk fix: package.json & .snyk to reduce vulnerabilities Nov 7, 2017
.travis.yml Update dist setting Sep 13, 2017
CODE_OF_CONDUCT.md Code of conduct styling Mar 6, 2017
CONTRIBUTING.md Update CONTRIBUTING.md Aug 22, 2017
Dockerfile Fixes #1503 Jan 19, 2018
Gruntfile.js Multiple email domain follow up Dec 9, 2015
LICENSE Fixed invalid license URL Jun 13, 2013
README.md badges Sep 5, 2018
app.js Fixed failing test and took out port from cass config Sep 4, 2017
chocolatey.config Removed pdftk dependency by just using GraphicsMagick Jan 21, 2015
config.js Fixes #1581 May 2, 2018
docker-compose.mac.yml Changed the test keyspace database's name Aug 8, 2017
docker-compose.yml fixes #1557 Mar 19, 2018
docker-sync.yml updated docker-sync file (unison is default now) Aug 2, 2017
local.js Increase default to give Hilary time to start Oct 5, 2017
nodemon.json Reduced nodemon watching list May 31, 2017
package.json export-data - test Jul 11, 2018
process.json Added cwd to pm2 config Mar 16, 2018
repl.js Added repl-promised to package.json Sep 6, 2017

README.md

Open Academic Environment (OAE Project)

Hilary is the back-end for the Open Academic Environment

Discord Koding

Build status

CircleCI Coverage Status Code Climate Codacy Badge dependencies devdependencies

Installation

If you're looking to install the OAE project manually, check out this page and then go the the Setup section below.

If you're looking to setup a development environment, you might want to run node locally instead of inside a docker container. If that's the case, follow through the instructions below and then check the troubleshooting section.

Otherwise, please follow our docker quickstart guide:

Docker Quickstart Guide

The recommended way to install docker is to follow the official guide at https://docs.docker.com/engine/installation/. Make sure you have docker version >= 17.x and docker-compose version >= 1.6.0 before you proceed to cloning the repos. Check your versions by running the following commands:

$ docker -v
Docker version 17.03.0-ce, build 60ccb2265
$ docker-compose -v
docker-compose version 1.11.2, build dfed245

Also, don't forget the post-install instructions if you're using linux.

Clone the repos

git clone https://github.com/oaeproject/Hilary.git && cd Hilary
git submodule init
git submodule update
cd 3akai-ux && git checkout master # because HEAD is detached after pulling submodules by default

Customize the folder paths

If you accept the following directory structure, docker-compose will work out of the box.

<some-local-path>
|-- Hilary
    |-- 3akai-ux
|-- files
|-- tmp
    |-- oae
|-- data
    |-- elasticsearch
    |-- cassandra
    |-- etherpad

If you want to use different (local) paths, make sure to change container volumes accordingly on docker-compose.yml:

Then, we need to edit the config.js file and make sure we change the following settings:

    'hosts': ['127.0.0.1:9160'], # replace this
    'hosts': ['oae-cassandra:9160'], # by this
    'host': '127.0.0.1', # replace this
    'host': 'oae-redis', # by this
    'host': 'localhost', # replace this
    'host': 'oae-elasticsearch', # by this
    'host': 'localhost', # replace this
    'host': 'oae-rabbitmq', # by this
config.previews = {
    'enabled': false, # replace this
    'enabled': true, # by this (optional)
    'host': '127.0.0.1', # replace this
    'host': 'oae-etherpad', # by this

Build the docker image locally

docker-compose create --build # this will build the hilary:latest image

NOTE: if the previous step fails due to network problems, try changing the DNS server to Google's: 8.8.8.8 or 8.8.4.4. In order to do this, either use your operating system's settings or do it via the command line interface by editing /etc/resolv.conf and making sure these two lines are on top:

nameserver 8.8.8.8
nameserver 8.8.4.4

Install dependencies

In order to install dependencies for the frontend and the backend, we need to run a one-off command for each:

docker-compose run oae-hilary "cd node_modules/oae-rest && npm install" # install dependencies for oae-rest
docker-compose run oae-hilary "cd 3akai-ux && npm install" # install dependencies for 3akai-ux
docker-compose run oae-hilary "npm install" # install dependencies for Hilary

Create the SSL Certificate

If we're looking to use HTTPS via nginx, first we need to create the SSL certificate. You can do do that by running:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout 3akai-ux/nginx/nginx-selfsigned.key -out 3akai-ux/nginx/nginx-selfsigned.crt

This will create two new files: 3akai-ux/nginx/nginx-selfsigned.key and 3akai-ux/nginx/nginx-selfsigned.crt.

Then, run the following command:

openssl dhparam -out 3akai-ux/nginx/dhparam.pem 2048

This may take a few minutes, but when it's done you will have the file nginx/dhparam.pem that you can use in your configuration.

--

Before moving on to the next step, make sure these three files exist otherwise there will be errors.

Run the containers

Run docker-compose up and all the containers will boot.

Extra docker utilities

The service names and description are in the docker-compose.yml file.

To start and stop all containers at once, run docker-compose up and docker-compose down respectively. Check docker-compose documentation for more information.

If you need to rebuild the hilary:latest docker image, try running docker build -f Dockerfile -t hilary:latest ..

If you need to tail the logs of a specific server for debugging, try running docker logs -f oae-hilary (for the oae-hilary service).

If you're having network problems, run docker network inspect bridge for check container network configuration or docker inspect oae-hilary to take a look at oae-hilary container details.

--

Setup

Set up external authentication strategies (optional)

In order to set up twitter authentication, you'll need to set your twitter dev account environment variables like this:

export TWITTER_KEY="<your key here>"
export TWITTER_SECRET"="<your secret here>"

Same thing goes for google auth and facebook auth. The environment variables for each are:

export GOOGLE_CLIENT_ID=""
export GOOGLE_CLIENT_SECRET=""

export FACEBOOK_APP_ID=""
export FACEBOOK_APP_SECRET=""

This is enough to run all the tests locally in a dev environment. For production purposes, all environment variables can and should be overwritten by the admin in the tenant configuration form.

Change the /etc/hosts file

OAE is a multi-tenant system that discriminates the tenant by the host name with which you are accessing the server. In order to support the "Global Tenant" (i.e., the tenant that hosts the administration UI) and a "User Tenant", you will need to have at least 2 different host names that point to your server. To do this, you will need to add the following entries to your /etc/hosts file:

127.0.0.1   admin.oae.com
127.0.0.1   tenant1.oae.com

Where admin.oae.com is the hostname that we will use to access the global administration tenant and tenant1.oae.com would be one of many potential user tenant hosts. After making this change, you should now be able to visit http://admin.oae.com \o/

Change the docker-compose DNS entries

This same DNS information must be made explicit in the docker-compose.yml file, to make sure that the oae-hilary container can connect to the oae-nginx container holding HTTP server (for instance, for preview processing purposes). Go to the file and look for the following section:

extra_hosts:
- "admin.oae.com:172.20.0.9"
- "tenant1.oae.com:172.20.0.9"

As you see, we already included both admin.oae.com and tenant1.oae.com, both associated with the oae-nginx static IP. If you're looking to add an extra host, say, tenant2.oae.com, then you should add the following line and you're good to go:

- "tenant2.oae.com:172.20.0.9"

Creating your first user tenant

When you start the server, all data schemas will be created for you if they don't already exist. A global administrator user and global administration tenant will be ready for you as well. You can use these to create a new user tenant that hosts the actual OAE user interface.

  1. Visit http://admin.oae.com/ (substitute "admin.oae.com" with the administration host you configured in /etc/hosts)
  2. Log in with username and password: administrator / administrator
  3. Click the "Tenants" header to open up the actions
  4. Click "Create tenant"
  5. Choose an alias (a short, unique 2-5 character alphanumeric string such as "oae"), and a name of your liking.
  6. For the Host field, use the host you configured for your user tenant in /etc/hosts (e.g., "tenant1.oae.com")
  7. Click "Create new tenant"

You can now access the user tenant by their host http://tenant1.oae.com and start creating new users.

Creating your first user

To create a new user, use either the Sign Up link at the top left, or the Sign In link at the top right.

Tip: OAE requires that users have an email address that is verified VIA an email that is sent to the user. To avoid the requirement of having a valid email server configuration, you can instead watch the app server logs when a user is created or their email address is updated. When config.email.debug is set to true in config.js, the content of the verification email can be seen in the logs, and you can copy/paste the email verification link from the log to your browser to verify your email. The URL will look similar to: http://tenant1.oae.com/?verifyEmail=abc123

We're looking forward to seeing your contributions to the OAE project!

Troubleshooting

Booting takes too much time

If you're on OSX, you might experience very slow booting especially for the Hilary server. This is a well known issue due to volume mounting. As a workaround, we recommend using docker-sync. Just follow the installation instructions on the website, edit the docker-sync.yml file so that syncs > oae-hilary-sync > src contains your Hilary source path as follows:

syncs:
  oae-hilary-sync:
    ...
    src: '/src/Hilary' # <- make sure this path is correct
  ...

Then, make sure you rename the mac-specific docker-compose.mac.json file we've included:

cp docker-compose.yml docker-compose.backup.yml
cp docker-compose.mac.yml docker-compose.yml

Finally, try one of these two alternatives to boot all the containers:

  1. Run docker-sync start on a terminal window and then docker-compose -f docker-compose.mac.yml up on another, in this order
  2. Run docker-sync-stack start which combines both commands above

More information on docker-sync is available here.

All I see is the 502 service unavailable page

If you still can't see the Web interface correctly by the time the containers start, it might be due to Hilary starting before Cassandra was available. This usually results in 502 Service unavailable pages. We recommend to start hilary again to make sure it boots after cassandra is accepting connections: docker-compose restart oae-hilary. This is something we're looking to fix in the future.

I would like to run node directly on my machine instead of inside a container

We understand that, and we do that ourselves too :) You can have that with just a few changes. If you're using linux:

In config.js change the following values:

  • oae-rabbitmq
  • oae-cassandra
  • oae-elasticsearch
  • oae-etherpad
  • oae-redis

...all to localhost.

Then, edit nginx.conf.docker and make sure these lines:

...
server oae-hilary:2000;
...
server oae-hilary:2001;
...

..become:

...
server 172.20.0.1:2000; # `172.20.0.1` is the IP address of the host machine, which can be obtained by running `/sbin/ip route|awk '/default/ { print $3 }'` from any container (e.g. `docker exec -it oae-nginx sh`).
...
server 172.20.0.1:2001;
...

If you're using mac osx, you'll need to use the external IP address (e.g. en0) instead of the docker0 IP address for oae-nginx to access Hilary, like this:

...
server 192.168.1.2:2000; # assuming 192.168.1.2 is the external network IP address
...
server 192.168.1.2:2001; # assuming 192.168.1.2 is the external network IP address
...

Also, don't forget that running Hilary locally implies installing several other packages, namely soffice (libreoffice), pdftotext and pdf2htmlEX. You can find instructions on how to do this here.

Now run docker-compose up -d oae-cassandra oae-redis oae-rabbitmq oae-elasticsearch and then docker-compose logs -f to check the logs. Once cassandra is listening for connections, you may run the remaining containers: docker-compose up -d oae-etherpad oae-nginx. You may then run nodemon app.js | bunyan locally on the terminal to start the server.

Get in touch

The project website can be found at http://www.oaeproject.org. The project blog will be updated with the latest project news from time to time.

The mailing list used for Apereo OAE is oae@apereo.org. You can subscribe to the mailing list at https://groups.google.com/a/apereo.org/d/forum/oae.

Bugs and other issues can be reported in our issue tracker. Ideas for new features and capabilities can be suggested and voted for in our UserVoice page.