Giter Site home page Giter Site logo

bcgov / biohubbc Goto Github PK

View Code? Open in Web Editor NEW
15.0 6.0 9.0 129.65 MB

Species Inventory Management System (SIMS)

Home Page: https://apps.nrs.gov.bc.ca/int/confluence/pages/viewpage.action?pageId=75599180

License: Apache License 2.0

HTML 0.01% JavaScript 0.09% TypeScript 99.59% Makefile 0.03% Dockerfile 0.02% Shell 0.15% SCSS 0.01% PLpgSQL 0.10% Python 0.01%
biodiversity species env flnr flnro react material-ui biohub express keycloak

biohubbc's Introduction

img Quality Gate Status codecov BioHubBC

Species Inventory Management System (SIMS)

Sub-project under the SEISM Capital project, the source of BCโ€™s species inventory data.

The objectives for the SIMS project are:

  • To provide a single source for aquatic and terrestrial species and habitat data.
  • To reduce the barriers for collecting and sharing aquatic and terrestrial species and habitat data throughout the province of British Columbia.
  • To reduce the effort involved with managing aquatic and terrestrial species and habitat data.
  • To improve access for all stakeholders to the aquatic and terrestrial species and habitat data needed to make informed decisions and policies for the province.

Pre-reqs

Install Node/NPM

Install Git

Clone the repo

  • git clone https://github.com/bcgov/biohubbc.git

Install Docker

Windows

Note: there are 2 mutually exclusive modes that Docker Desktop supports on Windows: Hyper-V or WSL2. You should be able to run the application in either mode, but this documentation was only written with instructions for Hyper-V. See https://code.visualstudio.com/blogs/2020/03/02/docker-in-wsl2 for possible instructions on using Docker Desktop in WSL2.

If prompted, install Docker using Hyper-V (not WSL 2)

Grant Docker access to your local folders

This setup uses volumes to support live reload.
Ensure Docker Desktop has access to your file system so that it can detect file changes and trigger live reload.

MacOS

  • In the Docker-Desktop app:
    • Go to settings (gear icon)
    • Now go to Resources
    • Go to File Sharing
    • Add the folder/drive your repo is cloned under
      • This will grant Docker access to the files under it, which is necessary for it to detect file changes.

Windows

  • In the Docker-Desktop app:
    • Go to settings (gear icon)
    • On the general tab ensure that the Use the WSL 2 based engine is unchecked.
      • If it is checked, uncheck it, and click Apply & Restart
        • Docker may crash, but that is fine, you can kill docker for now.
      • You will then need to go to the following URL and follow the instructions in the first section Enable Hyper-V using Powershell: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v
        • This should just consist of running the 1 command in Powershell (as Admin): Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
      • Once the powershell command has been run, it will ask you to restart your machine.
      • Once restarted, re-launch Docker, and check that docker starts successfully and that the Use the WSL 2 based engine setting is still unchecked
    • Go to settings (gear icon)
    • Now go to Resources
    • Go to File Sharing
    • Add the folder/drive your repo is cloned under
      • This will grant Docker access to the files under it, which is necessary for it to detect file changes.

Ensure you can run the make command

MacOS

Windows

Note: you will need to run choco commands in a terminal as administrator

Configuring Local IDE

You can use any code IDE you prefer, though VSCode is recommended.

For convenience, you can install all node_modules by running the following command from the repo's root folder.

make install

You can also manually run npm install in each of the /api/, /app/, and /database/ folders.

Building/Running the App

Note: Run all make commands from the root folder of the repo.

Note: Run all commands in a terminal that supports make. On Mac you can use the default Terminal, on Windows you can use git-bash.

Initialize the ./env file.

This will copy ./env_config/env.docker to ./.env. .
The .env file may need additional editing to provide secrets for external services (like S3).
The .env file should never be committed!

make env

Result of running make env for the first time:
make env screenshot

Modifying Environment Variables

There are several places where environment variables need to be defined, depending on whether you are running the apps locally or in Openshift.

Below are all of the relevant files that need to be updated when modifying environment variables.

Local Development

  • env.docker
  • docker-compose.yml
  • app/src/contexts/configContext.tsx

Deployed to OpenShift

  • [api/app/database]/.pipeline/**
  • .pipeline/configMaps/sims.configmap.yaml
  • server/index.js
  • app/src/contexts/configContext.tsx
  • OpenShift Secrets (tools, dev, test, prod)

Start all Applications

Starts all applications (database, api, app).

make web

Result of running make web (condensed to only show the important parts):
make web screenshot

Access the Running Applications

api:

  • localhost:6100/api/

app:

  • localhost:7100

Helpful Makefile Commands

See ./Makefile for all available commands.

Note: Run all make commands from the root folder of the repo.

Print Makefile Help Doc

make help

Install All Dependencies

Will run npm install in each of the project folders (api, app, database).

make install

Delete All Containers

Will stop and delete the application docker containers.
This is useful when you want to clear out all database content, returning it to its initial default state.
After you've run make clean, running make web will launch new containers, with a fresh instance of the database.

make clean

Viewing the logs for a container

API

make log-api

APP

make log-app

Database

make log-db

Database Setup (migrations + seeding)

make log-db-setup

Linting and Formatting

Run Linter and Fix Issues

Will run the projects code linter and attempt to fix all issues found.

make lint-fix

Run Formatter and Fix Issues

Will run the projects code formatter and attempt to fix all issues found.

make format-fix

Run Both Linter and Formatter and Fix Issues

Will run both the projects code linter and code formatter and attempt to fix all issues found.

make fix

Shell Into a Docker Container (database, api, app, etc)

See ./Makefile for all available commands.

Database

This is useful if you want to access the PSQL database through the CLI.
See DBeaver for a GUI-centric way of accessing the PSQL database.

make db-container

Helpful Docker Commands

Show all running containers

docker ps

Show all containers (running and closed)

docker ps -a

What a successfully built/run set of docker containers looks like: make web screenshot

Note: The exited container is correct, as that container executes database migrations and then closes

View the logs for a container

docker logs <container id or name>
Include -f to "follow" the container logs, showing logs in real time

Prune Docker Artifacts

Over a long period time, Docker can run out of storage memory. When this happens, docker will log a message indicating it is out of memory.

The below command will delete docker artifacts to recover docker hard-drive space.

See documentation for OPTIONS.

docker system prune [OPTIONS]

Troubleshooting

Make Issues

If you get an error saying the make command is not found, you may need to install it first.
See Ensure you can run the make command

Docker Service Issues

ENV

A docker service can fail if required environment variables can't be found.
Double check that your .env has the latest variables from env.docker, which may have been updated.

Docker Timezone Issue

While trying to run a make command such as make web, if you encounter an issue along the lines of:

E: Release file for http://deb.debian.org/debian/dists/buster-updates/InRelease is not valid yet (invalid for another 1d 1h 5min 13s). Updates for this repository will not be applied.

it may be possible that your system clock is out of date or not synced (dockerfile timezone has to match your machine timezone). In this case, make sure your timezone is correct and matches that of docker and restart your machine/terminal window and try again.

Database Container Wont Start

If you already had PostgreSQL (PSQL) installed, it is likely that the default port 5432 is already in use and the instance running in Docker fails because it can't acquire that port.

  • You can either stop the existing PSQL service, freeing up the port for Dockers use.
  • Or alter the DB_PORT environment variable in .env to something not in use (ex: 5433).
    • You will likely need to run make clean and make web to ensure the containers are re-built with the new variables.

The App Works Locally But Not In OpenShift

See the section on Modifying Environment Variables

Helpful Tools

DBeaver

GUI-centric application for viewing/interacting with Databases.

Pre-req

Add a new connection

  • Click New Database Connection (+ icon)
    • Host: localhost
    • Port: 5432
    • Database: biohubbc
    • username: postgres
    • password: postgres
    • user role: (leave empty)
    • local client: PostgreSQL 12

Note: all of the above connection values can be found in the .env file

Acknowledgements

SonarCloud

License

Copyright 2019 Province of British Columbia

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

biohubbc's People

Contributors

al-rosenthal avatar alfredrosenthal avatar anissa-agahchen avatar cgarrettjones avatar curtisupshall avatar dependabot[bot] avatar grahams-quartech avatar jeremyquartech avatar jeznorth avatar kjartane avatar macqsl avatar mauberti-bc avatar nickphura avatar popkinj avatar repo-mountie[bot] avatar rstens avatar sdevalapurkar avatar shreypdev avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

biohubbc's Issues

Add missing topics

TL;DR

Topics greatly improve the discoverability of repos; please add the short code from the table below to the topics of your repo so that ministries can use GitHub's search to find out what repos belong to them and other visitors can find useful content (and reuse it!).

Why Topic

In short order we'll add our 800th repo. This large number clearly demonstrates the success of using GitHub and our Open Source initiative. This huge success means it's critical that we work to make our content as discoverable as possible. Through discoverability, we promote code reuse across a large decentralized organization like the Government of British Columbia as well as allow ministries to find the repos they own.

What to do

Below is a table of abbreviation a.k.a short codes for each ministry; they're the ones used in all @gov.bc.ca email addresses. Please add the short codes of the ministry or organization that "owns" this repo as a topic.

add a topic

That's it, you're done!!!

How to use

Once topics are added, you can use them in GitHub's search. For example, enter something like org:bcgov topic:citz to find all the repos that belong to Citizens' Services. You can refine this search by adding key words specific to a subject you're interested in. To learn more about searching through repos check out GitHub's doc on searching.

Pro Tip ๐Ÿค“

  • If your org is not in the list below, or the table contains errors, please create an issue here.

  • While you're doing this, add additional topics that would help someone searching for "something". These can be the language used javascript or R; something like opendata or data for data only repos; or any other key words that are useful.

  • Add a meaningful description to your repo. This is hugely valuable to people looking through our repositories.

  • If your application is live, add the production URL.

Ministry Short Codes

Short Code Organization Name
AEST Advanced Education, Skills & Training
AGRI Agriculture
ALC Agriculture Land Commission
AG Attorney General
MCF Children & Family Development
CITZ Citizens' Services
DBC Destination BC
EMBC Emergency Management BC
EAO Environmental Assessment Office
EDUC Education
EMPR Energy, Mines & Petroleum Resources
ENV Environment & Climate Change Strategy
FIN Finance
FLNR Forests, Lands, Natural Resource Operations & Rural Development
HLTH Health
IRR Indigenous Relations & Reconciliation
JEDC Jobs, Economic Development & Competitiveness
LBR Labour Policy & Legislation
LDB BC Liquor Distribution Branch
MMHA Mental Health & Addictions
MAH Municipal Affairs & Housing
BCPC Pension Corporation
PSA Public Service Agency
PSSG Public Safety and Solicitor General
SDPR Social Development & Poverty Reduction
TCA Tourism, Arts & Culture
TRAN Transportation & Infrastructure

NOTE See an error or omission? Please create an issue here to get it remedied.

ZAP Full Scan Report

View the following link to download the report.
RunnerID:1826386489

Add project lifecycle badge

No Project Lifecycle Badge found in your readme!

Hello! I scanned your readme and could not find a project lifecycle badge. A project lifecycle badge will provide contributors to your project as well as other stakeholders (platform services, executive) insight into the lifecycle of your repository.

What is a Project Lifecycle Badge?

It is a simple image that neatly describes your project's stage in its lifecycle. More information can be found in the project lifecycle badges documentation.

What do I need to do?

I suggest you make a PR into your README.md and add a project lifecycle badge near the top where it is easy for your users to pick it up :). Once it is merged feel free to close this issue. I will not open up a new one :)

It's Been a While Since This Repository has Been Updated

This issue is a kind reminder that your repository has been inactive for 180 days. Some repositories are maintained in accordance with business requirements that infrequently change thus appearing inactive, and some repositories are inactive because they are unmaintained.

To help differentiate products that are unmaintained from products that do not require frequent maintenance, repomountie will open an issue whenever a repository has not been updated in 180 days.

  • If this product is being actively maintained, please close this issue.
  • If this repository isn't being actively maintained anymore, please archive this repository. Also, for bonus points, please add a dormant or retired life cycle badge.

Thank you for your help ensuring effective governance of our open-source ecosystem!

Lets use common phrasing

TL;DR ๐ŸŽ๏ธ

Teams are encouraged to favour modern inclusive phrasing both in their communication as well as in any source checked into their repositories. You'll find a table at the end of this text with preferred phrasing to socialize with your team.

Words Matter

We're aligning our development community to favour inclusive phrasing for common technical expressions. There is a table below that outlines the phrases that are being retired along with the preferred alternatives.

During your team scrum, technical meetings, documentation, the code you write, etc. use the inclusive phrasing from the table below. That's it - it really is that easy.

For the curious mind, the Public Service Agency (PSA) has published a guide describing how Words Matter in our daily communication. Its an insightful read and a good reminder to be curious and open minded.

What about the master branch?

The word "master" is not inherently bad or non-inclusive. For example people get a masters degree; become a master of their craft; or master a skill. It's generally when the word "master" is used along side the word "slave" that it becomes non-inclusive.

Some teams choose to use the word main for the default branch of a repo as opposed to the more commonly used master branch. While it's not required or recommended, your team is empowered to do what works for them. If you do rename the master branch consider using main so that we have consistency among the repos within our organization.

Preferred Phrasing

Non-Inclusive Inclusive
Whitelist => Allowlist
Blacklist => Denylist
Master / Slave => Leader / Follower; Primary / Standby; etc
Grandfathered => Legacy status
Sanity check => Quick check; Confidence check; etc
Dummy value => Placeholder value; Sample value; etc

Pro Tip ๐Ÿค“

This list is not comprehensive. If you're aware of other outdated nomenclature please create an issue (PR preferred) with your suggestion.

ZAP Full Scan Report

View the following link to download the report.
RunnerID:1441839130

It's Been a While Since This Repository has Been Updated

This issue is a kind reminder that your repository has been inactive for 180 days. Some repositories are maintained in accordance with business requirements that infrequently change thus appearing inactive, and some repositories are inactive because they are unmaintained.

To help differentiate products that are unmaintained from products that do not require frequent maintenance, repomountie will open an issue whenever a repository has not been updated in 180 days.

  • If this product is being actively maintained, please close this issue.
  • If this repository isn't being actively maintained anymore, please archive this repository. Also, for bonus points, please add a dormant or retired life cycle badge.

Thank you for your help ensuring effective governance of our open-source ecosystem!

ZAP Full Scan Report

View the following link to download the report.
RunnerID:1446272276

Add project lifecycle badge

No Project Lifecycle Badge found in your readme!

Hello! I scanned your readme and could not find a project lifecycle badge. A project lifecycle badge will provide contributors to your project as well as other stakeholders (platform services, executive) insight into the lifecycle of your repository.

What is a Project Lifecycle Badge?

It is a simple image that neatly describes your project's stage in its lifecycle. More information can be found in the project lifecycle badges documentation.

What do I need to do?

I suggest you make a PR into your README.md and add a project lifecycle badge near the top where it is easy for your users to pick it up :). Once it is merged feel free to close this issue. I will not open up a new one :)

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.