Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging this PR will add a guide to run the dashboard locally within the Readme #119

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4cc0f14
added aws-sso to devcontainer
jamesstottmoj Mar 20, 2024
b560c9e
Updated readme to add guide. Merged main changes
jamesstottmoj Apr 2, 2024
9954d51
Removed static analysis as it's causing issues with dependency buildi…
jamesstottmoj Apr 2, 2024
6153c89
updated readme
jamesstottmoj Apr 2, 2024
a5c0cdd
fixed heading
jamesstottmoj Apr 2, 2024
de53824
changed UI to Dashboard
jamesstottmoj Apr 2, 2024
035f2a0
added line to state which address to go to
jamesstottmoj Apr 2, 2024
7e7ad09
Included link to data platform docs
jamesstottmoj Apr 2, 2024
7b33d2f
clarified using justice identity
jamesstottmoj Apr 2, 2024
5b35d2c
Merge branch 'main' into feature/running-local-guide
jamesstottmoj Apr 2, 2024
78f50b6
added script to run server. added to post-create script to run migrat…
jamesstottmoj Apr 2, 2024
a15b699
punctuation
jamesstottmoj Apr 2, 2024
de6ffaa
Shifted ordering of sections
jamesstottmoj Apr 2, 2024
f3d7138
fixed potential linting error
jamesstottmoj Apr 3, 2024
3298a8b
Update DevContainer build instructions
jamesstottmoj Apr 3, 2024
2c8a364
added makefile command to run server. command added to readme
jamesstottmoj Apr 4, 2024
efd6d44
Removed static analysis as it's causing issues with dependency buildi…
jamesstottmoj Apr 2, 2024
3770824
updated readme
jamesstottmoj Apr 2, 2024
e3fda52
fixed heading
jamesstottmoj Apr 2, 2024
277ddd1
changed UI to Dashboard
jamesstottmoj Apr 2, 2024
e4f5aa9
added line to state which address to go to
jamesstottmoj Apr 2, 2024
2b07f76
Included link to data platform docs
jamesstottmoj Apr 2, 2024
3591fee
clarified using justice identity
jamesstottmoj Apr 2, 2024
91b8c56
added script to run server. added to post-create script to run migrat…
jamesstottmoj Apr 2, 2024
6a92234
punctuation
jamesstottmoj Apr 2, 2024
98fa955
Shifted ordering of sections
jamesstottmoj Apr 2, 2024
cd3aac7
fixed potential linting error
jamesstottmoj Apr 3, 2024
1f4275e
Update DevContainer build instructions
jamesstottmoj Apr 3, 2024
68aceac
added makefile command to run server. command added to readme
jamesstottmoj Apr 4, 2024
771e873
Merge branch 'feature/running-local-guide' of github.com:ministryofju…
jamesstottmoj Apr 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ db-drop:
serve:
python manage.py runserver

serve-sso:
aws-sso exec --profile analytical-platform-development:AdministratorAccess -- python manage.py runserver

container:
docker build -t controlpanel .

Expand Down
40 changes: 15 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,28 @@

[![repo standards badge](https://img.shields.io/endpoint?labelColor=231f20&color=005ea5&style=for-the-badge&label=MoJ%20Compliant&url=https%3A%2F%2Foperations-engineering-reports.cloud-platform.service.justice.gov.uk%2Fapi%2Fv1%2Fcompliant_public_repositories%2Fendpoint%2Fanalytical-platform-dashboard&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABmJLR0QA/wD/AP+gvaeTAAAHJElEQVRYhe2YeYyW1RWHnzuMCzCIglBQlhSV2gICKlHiUhVBEAsxGqmVxCUUIV1i61YxadEoal1SWttUaKJNWrQUsRRc6tLGNlCXWGyoUkCJ4uCCSCOiwlTm6R/nfPjyMeDY8lfjSSZz3/fee87vnnPu75z3g8/kM2mfqMPVH6mf35t6G/ZgcJ/836Gdug4FjgO67UFn70+FDmjcw9xZaiegWX29lLLmE3QV4Glg8x7WbFfHlFIebS/ANj2oDgX+CXwA9A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XdArwCOllFX/i53P5P9a/gNkKpsCMFRuFAAAAABJRU5ErkJggg==)](https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/public-report/analytical-platform-dashboard)

## Running
## Running Locally

The quickest way to get the project running is to use the dev container that has been configured to install all
dependencies required to run the project locally. To use the dev container, see the [Data Platform docs.](https://technical-documentation.data-platform.service.justice.gov.uk/documentation/platform/infrastructure/developing.html#developing-the-data-platform)
The dashboard is run in a DevContainer via Docker. The DevContainer VSCode extension is recommended, as is Docker Desktop.

Alternatively you can install the project locally by installing python 3.11, creating a venv, and installing the
project dependencies with
For more information on Dev Containers, see the [Data Platform docs.](https://technical-documentation.data-platform.service.justice.gov.uk/documentation/platform/infrastructure/developing.html#developing-the-data-platform)

```commandline
pip install -r requirements.dev.txt
```

You will also need to have Postgresql installed and running on your machine.
### Building the DevContainer
To build the dev container, ensure docker desktop is running, then open the AP Dashboard project in VSCode. Open the command pallet by hitting command+shift+p and search for ```Dev Containers: Reopen in container``` and hit enter. This will build the dev container.

### Pre-commit
If you are using a workspace with multiple applications, search for ```Dev Containers: Open folder in Container…``` instead, then select the AP UI folder. Once the dev container has finished building, it should install all the required Python and npm dependencies, as well as run the migrations.

To avoid pushing code and seeing the GitHub actions fail due to linting errors, when installing the project for the
first time you should install the pre-commit hooks with:
### Environment Variables
There is an example environment file stored on 1Password named ```Analytical Platform Dashboard Env```. Paste the contents into a new file called ```.env``` in the root of the project.

```commandline
pre-commit install
```
### Running Development Server
To run the server, you will need to use aws-sso cli. To find the correct profile, run ```aws-sso list``` in the terminal. This will provide you with a link to sign in via SSO. Once signed in, a list of profiles will be displayed. You are looking for the profile name linked to the ```analytical-platform-development``` AccountAlias.
jamesstottmoj marked this conversation as resolved.
Show resolved Hide resolved

This will run black, mypy, flake8 and isort before a commit to check for failures and stage any required changes.
To run the server using this profile, enter ```aws-sso exec --profile analytical-platform-development:AdministratorAccess -- python manage.py runserver``` or ```make serve-sso```. Then go to ```localhost:8000``` and sign in using your @justice.gov.uk identity.

### Updating Migrations
To run the migrations locally, run ```python manage.py migrate``` in the terminal.

### Build static

There is a Makefile to wrap commands used to build the static files. When setting up the project, run all steps using the command:

```commandline
make build-static
```

Or look at the Makefile and run the individual commands as you require.
### Updating static assets
To build the static assets, run ```make build-static``` in the terminal.
7 changes: 7 additions & 0 deletions scripts/devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ pip install --upgrade pip

# Install dependencies
pip install -r requirements.dev.txt

# install npm dependencies and static assets
npm install
make build-static

# Run migrations
python manage.py migrate
Loading