From 5bc7a03fbfe444d032663900ada1e651686776a7 Mon Sep 17 00:00:00 2001 From: Derek Roberts Date: Tue, 6 Aug 2024 06:19:23 -0700 Subject: [PATCH] Start restoring root files --- CODE_OF_CONDUCT.md | 138 +------ COMPLIANCE.yaml | 8 +- LICENSE | 2 +- README.md | 430 +++++--------------- docker-compose.yml | 253 ++++++++---- gwells/CODE_OF_CONDUCT.md | 24 -- gwells/COMPLIANCE.yaml | 11 - gwells/LICENSE | 201 --------- gwells/README.md | 149 ------- gwells/docker-compose.yml | 173 -------- {gwells/pics => pics}/container_diagram.png | Bin 11 files changed, 278 insertions(+), 1111 deletions(-) delete mode 100644 gwells/CODE_OF_CONDUCT.md delete mode 100644 gwells/COMPLIANCE.yaml delete mode 100644 gwells/LICENSE delete mode 100644 gwells/README.md delete mode 100644 gwells/docker-compose.yml rename {gwells/pics => pics}/container_diagram.png (100%) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 6f5be045d..d225ebb39 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,132 +1,24 @@ -# Contributor Covenant Code of Conduct +## Contributor Code of Conduct -## Overview +As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. -Act in the best interests of the community, the government of British Columbia and your fellow collaborators. We welcome and appreciate your contributions, in any capacity. +We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. -## Our Pledge +Examples of unacceptable behavior by participants include: -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, religion, or sexual identity -and orientation. +- The use of sexualized language or imagery +- Personal attacks +- Trolling or insulting/derogatory comments +- Public or private harassment +- Publishing other's private information, such as physical or electronic addresses, without explicit permission +- Other unethical or unprofessional conduct -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. -## Our Standards +By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. -Examples of behavior that contributes to a positive environment for our -community include: +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the - overall community +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a project maintainer at [Christian.Evans@gov.bc.ca](mailto:Christian.Evans@gov.bc.ca). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an incident. -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or - advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email - address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -derek.roberts@gmail.com. -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series -of actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or -permanent ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within -the community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.0, available at -https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. - -Community Impact Guidelines were inspired by [Mozilla's code of conduct -enforcement ladder](https://github.com/mozilla/diversity). - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see the FAQ at -https://www.contributor-covenant.org/faq. Translations are available at -https://www.contributor-covenant.org/translations. +This Code of Conduct is adapted from the Contributor Covenant, version 1.3.0, available at [http://contributor-covenant.org/version/1/3/0/](http://contributor-covenant.org/version/1/3/0/) diff --git a/COMPLIANCE.yaml b/COMPLIANCE.yaml index f18d0a7ad..39258666e 100644 --- a/COMPLIANCE.yaml +++ b/COMPLIANCE.yaml @@ -4,8 +4,8 @@ description: | compliance. spec: - name: PIA - status: not-required - last-updated: '2022-01-26T23:07:19.992Z' + status: in-progress + last-updated: '2020-01-20T00:04:29.148Z' - name: STRA - status: not-required - last-updated: '2022-01-26T23:07:19.992Z' + status: completed + last-updated: '2020-01-20T00:04:29.148Z' diff --git a/LICENSE b/LICENSE index fe0c038e5..8dada3eda 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2024 Province of British Columbia + Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 75305fc4c..9943f51db 100644 --- a/README.md +++ b/README.md @@ -1,389 +1,149 @@ -[![MIT License](https://img.shields.io/github/license/bcgov/nr-gwells.svg)](/LICENSE.md) -[![Lifecycle](https://img.shields.io/badge/Lifecycle-Experimental-339999)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md) +[![img](https://img.shields.io/badge/Lifecycle-Stable-97ca00)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md) -[![Merge](https://github.com/bcgov/nr-gwells/actions/workflows/merge.yml/badge.svg)](https://github.com/bcgov/nr-gwells/actions/workflows/merge.yml) -[![Analysis](https://github.com/bcgov/nr-gwells/actions/workflows/analysis.yml/badge.svg)](https://github.com/bcgov/nr-gwells/actions/workflows/analysis.yml) -[![Scheduled](https://github.com/bcgov/nr-gwells/actions/workflows/scheduled.yml/badge.svg)](https://github.com/bcgov/nr-gwells/actions/workflows/scheduled.yml) +# Groundwater Wells and Aquifers (GWELLS) -Frontend (JavaScript/TypeScript) +https://apps.nrs.gov.bc.ca/gwells/ -[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_frontend&metric=bugs)](https://sonarcloud.io/summary/new_code?id=nr-gwells_frontend) -[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_frontend&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=nr-gwells_frontend) -[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_frontend&metric=coverage)](https://sonarcloud.io/summary/new_code?id=nr-gwells_frontend) -[![Duplicated Lines](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_frontend&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=nr-gwells_frontend) -[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_frontend&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=nr-gwells_frontend) -[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_frontend&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=nr-gwells_frontend) -[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_frontend&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=nr-gwells_frontend) -[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_frontend&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=nr-gwells_frontend) -[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_frontend&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=nr-gwells_frontend) +## Introduction -Backend (JavaScript/TypeScript) +The Ministry of Environment receives and processes groundwater data and information related to the construction, alteration and decommissioning of groundwater wells. Well construction and reporting requirements are regulated under the Water Sustainability Act and Groundwater Protection Regulation. The information collected and stored is used by government and other users to help inform decisions related to the management of the groundwater resource in B.C. -[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_backend&metric=bugs)](https://sonarcloud.io/summary/new_code?id=nr-gwells_backend) -[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_backend&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=nr-gwells_backend) -[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_backend&metric=coverage)](https://sonarcloud.io/summary/new_code?id=nr-gwells_backend) -[![Duplicated Lines](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_backend&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=nr-gwells_backend) -[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_backend&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=nr-gwells_backend) -[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_backend&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=nr-gwells_backend) -[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_backend&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=nr-gwells_backend) -[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_backend&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=nr-gwells_backend) -[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=nr-gwells_backend&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=nr-gwells_backend) +GWELLS, the new groundwater data repository, aims to improve the user experience when submitting and searching for well information, to improve the quality of the data being submitted, and to improve the overall functionality of the system to meet user and regulatory requirements. -# QuickStart for OpenShift +The application is being developed as an open source solution. -## Pull Request-Based Workflows with Sample Stack +## Table of Contents -The is a fully functional set of [GitHub Actions](https://github.com/bcgov/nr-gwells/actions) workflows and a starter application stack intended to help Agile teams hit the ground running. +1. [Using the GWELLS API](#Using-the-gwells-api) +1. [Developing GWELLS](#Developing-gwells) + * [Running the GWELLS application locally](#Running-the-GWELLS-application-locally) + * [Authentication](#Authentication) + * [Running tests](#Running-tests) + * [Making pull requests](#Making-pull-requests) +1. [Architecture](#Architecture) +1. [Contributing](#contributing) + * [Code With Us](#code-with-us) +1. [Issues](#issues) +1. [License](#license) -Features: -* Pull Request-based pipeline -* Sandboxed development environments -* Gateable production deployments -* Container publishing (ghcr.io) and importing (OpenShift) -* Security, vulnerability, infrastructure, and container scan tools -* Automatic dependency patching available from [bcgov/renovate-config](https://github.com/bcgov/renovate-config) -* Enforced code reviews and workflow jobs (pass|fail) -* Helm Package Manager for atomic deployments -* Prometheus Metrics export from Backend/Frontend -* Resource Tuning with Horizontal Pod Autoscaler (TEST/PROD only) -* Affinity and anti-affinity for Scheduling on different worker nodes -* Rolling updates with zero downtime in PROD -* Database Migrations with Flyway -* Pod disruption budgets for high availability -* Self-healing through with probes/checks (startup, readiness, liveness) -* Point the long-lived DEMO route to PRs by using the `demo` label -* Sample application stack: - * Database: Postgres, PostGIS, backups, Flyway - * Frontend: TypeScript, Caddy Server - * Backend: TypeScript, Nest.js - * Alternative backends for [Java/Quarkus, Go/Fiber and Python/FastAPI](https://github.com/bcgov/quickstart-openshift-backends) +## Using the GWELLS API -# Setup +GWELLS maintains a REST API where public data relating to wells is made available for other applications and services. -Initial setup is intended to take an hour or less. This depends greatly on intended complexity, features selected/excluded and outside cooperation. +Our Swagger documentation is available at https://apps.nrs.gov.bc.ca/gwells/api/. Some examples of GWELLS endpoints: -## Prerequisites +Wells: +```sh +# all wells (paginated) +curl https://apps.nrs.gov.bc.ca/gwells/api/v1/wells -The following are required: +# all wells in an area bounded by sw_lat, sw_long, ne_lat, and ne_long +curl https://apps.nrs.gov.bc.ca/gwells/api/v1/wells?sw_lat=51.599253&sw_long=-128.220340&ne_lat=52.108192&ne_long=-127.150547 +``` -* BC Government IDIR accounts for anyone submitting requests -* [GitHub accounts](https://github.com/signup) for all participating team members -* Membership in the BCGov GitHub organization - * Provide GitHub IDs to [BCGov's Just Ask](https://just-ask.developer.gov.bc.ca/) -* OpenShift project namespaces: - * [BCGov signup](https://registry.developer.gov.bc.ca) +Aquifers: +```sh +# all aquifers +curl https://apps.nrs.gov.bc.ca/gwells/api/v1/aquifers +``` -## Using this Template +See the [Swagger documentation](https://apps.nrs.gov.bc.ca/gwells/api/) for more examples. -Create a new repository using this repository as a template. +## DataBC Export -* Verify bcgov/nr-gwells is selected under Repository template +GWELLS Api is used by DataBC to export model information and provide well information on the DataBC website. -![](./.github/graphics/template.png) +The command located in app/backend/gwells/management/commands/export_databc.py is used to pull data from the gwells database and export it for consumption in DataBC. -## Secrets and Variables +If a new field(s) are needed for export, this export_databc.py has raw sql queries that need to be updated with the required fields. Descriptions are also needed for the swagger documentation that are pulled from the db_comment fields in the django models. Both the raw sql queries and the db_comment field on the model need to be updated for new fields. -Variables and secrets are consumed by workflows. Environments provide their own values, overriding default sets. +## Developing GWELLS -Secrets are hidden from logs and outputs, while variables are visible. Using secrets exclusively can make troubeshooting more difficult. +### Running the GWELLS application locally -Note: Dependabot, which we don't recommend as highly as Renovate, requires its own set of variables. +[Clone the GWELLS repository](https://help.github.com/en/articles/cloning-a-repository) and run the application with [Docker](https://store.docker.com/search?type=edition&offering=community): +```sh +cd gwells +docker-compose up +``` -### Secrets Values +Visit the following links to browse the API and frontend applications: -> Click Settings > Secrets and Variables > Actions > Secrets > New repository secret +* Django REST API development server: http://localhost:8000/gwells/api/ +* Vue frontend development server: http://localhost:8080/ -**OC_TOKEN** +### Authentication -OpenShift token, different for every project/namespace. This guide assumes your OpenShift platform team has provisioned a pipeline account. +Some GWELLS pages (submitting new well reports, adding or editing aquifers, or adding or editing qualified well drillers to the registry) require authentication. Authentication uses the Province's Single Sign-On system. A GWELLS team member can request access for collaborators if needed. -* Consume: `{{ secrets.OC_TOKEN }}` +### Running tests: -Locate an OpenShift pipeline token: +Django unit tests: +```sh +cd app/backend +docker-compose exec backend python manage.py test +``` -1. Login to your OpenShift cluster, e.g.: [Gold](https://console.apps.gold.devops.gov.bc.ca/) or [Silver](https://console.apps.silver.devops.gov.bc.ca/) -2. Select your DEV namespace -3. Click Workloads > Secrets (under Workloads for Administrator view) -4. Select `pipeline-token-...` or a similarly privileged token -5. Under Data, copy `token` -6. Paste into the GitHub Secret `OC_TOKEN` +Vue unit tests: +```sh +cd app/frontend +docker-compose exec frontend npm run test:unit +``` -**OC_NAMESPACE** +Postman API tests: +Import the json test collections in the `api-tests/` folder into [Postman](https://www.getpostman.com/). -OpenShift project/namespace. Provided by your OpenShift platform team. +### Import a Shapefile -* Consume: `{{ secrets.OC_NAMESPACE }}` -* Value: format `abc123-dev | test | prod` +Single shapefile, with aquifer ID specified in CLI. -**SONAR_TOKEN(s)** +``` +docker-compose exec backend python manage.py import_shapefile 2 aquifers/fixtures/shp/shapefile.zip +``` -If SonarCloud is being used each application will have its own token. Single-application repositories typically use `${{ secrets.SONAR_TOKEN }}`, while monorepos use similar names. +Bulk import, requires the AQ_NUMBER attribute on each polygon. Requires a folder with shapefiles to be prepared and passed in (zipped or not). Note: if DEBUG=True, all geometries will be uploaded to a random aquifer instead of the one matching its' number, so we can test locally with a development database. -E.g.: -* `${{ secrets.SONAR_TOKEN_BACKEND }}` -* `${{ secrets.SONAR_TOKEN_FRONTEND }}` +``` +mkdir app/backend/bulk +mv DATABC_EXPORT_FILE.zip app/backend/bulk/ -BC Government employees can request SonarCloud projects by creating an [issue](https://github.com/BCDevOps/devops-requests/issues/new/choose) with BCDevOps. Please make sure to request a monorepo with component names (e.g. backend, frontend), which may not be explained in their directions. +docker-compose exec backend python manage.py import_bulk_shapefile bulk +``` -### Variable Values +### Importing Licences -> Click Settings > Secrets and Variables > Actions > Variables > New repository variable +To download new licence data from DataBC and merge it into your DB, do -**OC_SERVER** +``` +docker-compose exec backend python manage.py import_licences +``` -OpenShift server address. -* Consume: `{{ vars.OC_SERVER }}` -* Value: `https://api.gold.devops.gov.bc.ca:6443` or `https://api.silver.devops.gov.bc.ca:6443` +### Making pull requests -## Environments +Pull requests made from branches in the bcgov/gwells repo will kick off a dev pipeline, which runs tests and deploys a preview environment containing your changes. The pull request page will update when the environment is deployed and mandatory checks (unit tests, etc.) pass or fail. -Environments are groups of secrets and variables that can be gatekept. This includes limting access to certain users or requiring manual approval before a requesting workflow can run. Environment values override any default values. +## Architecture -For pull requests and development surrounding lower-level, sandboxed environments it is best not to use an environment at all. Higher level environments, like TEST and PROD, will override those values as necessary. +GWELLS uses PostgreSQL (with PostGIS), Django REST Framework, and Vue.js. We also use both AWS S3 and a self-hosted Minio service for storing documents. -> Click Settings > Environments > New environment +Our production and staging environments run on an OpenShift container platform cluster. OpenShift templates for services are located in the `openshift/` folder, along with more information about dev and staging environments on our cluster. -Environments provide a [number of features](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment), including: +![GWELLS container diagram](pics/container_diagram.png) -* Required reviewers -* Wait timer -* Deployment branches +## Contributing -## Updating Dependencies +Government employees, the public and members of the private sector are encouraged to contribute. Please read and follow our [Code of Conduct](https://github.com/bcgov/gwells/blob/master/CODE_OF_CONDUCT.md). -Dependabot and Mend Renovate can both provide dependency updates using pull requests. Dependabot is simpler to configure, while Renovate is much more configurable and lighter on resources. +All contributors retain original copyright, but are granting a world-wide, royalty-free, perpetual, irrevocable, non-exclusive, transferable license to all users. This project is covered by an [Apache v2.0 license](https://github.com/bcgov/gwells/blob/master/LICENSE). -### Renovate +### Code With Us -A config file (`renovate.json`) is included with this template. It can source config from our [renovate repository](https://github.com/bcgov/renovate-config). Renovate can be [self-hosted](https://github.com/renovatebot/github-action) or run using the GitHub App managed at the organization level. For BC Government the OCIO controls this application, so please opt in with them using a GitHub issue. +Many of our features have been developed by members of the community. Check the [BC Developer Exchange website](https://bcdevexchange.org/), where paid opportunities to build features for GWELLS and other applications are posted. -To opt-in: -* Visit the [Renovate GitHub App](https://github.com/apps/renovate/) -* Click `Configure` and set up your repository -* Visit [BCDevOps Requests](https://github.com/BCDevOps/devops-requests) -* Select [Issues](https://github.com/BCDevOps/devops-requests/issues) -* Select [New Issue](https://github.com/BCDevOps/devops-requests/issues/new/choose) -* Select [Request for integrating a GitHub App](https://github.com/BCDevOps/devops-requests/issues/new?assignees=MonicaG%2C+oomIRL%2C+SHIHO-I&labels=github-app%2C+pending&projects=&template=github_integration_request.md&title=) -* Create a meaningful title, e.g. `Request to add X repo to Renovate App` -* Fill out the description providing a repository name -* Select "Submit new issue" -* Wait for Renovate to start sending pull requests to your repository +## Issues -### Dependabot +Issues are tracked on the [Water Jira board](https://apps.nrs.gov.bc.ca/int/jira/projects/WATER/issues). Note this is a restricted issue tracker and you will require permission to be able to view it. -Dependabot is no longer recommended as an alternative to Renovate for generating security, vulnerability and dependency pull requests. It can still be used to generate warnings under the GitHub Security tab, which is only viewable by repository administrators. +## License -## Repository Configuration - -### Pull Request Handling - -Squash merging is recommended for simplified history and ease of rollback. Cleaning up merged branches is recommended for your DevOps Specialist's fragile sanity. - -> Click Settings > General (selected automatically) - -Pull Requests: - -* `[uncheck] Allow merge commits` -* `[check] Allow squash merging` - * `Default to pull request title` -* `[uncheck] Allow rebase merging` -* `[check] Always suggest updating pull request branches` -* `[uncheck] Allow auto-merge` -* `[check] Automatically delete head branches` - -### Packages - -Packages are available from your repository (link on right). All should have visibility set to public for the workflows to run successfully. - -E.g. https://github.com/bcgov/nr-gwells/packages - -### Branch Protection Rules - -This is required to prevent direct pushes and merges to the default branch. These steps must be run after one full pull request pipeline has been run to populate the required status checks. - -1. Select `Settings` (gear, top right) > `Rules` > `Rulesets` (under Code and Automation) -2. Click `New ruleset` > `New branch ruleset` -3. Setup Ruleset: - * Ruleset Name: `main` - * Enforcement status: `Active` - * Bypass list: - * Click `+ Add bypass` - * Check `[x] Repository admin` - * Click `Add selected` - * Target branches: - * Click `Add target` - * Select `Add default branch` - * Branch protections: - * `[x] Restrict deletions` - * `[x] Require linear history` - * `[x] Require a pull request before merging` - * Additional settings: - * `Require approvals: 1` (or more!) - * `[x] Require conversation resolution before merging` - * `[x] Require status checks to pass` - * `[x] Require branches to be up to date before merging` - * Required checks: *These will be populated after a full pull request pipeline run!* - * Click `+Add checks` - * This is our default set, yours may differ: - * `Analysis Results` - * `PR Results` - * `Validate Results` - * `[x] Block force pushes` - * `[x] Require code scanning results` - * Click `+ Add tool` - * This is our default set, yours may differ: - * `CodeQL` - * `Trivy` - * Click `Create` - -#### Status checks example -![](./.github/graphics/branch-protection.png) - -#### Required tools and alerts example -![](./.github/graphics/branch-code-results.png) - - -### Adding Team Members - -Don't forget to add your team members! - -1. Select Settings (gear, top right) *> Collaborators and teams (under `Access`) -2. Click `Add people` or `Add teams` -3. Use the search box to find people or teams -4. Choose a role (read, triage, write, maintain, admin) -5. Click Add - -# Workflows - -## Pull Request - -Runs on pull request submission. - -* Provides safe, sandboxed deployment environments -* Build action pushes to GitHub Container Registry (ghcr.io) -* Build triggers select new builds vs reusing builds -* Deploy only when changes are made -* Deployment includes curl checks and optional penetration tests -* Run tests (e2e, load, integration) when changes are made -* Other checks and updates as required - -![](.github/graphics/pr-open.png) - -## Validation - -Runs on pull request submission. - -* Enforces conventional commits in PR title -* Adds greetings/directions to PR descriptions - -![](.github/graphics/pr-validate.png) - - -## Analysis - -Runs on pull request submission or merge to the default branch. - -* Unit tests (should include coverage) -* CodeQL/GitHub security reporting (now handled as GitHub default!) -* Trivy password, vulnerability and security scanning - -![](.github/graphics/analysis.png) - -## Pull Request Closed - -Runs on pull request close or merge. - -* Cleans up OpenShift objects/artifacts -* Merge retags successful build images as `latest` - -![](.github/graphics/pr-close.png) - -## Merge - -Runs on merge to main branch. - -* Code scanning and reporting to GitHub Security overview -* Zero-downtime* TEST deployment -* Penetration tests on TEST deployment (optional) -* Zero-downtime* PROD deployment -* Labels successful deployment images as PROD - -\* excludes database changes - -![](.github/graphics/merge.png) - -## Scheduled - -Runs on scheduled job (cronjob) or workflow dispatch. - -* PR environment purge -* Generate SchemaSpy documentation -* Tests (e2e, load, integration) on TEST deployment - -![](.github/graphics/scheduled.png) - -## DEMO Routing - -There is a long-lived custom route available to be assigned to specific Pull Request deployments. Add the label `demo` to that pull request or run the `DEMO Route` workflow. - -Typical route: `https://-demo.apps.silver.devops.gov.bc.ca` - -#### PR Label - -Please note that the label must be manually created using GitHub's web interface. - -![](.github/graphics/demo-label.png) - -#### Workflow -![](.github/graphics/workflow.png) - - -# App Stack - -## Starter - -The starter stack includes a (React, MUI, Vite, Caddy) frontend, Pluggable backend(Nest/Node, Quarkus/Java On Native, FastAPI/Python, Fiber/Golang) and postgres database. See subfolder for source, including Dockerfiles and OpenShift templates. - -Features: -* [TypeScript](https://www.typescriptlang.org/) strong-typing for JavaScript -* [NestJS](https://docs.nestjs.com) Nest/Node backend and frontend -* [Flyway](https://flywaydb.org/) database migrations -* [Postgres](https://www.postgresql.org/) or [PostGIS](https://postgis.net/) database -* [backup-container](https://github.com/BCDevOps/backup-container) provided by BCDevOps - -Postgres is default. Switch to PostGIS by copying the appropriate Dockerfile to `./database`: - -> cp ./database/postgis/Dockerfile ./database - -## Pluggable Backends - -This quickstart works with more than just JavaScript. Please check out our pluggable [backends repository](https://github.com/bcgov/quickstart-openshift-backends). Flyway-based database migrations for each are included. - -Supported languages: -* [Go with Fiber](https://github.com/bcgov/quickstart-openshift-backends/tree/main/backend-go) -* [Java with Quarkus, Cloud Native](https://github.com/bcgov/quickstart-openshift-backends/tree/main/backend-go) -* [Python with FastAPI](https://github.com/bcgov/quickstart-openshift-backends/tree/main/backend-py) - -## SchemaSpy - -The database documentation is created and deployed to GitHub pages. See [here](https://bcgov.github.io/nr-gwells/schemaspy/index.html). - -After a full workflow run and merge can been run, please do the following: - -1. Select Settings (gear, top right) *> Pages (under `Code and automation`) -2. Click `Branch` or `Add teams` -3. Select `gh-pages` -4. Click `Save` - -![img.png](.github/graphics/schemaspy.png) - -# Resources - -This repository is provided by NRIDS Architecture and Forestry Digital Services, courtesy of the Government of British Columbia. - -* NRID's [Kickstarter Guide](https://bcgov.github.io/nr-architecture-patterns-library/docs/Agile%20Team%20Kickstarter) (via. Confluence, links may be internal) -* [OpenShift Backends for Go, Java and Python](https://github.com/bcgov/quickstart-openshift-backends) - -# Contributing - -Please contribute your ideas! [Issues](/../../issues) and [Pull Requests](/../../pulls) are appreciated. +Code released under the [Apache License, Version 2.0](https://github.com/bcgov/gwells/blob/master/LICENSE). diff --git a/docker-compose.yml b/docker-compose.yml index 783c17948..32249e43f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,100 +1,173 @@ -# Reusable vars -x-var: - - &POSTGRES_USER - postgres - - &POSTGRES_PASSWORD - default - - &POSTGRES_DATABASE - postgres - -# Reusable envars for postgres -x-postgres-vars: &postgres-vars - POSTGRES_HOST: database - POSTGRES_USER: *POSTGRES_USER - POSTGRES_PASSWORD: *POSTGRES_PASSWORD - POSTGRES_DATABASE: *POSTGRES_DATABASE - +version: '3.7' +# NOTE For Red Hat or other images on the internal registry please login as follows: +# 1. Be logged into the BC Gov OpenShift Console +# https://console.pathfinder.gov.bc.ca:8443/console/catalog) +# 2. Be logged into the BC Gov OpenShift Image Registry via +# docker login -u -p `oc whoami -t` docker-registry.pathfinder.gov.bc.ca +# +# For example: +# docker login -u garywong-bc -p `oc whoami -t` docker-registry.pathfinder.gov.bc.ca services: - database: - image: postgres:15 - container_name: database + minio-public: + build: + context: ./openshift/docker/minio/ + hostname: minio + ports: + - "9000:9000" + volumes: + - /data environment: - <<: *postgres-vars - healthcheck: - test: ["CMD", "pg_isready", "-U", *POSTGRES_USER] - ports: ["5432:5432"] - - migrations: - image: flyway/flyway:10-alpine - container_name: migrations - command: info migrate info - volumes: ["./migrations/sql:/flyway/sql:ro"] + MINIO_ACCESS_KEY: minio + MINIO_SECRET_KEY: minio1234 + MINIO_DATA_DIR: /data + entrypoint: /minio-entrypoint.sh + command: server /data + minio-private: + build: + context: ./openshift/docker/minio/ + hostname: minio + ports: + - "9001:9001" + volumes: + - /data environment: - FLYWAY_URL: jdbc:postgresql://database:5432/postgres - FLYWAY_USER: *POSTGRES_USER - FLYWAY_PASSWORD: *POSTGRES_PASSWORD - FLYWAY_BASELINE_ON_MIGRATE: true - FLYWAY_DEFAULT_SCHEMA: users - depends_on: - database: - condition: service_healthy - - schemaspy: - image: schemaspy/schemaspy:6.2.4 - profiles: ["schemaspy"] - container_name: schemaspy - command: -t pgsql11 -db postgres -host database -port 5432 -u postgres -p default -schemas users - depends_on: - migrations: - condition: service_completed_successfully - volumes: ["./output:/output"] - - backend: - container_name: backend + MINIO_ACCESS_KEY: minio + MINIO_SECRET_KEY: minio1234 + entrypoint: /minio-entrypoint.sh + command: server --address :9001 /data + db: + image: crunchydata/crunchy-postgres-gis:centos7-12.2-4.2.2 + hostname: db + environment: + PG_USER: gwells + PG_PASSWORD: test1 + PG_DATABASE: gwells + PG_MODE: primary + PG_PRIMARY_USER: primaryuser + PG_PRIMARY_PASSWORD: test_primary_password + PG_ROOT_PASSWORD: test_root_password + PG_PRIMARY_PORT: 5432 + TEMP_BUFFERS: 9MB + MAX_CONNECTIONS: 101 + SHARED_BUFFERS: 128MB + MAX_WAL_SENDERS: 7 + WORK_MEM: 5MB + PG_PRIMARY_HOST: db + PGHOST: /tmp + TILESERVER_USER: ftw_reader + TILESERVER_PASSWORD: test1 + ports: + - "5432:5432" + volumes: + - pgdata-volume:/pgdata:z + - type: bind + source: ./app/database/scripts/local_dev/setup.sql + target: /pgconf/setup.sql + consistency: cached + tileserv: + hostname: tileserv depends_on: - migrations: - condition: service_started - entrypoint: sh -c "npm i && npm run start:dev" + - db + image: pramsey/pg_tileserv:latest environment: - <<: *postgres-vars - NODE_ENV: development - image: node:22 - ports: ["3001:3000"] - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3000/api"] - working_dir: "/app" - volumes: ["./backend:/app", "/app/node_modules"] - + DATABASE_URL: postgres://ftw_reader:test1@db:5432/gwells + ports: + - "7800:7800" + entrypoint: sh -c "sleep 10; /app/pg_tileserv" frontend: - container_name: frontend - entrypoint: sh -c "npm ci && npm run dev" + image: node:8.9.4 + hostname: frontend + working_dir: /app/frontend environment: - BACKEND_URL: http://backend:3000 - PORT: 3000 - NODE_ENV: development - image: node:22 - ports: ["3000:3000"] - volumes: ["./frontend:/app", "/app/node_modules"] - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3000"] - working_dir: "/app" + DEBUG: "True" + VUE_APP_AXIOS_BASE_URL: /api/ + VUE_APP_VECTOR_TILE_BASE_URL: "/tiles/" + VECTOR_TILE_SERVER: "http://tileserv:7800/" + CHOKIDAR_USEPOLLING: "True" + API_TARGET: "${API_TARGET}" + command: /bin/bash -c " + set -x && + cd /app/frontend && + npm install && + npm run serve" + ports: + - "8080:8080" + volumes: + - type: bind + source: ./app/frontend + target: /app/frontend + consistency: cached + - /app/frontend/node_modules/ depends_on: - backend: - condition: service_healthy - - caddy: - container_name: caddy - profiles: ["caddy"] - build: ./frontend + - backend + backend: + image: gwells/backend + hostname: backend environment: - NODE_ENV: development - PORT: 3000 - BACKEND_URL: http://backend:3000 - LOG_LEVEL: info - ports: ["3005:3000"] - volumes: ["./frontend/Caddyfile:/etc/caddy/Caddyfile"] - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3000"] + APP_CONTEXT_ROOT: gwells + CSRF_COOKIE_SECURE: "False" + CUSTOM_GDAL_GEOS: "False" + DATABASE_NAME: gwells + DATABASE_USER: gwells + DATABASE_PASSWORD: test1 + DATABASE_SERVICE_NAME: gwells + DJANGO_ADMIN_URL: admin + DJANGO_DEBUG: "True" + DJANGO_SECRET_KEY: secret + ENABLE_ADDITIONAL_DOCUMENTS: "True" + ENABLE_AQUIFERS_SEARCH: "True" + ENABLE_GOOGLE_ANALYTICS: "False" + GWELLS_SERVICE_HOST: db + GWELLS_SERVICE_PORT: 5432 + MINIO_ACCESS_KEY: minio + MINIO_SECRET_KEY: minio1234 + PYTHONUNBUFFERED: "1" + SESSION_COOKIE_SECURE: "False" + SSO_AUDIENCE: gwells-test + SSO_CLIENT: gwells-test + SSO_AUTH_HOST: https://test.oidc.gov.bc.ca/auth + SSO_IDP_HINT: "undefined" + SSO_PORT: 0 + SSO_REALM: gwells + SSO_PUBKEY: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAh+5Hc4w/PKN04avW1LX/orSyXsJ7nJiEbErMyQqCvYAEKmQUeok7Yy+r6sVuJSyQQMCExk37NY3fUQOK92J83oC/9WGij7bvlWHew810edIisechoKpLuQbw63xlj/5ifQfJ977NM1n1RQgXF4hr4MDuhGbV+PAkQGdSPfufjEFleCwj8mvjUwTFnSwE9I+Rf78DVJzCHZbpFMq9skvrpCzeNsLNNoz+k1DENQ6MKnVnbUYskG+j5NZ3g+kxfkRf2G0tw2KisLYtxUSdfwutieT2Zxglk/kZeMWS7khXWzhwjvWf5a1qM5ebreVVYNhra7MjcrkXSh0v5IBcW+122wIDAQAB + S3_HOST: minio-public:9000 + S3_PRIVATE_HOST: minio-private:9001 + S3_PRIVATE_BUCKET: gwells + S3_PRIVATE_ROOT_BUCKET: gwells + S3_PRIVATE_WELL_BUCKET: well-docs + S3_PRIVATE_AQUIFER_BUCKET: aquifer-docs + S3_PRIVATE_REGISTRANT_BUCKET: driller-docs + S3_PUBLIC_ACCESS_KEY: minio + S3_PUBLIC_SECRET_KEY: minio1234 + S3_AQUIFER_BUCKET: aquifer-docs + S3_REGISTRANT_BUCKET: driller-docs + S3_ROOT_BUCKET: gwells + S3_WELL_BUCKET: well-docs + S3_WELL_EXPORT_BUCKET: gwells + S3_USE_SECURE: 0 + command: /bin/bash -c " + sleep 3 && + set -x && + cd /app/backend && + mkdir -p .pip && + python3 -m pip install --upgrade pip && + python3 -m pip install ptvsd && + python3 -m pip install --cache-dir=.pip -r requirements.txt && + python3 manage.py migrate --noinput && + ./load_fixtures.sh all && + python3 manage.py createinitialrevisions && + python3 manage.py collectstatic --noinput && + python3 manage.py export --cleanup=1 --upload=1 && + python3 manage.py runserver 0.0.0.0:8000" + volumes: + - type: bind + source: ./app/backend + target: /app/backend + consistency: cached + ports: + - "8000:8000" + - "3000:3000" depends_on: - backend: - condition: service_healthy + - db +volumes: + pgdata-volume: diff --git a/gwells/CODE_OF_CONDUCT.md b/gwells/CODE_OF_CONDUCT.md deleted file mode 100644 index d225ebb39..000000000 --- a/gwells/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,24 +0,0 @@ -## Contributor Code of Conduct - -As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. - -We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. - -Examples of unacceptable behavior by participants include: - -- The use of sexualized language or imagery -- Personal attacks -- Trolling or insulting/derogatory comments -- Public or private harassment -- Publishing other's private information, such as physical or electronic addresses, without explicit permission -- Other unethical or unprofessional conduct - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. - -By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. - -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a project maintainer at [Christian.Evans@gov.bc.ca](mailto:Christian.Evans@gov.bc.ca). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an incident. - -This Code of Conduct is adapted from the Contributor Covenant, version 1.3.0, available at [http://contributor-covenant.org/version/1/3/0/](http://contributor-covenant.org/version/1/3/0/) diff --git a/gwells/COMPLIANCE.yaml b/gwells/COMPLIANCE.yaml deleted file mode 100644 index 39258666e..000000000 --- a/gwells/COMPLIANCE.yaml +++ /dev/null @@ -1,11 +0,0 @@ -name: compliance -description: | - This document is used to track a projects PIA and STRA - compliance. -spec: - - name: PIA - status: in-progress - last-updated: '2020-01-20T00:04:29.148Z' - - name: STRA - status: completed - last-updated: '2020-01-20T00:04:29.148Z' diff --git a/gwells/LICENSE b/gwells/LICENSE deleted file mode 100644 index 8dada3eda..000000000 --- a/gwells/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - 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. diff --git a/gwells/README.md b/gwells/README.md deleted file mode 100644 index 9943f51db..000000000 --- a/gwells/README.md +++ /dev/null @@ -1,149 +0,0 @@ -[![img](https://img.shields.io/badge/Lifecycle-Stable-97ca00)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md) - -# Groundwater Wells and Aquifers (GWELLS) - -https://apps.nrs.gov.bc.ca/gwells/ - -## Introduction - -The Ministry of Environment receives and processes groundwater data and information related to the construction, alteration and decommissioning of groundwater wells. Well construction and reporting requirements are regulated under the Water Sustainability Act and Groundwater Protection Regulation. The information collected and stored is used by government and other users to help inform decisions related to the management of the groundwater resource in B.C. - -GWELLS, the new groundwater data repository, aims to improve the user experience when submitting and searching for well information, to improve the quality of the data being submitted, and to improve the overall functionality of the system to meet user and regulatory requirements. - -The application is being developed as an open source solution. - -## Table of Contents - -1. [Using the GWELLS API](#Using-the-gwells-api) -1. [Developing GWELLS](#Developing-gwells) - * [Running the GWELLS application locally](#Running-the-GWELLS-application-locally) - * [Authentication](#Authentication) - * [Running tests](#Running-tests) - * [Making pull requests](#Making-pull-requests) -1. [Architecture](#Architecture) -1. [Contributing](#contributing) - * [Code With Us](#code-with-us) -1. [Issues](#issues) -1. [License](#license) - -## Using the GWELLS API - -GWELLS maintains a REST API where public data relating to wells is made available for other applications and services. - -Our Swagger documentation is available at https://apps.nrs.gov.bc.ca/gwells/api/. Some examples of GWELLS endpoints: - -Wells: -```sh -# all wells (paginated) -curl https://apps.nrs.gov.bc.ca/gwells/api/v1/wells - -# all wells in an area bounded by sw_lat, sw_long, ne_lat, and ne_long -curl https://apps.nrs.gov.bc.ca/gwells/api/v1/wells?sw_lat=51.599253&sw_long=-128.220340&ne_lat=52.108192&ne_long=-127.150547 -``` - -Aquifers: -```sh -# all aquifers -curl https://apps.nrs.gov.bc.ca/gwells/api/v1/aquifers -``` - -See the [Swagger documentation](https://apps.nrs.gov.bc.ca/gwells/api/) for more examples. - -## DataBC Export - -GWELLS Api is used by DataBC to export model information and provide well information on the DataBC website. - -The command located in app/backend/gwells/management/commands/export_databc.py is used to pull data from the gwells database and export it for consumption in DataBC. - -If a new field(s) are needed for export, this export_databc.py has raw sql queries that need to be updated with the required fields. Descriptions are also needed for the swagger documentation that are pulled from the db_comment fields in the django models. Both the raw sql queries and the db_comment field on the model need to be updated for new fields. - -## Developing GWELLS - -### Running the GWELLS application locally - -[Clone the GWELLS repository](https://help.github.com/en/articles/cloning-a-repository) and run the application with [Docker](https://store.docker.com/search?type=edition&offering=community): -```sh -cd gwells -docker-compose up -``` - -Visit the following links to browse the API and frontend applications: - -* Django REST API development server: http://localhost:8000/gwells/api/ -* Vue frontend development server: http://localhost:8080/ - -### Authentication - -Some GWELLS pages (submitting new well reports, adding or editing aquifers, or adding or editing qualified well drillers to the registry) require authentication. Authentication uses the Province's Single Sign-On system. A GWELLS team member can request access for collaborators if needed. - -### Running tests: - -Django unit tests: -```sh -cd app/backend -docker-compose exec backend python manage.py test -``` - -Vue unit tests: -```sh -cd app/frontend -docker-compose exec frontend npm run test:unit -``` - -Postman API tests: -Import the json test collections in the `api-tests/` folder into [Postman](https://www.getpostman.com/). - -### Import a Shapefile - -Single shapefile, with aquifer ID specified in CLI. - -``` -docker-compose exec backend python manage.py import_shapefile 2 aquifers/fixtures/shp/shapefile.zip -``` - -Bulk import, requires the AQ_NUMBER attribute on each polygon. Requires a folder with shapefiles to be prepared and passed in (zipped or not). Note: if DEBUG=True, all geometries will be uploaded to a random aquifer instead of the one matching its' number, so we can test locally with a development database. - -``` -mkdir app/backend/bulk -mv DATABC_EXPORT_FILE.zip app/backend/bulk/ - -docker-compose exec backend python manage.py import_bulk_shapefile bulk -``` - -### Importing Licences - -To download new licence data from DataBC and merge it into your DB, do - -``` -docker-compose exec backend python manage.py import_licences -``` - -### Making pull requests - -Pull requests made from branches in the bcgov/gwells repo will kick off a dev pipeline, which runs tests and deploys a preview environment containing your changes. The pull request page will update when the environment is deployed and mandatory checks (unit tests, etc.) pass or fail. - -## Architecture - -GWELLS uses PostgreSQL (with PostGIS), Django REST Framework, and Vue.js. We also use both AWS S3 and a self-hosted Minio service for storing documents. - -Our production and staging environments run on an OpenShift container platform cluster. OpenShift templates for services are located in the `openshift/` folder, along with more information about dev and staging environments on our cluster. - -![GWELLS container diagram](pics/container_diagram.png) - -## Contributing - -Government employees, the public and members of the private sector are encouraged to contribute. Please read and follow our [Code of Conduct](https://github.com/bcgov/gwells/blob/master/CODE_OF_CONDUCT.md). - -All contributors retain original copyright, but are granting a world-wide, royalty-free, perpetual, irrevocable, non-exclusive, transferable license to all users. This project is covered by an [Apache v2.0 license](https://github.com/bcgov/gwells/blob/master/LICENSE). - -### Code With Us - -Many of our features have been developed by members of the community. Check the [BC Developer Exchange website](https://bcdevexchange.org/), where paid opportunities to build features for GWELLS and other applications are posted. - -## Issues - -Issues are tracked on the [Water Jira board](https://apps.nrs.gov.bc.ca/int/jira/projects/WATER/issues). Note this is a restricted issue tracker and you will require permission to be able to view it. - -## License - -Code released under the [Apache License, Version 2.0](https://github.com/bcgov/gwells/blob/master/LICENSE). diff --git a/gwells/docker-compose.yml b/gwells/docker-compose.yml deleted file mode 100644 index 32249e43f..000000000 --- a/gwells/docker-compose.yml +++ /dev/null @@ -1,173 +0,0 @@ -version: '3.7' -# NOTE For Red Hat or other images on the internal registry please login as follows: -# 1. Be logged into the BC Gov OpenShift Console -# https://console.pathfinder.gov.bc.ca:8443/console/catalog) -# 2. Be logged into the BC Gov OpenShift Image Registry via -# docker login -u -p `oc whoami -t` docker-registry.pathfinder.gov.bc.ca -# -# For example: -# docker login -u garywong-bc -p `oc whoami -t` docker-registry.pathfinder.gov.bc.ca -services: - minio-public: - build: - context: ./openshift/docker/minio/ - hostname: minio - ports: - - "9000:9000" - volumes: - - /data - environment: - MINIO_ACCESS_KEY: minio - MINIO_SECRET_KEY: minio1234 - MINIO_DATA_DIR: /data - entrypoint: /minio-entrypoint.sh - command: server /data - minio-private: - build: - context: ./openshift/docker/minio/ - hostname: minio - ports: - - "9001:9001" - volumes: - - /data - environment: - MINIO_ACCESS_KEY: minio - MINIO_SECRET_KEY: minio1234 - entrypoint: /minio-entrypoint.sh - command: server --address :9001 /data - db: - image: crunchydata/crunchy-postgres-gis:centos7-12.2-4.2.2 - hostname: db - environment: - PG_USER: gwells - PG_PASSWORD: test1 - PG_DATABASE: gwells - PG_MODE: primary - PG_PRIMARY_USER: primaryuser - PG_PRIMARY_PASSWORD: test_primary_password - PG_ROOT_PASSWORD: test_root_password - PG_PRIMARY_PORT: 5432 - TEMP_BUFFERS: 9MB - MAX_CONNECTIONS: 101 - SHARED_BUFFERS: 128MB - MAX_WAL_SENDERS: 7 - WORK_MEM: 5MB - PG_PRIMARY_HOST: db - PGHOST: /tmp - TILESERVER_USER: ftw_reader - TILESERVER_PASSWORD: test1 - ports: - - "5432:5432" - volumes: - - pgdata-volume:/pgdata:z - - type: bind - source: ./app/database/scripts/local_dev/setup.sql - target: /pgconf/setup.sql - consistency: cached - tileserv: - hostname: tileserv - depends_on: - - db - image: pramsey/pg_tileserv:latest - environment: - DATABASE_URL: postgres://ftw_reader:test1@db:5432/gwells - ports: - - "7800:7800" - entrypoint: sh -c "sleep 10; /app/pg_tileserv" - frontend: - image: node:8.9.4 - hostname: frontend - working_dir: /app/frontend - environment: - DEBUG: "True" - VUE_APP_AXIOS_BASE_URL: /api/ - VUE_APP_VECTOR_TILE_BASE_URL: "/tiles/" - VECTOR_TILE_SERVER: "http://tileserv:7800/" - CHOKIDAR_USEPOLLING: "True" - API_TARGET: "${API_TARGET}" - command: /bin/bash -c " - set -x && - cd /app/frontend && - npm install && - npm run serve" - ports: - - "8080:8080" - volumes: - - type: bind - source: ./app/frontend - target: /app/frontend - consistency: cached - - /app/frontend/node_modules/ - depends_on: - - backend - backend: - image: gwells/backend - hostname: backend - environment: - APP_CONTEXT_ROOT: gwells - CSRF_COOKIE_SECURE: "False" - CUSTOM_GDAL_GEOS: "False" - DATABASE_NAME: gwells - DATABASE_USER: gwells - DATABASE_PASSWORD: test1 - DATABASE_SERVICE_NAME: gwells - DJANGO_ADMIN_URL: admin - DJANGO_DEBUG: "True" - DJANGO_SECRET_KEY: secret - ENABLE_ADDITIONAL_DOCUMENTS: "True" - ENABLE_AQUIFERS_SEARCH: "True" - ENABLE_GOOGLE_ANALYTICS: "False" - GWELLS_SERVICE_HOST: db - GWELLS_SERVICE_PORT: 5432 - MINIO_ACCESS_KEY: minio - MINIO_SECRET_KEY: minio1234 - PYTHONUNBUFFERED: "1" - SESSION_COOKIE_SECURE: "False" - SSO_AUDIENCE: gwells-test - SSO_CLIENT: gwells-test - SSO_AUTH_HOST: https://test.oidc.gov.bc.ca/auth - SSO_IDP_HINT: "undefined" - SSO_PORT: 0 - SSO_REALM: gwells - SSO_PUBKEY: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAh+5Hc4w/PKN04avW1LX/orSyXsJ7nJiEbErMyQqCvYAEKmQUeok7Yy+r6sVuJSyQQMCExk37NY3fUQOK92J83oC/9WGij7bvlWHew810edIisechoKpLuQbw63xlj/5ifQfJ977NM1n1RQgXF4hr4MDuhGbV+PAkQGdSPfufjEFleCwj8mvjUwTFnSwE9I+Rf78DVJzCHZbpFMq9skvrpCzeNsLNNoz+k1DENQ6MKnVnbUYskG+j5NZ3g+kxfkRf2G0tw2KisLYtxUSdfwutieT2Zxglk/kZeMWS7khXWzhwjvWf5a1qM5ebreVVYNhra7MjcrkXSh0v5IBcW+122wIDAQAB - S3_HOST: minio-public:9000 - S3_PRIVATE_HOST: minio-private:9001 - S3_PRIVATE_BUCKET: gwells - S3_PRIVATE_ROOT_BUCKET: gwells - S3_PRIVATE_WELL_BUCKET: well-docs - S3_PRIVATE_AQUIFER_BUCKET: aquifer-docs - S3_PRIVATE_REGISTRANT_BUCKET: driller-docs - S3_PUBLIC_ACCESS_KEY: minio - S3_PUBLIC_SECRET_KEY: minio1234 - S3_AQUIFER_BUCKET: aquifer-docs - S3_REGISTRANT_BUCKET: driller-docs - S3_ROOT_BUCKET: gwells - S3_WELL_BUCKET: well-docs - S3_WELL_EXPORT_BUCKET: gwells - S3_USE_SECURE: 0 - command: /bin/bash -c " - sleep 3 && - set -x && - cd /app/backend && - mkdir -p .pip && - python3 -m pip install --upgrade pip && - python3 -m pip install ptvsd && - python3 -m pip install --cache-dir=.pip -r requirements.txt && - python3 manage.py migrate --noinput && - ./load_fixtures.sh all && - python3 manage.py createinitialrevisions && - python3 manage.py collectstatic --noinput && - python3 manage.py export --cleanup=1 --upload=1 && - python3 manage.py runserver 0.0.0.0:8000" - volumes: - - type: bind - source: ./app/backend - target: /app/backend - consistency: cached - ports: - - "8000:8000" - - "3000:3000" - depends_on: - - db -volumes: - pgdata-volume: diff --git a/gwells/pics/container_diagram.png b/pics/container_diagram.png similarity index 100% rename from gwells/pics/container_diagram.png rename to pics/container_diagram.png