Analytical Platform Control Panel

Running with Docker

Environment variables

You need to set a few environment variables which will be picked up by Docker. This can be done by creating a .env file with a variable set on each line with VAR_NAME=value.

Build and run

Checkout the repo and run

docker-compose pull
docker-compose build
docker-compose up

Create superuser (on first run)

In a separate terminal window, run

docker-compose exec api python3 manage.py createsuperuser

View the app

Then browse to http://localhost:3000/ You can also access the API backend at http://localhost:8000/

Developing

The docker container mounts the app/ and test/ directories from the host, and runs with nodemon, so file changes will be detected and the node app restarted. The static/ directory is not monitored, so if you add files directly to this directory, you will need to rebuild the docker image to pick them up.

Running the tests

docker-compose exec frontend yarn run test

Running directly

Install dependencies

yarn install

Environment variables

You should set these in a file named .env with each variable on a separate line, eg: API_USER=username

name value
API_URL Base URL of the Control Panel API. Default http://localhost:8000
API_USER DEPRECATED. User name for Basic authentiation with the Control Panel API
API_PASSWORD DEPRECATED. Password for Basic authentication with the Control Panel API
APP_PROTOCOL http (default) or https. The protocol used for fully qualified links into the Control Panel
APP_HOST The hostname (and optional port) of the Control Panel. Default localhost:3000
AUTH0_DOMAIN Domain of Auth0 tenant, eg: dev-analytics-moj.eu.auth0.com
AUTH0_CLIENT_ID Client ID from Auth0
AUTH0_CLIENT_SECRET Client Secret from Auth0
COOKIE_SECRET Secret used to encrypt cookies
COOKIE_MAXAGE Maximum lifetime of session cookie in milliseconds. Default 1 hr (3600000)
ENABLE_WRITE_TO_CLUSTER Set to 0 to prevent writing to Kubernetes or AWS (which will break if you have no AWS credentials)
ENABLE_ACCESS_LOGS Set to false to disable HTTP request logging
ENV Name of the cluster this frontend will be deployed to. Default dev
EXPRESS_HOST Hostname to listen on. Default 127.0.0.1
EXPRESS_PORT Port to listen on. Default 3000
IAM_ARN_BASE Used to construct ARNs
K8S_WORKER_ROLE_NAME Used to construct ARN of IAM role
LOG_LEVEL Controls verbosity of logging. One of DEBUG (default), INFO, WARN or ERROR
NODE_RESTART Set to 1 to enable restarting the app on file changes
OIDC_CLIENT_ID Same value as AUTH0_CLIENT_ID - only required for docker-compose
OIDC_CLIENT_SECRET Same value as AUTH0_CLIENT_SECRET - only required for docker-compose
REDIS_HOST Hostname of your redis server
REDIS_PASSWORD Set to any string (if not set, it will break)
SAML_PROVIDER Used to contruct ARN of SAML provider
SENTRY_DSN Optional. Credentials and URL of Sentry instance for error logging.
TOOLS_DOMAIN The domain where tools (eg: RStudio) are hosted, used to build URLs to tools.

Run a Redis server

redis-server --requirepass $REDIS_PASSWORD

Run the webapp

yarn run start

View the app

Browse to http://localhost:3000/

Running the tests

yarn run test