Home

Awesome

Frontend for infra-risk-vis

React app, frontend for https://global.infrastructureresilience.org/.

Set up Husky

When running npm install in development, the prepare script should be run automatically. This will set up the Husky git hooks. The pre-commit hook is used to run linting and formatting on staged files using lint-staged.

Install dependencies for development

This package's dependencies include packages in the @nismod scope, which are published through the GitHub npm package repository.

These packages are publicly available, but require a GitHub Personal Access Token to install.

In order to install the project's dependencies:

If using npm natively rather than in a docker container, then:

Containers

See ./containers for Docker configuration.

As described in the section above, the GitHub NPM registry auth token needs to be available during build so that dependencies from the @nismod scope can be installed.

The Dockerfiles are set up to accept a Docker secret named GH_TOKEN. This can be passed using a path to a local file that contains the token. For steps to obtain a token, see the previous section.

Note that passing --secret during build is a Docker BuildKit feature, hence the need to install docker buildx for building locally, and to pass the DOCKER_BUILDKIT=1 variable before the docker build command.

For example, to build the container (replace /PATH/TO/TOKEN, but not GH_TOKEN):

DOCKER_BUILDKIT=1 docker build \
   --secret id=GH_TOKEN,src=/PATH/TO/TOKEN \
   -f containers/Dockerfile-dev \
   -t ghcr.io/nismod/irv-frontend:0.27-dev .

To run:

docker run -it -p 5173:5173 -v $(pwd)/src:/app/src ghcr.io/nismod/irv-frontend:0.27-dev

Or to run inside an infra-risk-vis network (allowing DNS resolution for connection to the backend services via the vite reverse proxy):

docker run -it -p 5173:5173 -v $(pwd)/src:/app/src --network infra-risk-vis_default ghcr.io/nismod/irv-frontend:0.27-dev

Then visit http://localhost:5173

Release an update

The easiest way to make the updated code available is to push/merge to main, then make a GitHub Release with a new tag, which will be used as the version number.

Alternatively, to build and push an update to the container registry manually:

DOCKER_BUILDKIT=1 docker build \
   --secret id=GH_TOKEN,src=/PATH/TO/TOKEN \
   -f containers/Dockerfile-prod \
   -t ghcr.io/nismod/irv-frontend:0.27 .

docker push ghcr.io/nismod/irv-frontend:0.27

See https://github.com/nismod/infra-risk-vis/ for docker-compose.yml and how the frontend is composed with other services.

Development

Developer-focussed documentation on the app and potential roadmap:

License

This codebase is made available under the MIT License, copyright (c) 2023 Tom Russell, Maciej Ziarkowski and contributors. See ./LICENSE for details

Acknowledgments

See https://github.com/nismod/infra-risk-vis/#acknowledgements