adlnet / learninglocker-docker

Dockerized version of the Learning Locker LRS capable of targeting different release tags from the official repo.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Learning Locker version 2 in Docker

A dockerized version of the outstanding Learning Locker LRS by Sprout Labs. This project follows the deployment steps for version 2, based on the installation guides at http://docs.learninglocker.net/guides-custom-installation/.

This is a modified version of the original repo from michzimny to match the general ADL conventions for Nginx, Certbot, and Office 365's SMTP server requirements. Accordingly, a few of the original instructions have been changed in this fork to match that structure.

TL;DR

To stand up an instance of this LRS, get the repo:

git clone https://github.com/adlnet/learninglocker-docker lrs
cd lrs

get the Learning Locker repo:

./clone-locker.sh

copy the baseline settings:

cp .env.example .env
sudo ./install-reqs.sh
sudo ./init-ssl.sh localhost

then stand it up:

sudo docker-compose up -d --build

and create the first admin user:

sudo ./create-admin.sh admin@example.com MyOrg password

Configuring Office 365 SMTP

The mailer should be able to use any account and the TLS / Secure settings are already configured to work with Office 365, but the authenticated user must match the user sending the email. The original LL project does expose the variables to do this, but it wasn't documented super well:

The lines to change in your .env file are:

SMTP_HOST=smtp.office.com
SMTP_USER=your.mail.user@office.com
SMTP_PASS=your.password
SMTP_REQUIRE_TLS=true

Architecture

For LL's architecture consult http://docs.learninglocker.net/overview-architecture/

This section is about the architecture coming out of this dockerization.

Official images of Mongo, Redis, and xAPI service are used. Additionally, build creates two Docker images: nginx and app. LL application services are to be run on containers based on the app image.

File docker-compose.yml describes the relation between services. A base configuration consists of 7 containers that are run using the above-mentioned images (LL application containers - api, ui, and worker - are run using image app).

The only persistent locations are directories in $DATA_LOCATION (see below), which are mounted as volumes to Mongo container and app-based containers.

The origin service ui expects service api to work on localhost, however in this dockerized version the both services are run in separate containers. To make connections between those services work, socat process is run within ui container to forward local tcp connections to api container.

Usage

To build the images:

./build-dev.sh

To configure adjust settings in .env:

  • DOCKER_TAG - git commit (SHA-1) to be used ("dev" for images built by build-dev.sh)
  • DATA_LOCATION - location on Docker host where volumes are created
  • DOMAIN_NAME - domain name as the instance is to be accessed from the world
  • APP_SECRET - LL's origin setting: Unique string used for hashing, Recommended length - 256 bits
  • SMTP_* - SMTP connection settings (for TLS config, see here)

To run the services:

docker-compose up -d

BUT, for the first time, as Mongo requires some significant time to start up, you should rather:

docker-compose up -d mongo  # launch Mongo first
docker-compose logs -f mongo  # wait until Mongo gets ready
docker-compose up -d   # launch all the other services

Open the site and accept non-trusted SSL/TLS certs (see below for trusted certs).

To create a new user and organisation for the site:

docker-compose exec api node cli/dist/server createSiteAdmin [email] [organisation] [password]

Production usage

Deployment

Preparing a remote machine for the first time, put .env file to the machine and adjust the settings as given above.

To deploy a new version (git commit) to the machine, set DOCKER_TAG in .env to the git commit (SHA-1), copy docker-compose.yml of the git commit to the machine (see the SSL/TLS notice below), and just call the command:

docker-compose up -d

Keep also in mind the note given above that for the first launch, it might be good to start Mongo only in the first step.

SSL/TLS certs

Mount cert files to nginx container adding a section in docker-compose.yml:

     volumes:
        - "/path-to-certs-on-docker-host/fullchain.pem:/root/ssl/fullchain.pem:ro"
        - "/path-to-certs-on-docker-host/privkey.pem:/root/ssl/privkey.pem:ro"

Backups

Backup $DATA_LOCATION, i.e. the Docker volumes: Mongo's data and app's storage.

Upgrading

In app/Dockerfile, git tag of LL application is declared. In docker-compose.yml, image tag of xAPI service is declared. The versions (tags) in use can be easily adjusted as needed.

After upgrading these versions, you shall usually proceed as follows:

docker-compose pull
docker-compose stop xapi worker ui api nginx
docker-compose run --rm api yarn migrate
docker-compose up

About

Dockerized version of the Learning Locker LRS capable of targeting different release tags from the official repo.

License:GNU General Public License v3.0


Languages

Language:Shell 79.9%Language:Dockerfile 20.1%