Coder Social home page Coder Social logo

ministryofjustice / moj-product-dashboard Goto Github PK

View Code? Open in Web Editor NEW
5.0 15.0 3.0 6.71 MB

Product dashboard for MoJ products

License: MIT License

Python 60.84% HTML 5.10% CSS 19.70% Shell 0.12% JavaScript 14.24%
python3 reactjs plotlyjs django-rest-framework

moj-product-dashboard's Introduction

MOJ Product Dashboard

Code Climate

Test Coverage

Issue Count

Product dashboard for MoJ products.

depth

1

Dependencies

  • Python 3.5 (can be installed using brew install python3)
  • Virtualenv (can be installed using pip3 install virtualenv)
  • nodejs.org (v6.2.0 - can be installed using nvm)

Installation

Clone the repository:

git clone [email protected]:ministryofjustice/moj-product-dashboard.git

Next, create the environment and start it up:

virtualenv env --python=`which python3` --prompt=\(dashboard)\

source env/bin/activate

Update pip to the latest version:

pip install -U pip

Install python dependencies:

pip install -r requirements/local.txt

Install frontend dependencies:

npm install

Development

Create the postgres database named dashboard:

createdb dashboard

Create database tables

python manager.py migrate

Load auth group, permissions and test users:

python manager.py loaddata dashboard/apps/dashboard/fixtures/*

Run the Django development server:

python manage.py runserver

Watch and compile JS and CSS when code changes detected:

npm run watch

Build compressed JS and CSS:

npm run build

Testing

Run unit tests for python code:

py.test --cov=dashboard --cov-report term-missing

Run unit tests for JS code:

npm run test

Generate coverage report for JS code:

npm run test -- --coverage

Watch and rerun JS unit tests when code changes detected:

npm run test -- --watch

Background Tasks

Background tasks on AWS are run using Celery and SQS. Locally you will need to install rabbitmq-server instead of SQS.

brew install rabbitmq

Copy BROCKER_URL in to your local.py

BROKER_URL = "amqp://"
BROKER_TRANSPORT_OPTIONS = {}

Then run rabbitmq-server it with

rabbitmq-server

and finally run cellery with

celery -A dashboard worker -B -l info

Heroku

Check the repo out and run these commands once you have created your app

heroku plugins:install heroku-container-tools
heroku plugins:install heroku-container-registry
heroku container:login
heroku addons:create heroku-postgresql:standard-2x --app moj-product-dashboard
heroku addons:create cloudamqp:lemur --app moj-product-dashboard
heroku addons:create heroku-redis:hobby-dev --app moj-product-dashboard

Then run

heroku config --app moj-product-dashboard

to get the DATABASE_URL, REDIS_URL and CLOUDAMQP_URL to set up application env vars

heroku config:set DB_HOST=xx --app moj-product-dashboard
heroku config:set DB_NAME=xx --app moj-product-dashboard
heroku config:set DB_PASSWORD=xx --app moj-product-dashboard
heroku config:set DB_PORT=5432 --app moj-product-dashboard
heroku config:set DB_USERNAME=xx --app moj-product-dashboard

heroku config:set CELERY_BROKER_URL=amqp://xx:[email protected]/xx --app moj-product-dashboard

heroku config:set REDIS_URL:redis://xx:[email protected]:10109  --app moj-product-dashboard

heroku config:set FLOAT_API_TOKEN:xx --app moj-product-dashboard
heroku config:set FLOAT_URL:xx --app moj-product-dashboard

Set other env vars

heroku config:set DEBUG=True --app moj-product-dashboard

Then push and start the app

heroku container:push web --app moj-product-dashboard

Amazon ECS

To use the AWS CLI you will need to create an IAM user in your AWS account and configure a profile. See CLI - getting started For more info on how to do this. Remember your profile name as you will need it when running the login command below.

You can get this running on Amazon ECS but creating a stack with the cloudformation template in `cloudformation/template.yaml`

The Template can also be produced/edited with this repository

https://github.com/s-block/ecs/ (by running python create.py)

  1. Create a Key Pair that you want your instances to have so you can ssh in to them - need to enter this when creating the stack
  2. Create a Hosted Zone in AWS Route53 for the domain you would like
3. Upload the cloudformation template to AWS either via the AWS Console or via the AWS CLI. You will have to confirm the Certificate creation - maybe via email. Most of the fields are obvious but some that aren't are:
  • Stack name: can be anything, will be used as the repository name
  • DomainName: domain to create the Certificate for
  • KeyName: name of Key Pair created in step one. Will bee needed to ssh in to any instances
  • SecretKey: Used to set the ENV var SECRET_KEY to be used by the Django app
  • WebAppRevision: Docker tag to automatically build when updated. 'master' or 'prod' or anything you like.
  1. Create an A Record in the hosted zone and point it to the load balancer created in the stack
  2. Create a local.py file in the dashboard/settings directory
  3. Build a docker image - find your image repository from ECS Management in AWS Console
aws ecr get-login --profile {YOUR_PROFILE_NAME} --region eu-west-1
{RUN_COMMAND_RETURNED_FROM_ABOVE}

docker build -t {STACK_NAME} .
docker tag {STACK_NAME}:{WebAppRevision} {YOUR_IMAGE_REPOSITRY}/{STACK_NAME}:{WebAppRevision}
docker push {YOUR_IMAGE_REPOSITRY}/{STACK_NAME}:{WebAppRevision}
  1. Re-run the task for the Cluster in ECS Management in AWS Console

Create Finance Admin User

Only users with the role of finance can access sensitive data like people's salary or daily rates. Only users with both roles of finance and admin can create finance users. Therefore to get the system running, a finance admin user is needed.

This command will create a finance admin user if one doesn't already exist, so it's safe to be used by build system to run in every build without causing additional side effects

python manager.py ensure_finance_amdin_user --username ${username} --password ${password}

To create an extra finance admin user, use the --force option

python manager.py ensure_finance_amdin_user --username ${username} --password ${password} --force

moj-product-dashboard's People

Contributors

axemonkey avatar cliffxuan avatar jimnarey avatar s-block avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moj-product-dashboard's Issues

A branch protection setting is not enabled: codeowners require reviews

Hi there
The default branch protection setting called codeowners require review is not enabled for this repository
This option affects a pull request, i.e a PR will need to be reviewed and approved by a CODEOWNER before it can be merged.
See repository settings/Branches/Branch protection rules
Either add a new Branch protection rule or edit the existing branch protection rule and select the Require review from Code Owners option
Create a .github/CODEOWNERS file
Add a or multiple entries of @ministryofjustice/team_name to the CODEOWNERS file
The team_name shall be a team from within the MoJ teams: https://github.com/orgs/ministryofjustice/teams
See GH Codeowners documentation: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

A branch protection setting is not enabled: requires approving reviews

Hi there
The default branch protection setting called requires approving reviews is not enabled for this repository
See repository settings/Branches/Branch protection rules
Either add a new Branch protection rule or edit the existing branch protection rule and select the Require approvals option
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

Default branch is not main

Hi there
The default branch for this repository is not set to main
See repository settings/settings/branches to rename the default branch to main and ensure the Branch protection rules is set to main as well
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.