This web application is intended to replace the current access based tool which will soon be deprecated. This application will be an essential tool for the business areas for planning and tracking of capital and rehabilitation maintenance projects for the Ministry of Transportation and Infrastructure.
- .Net 7
- Node.JS v13.7.0 or newer
- Microsoft SQL Server 2017 or newer
- Working KeyCloak Realm with BC Gov IDIR
- Ministry of Transportation and Infrastructure GeoServer access
- IDIR service account with access to LDAP service
Use the following steps to configure the local development environment
-
Clone the repository
git clone https://github.com/bcgov/crt.git -
Create the CRT_DEV database in MS SQL Server
- Delete all existing tables
- Run scripts in
database/V01.1directory - Apply incremental scripts
(Vxx.x to Vxx.x)in ascending order - Create the first admin user in
CRT_SYSTEM_USERtable and assign theSYSTEM_ADMINrole in theCRT_USER_ROLEtable
-
Configure API Server settings
- Copy
api/Crt.API/appsettigns.jsontoapi/Crt.API/appsettigns.Development.json - Update the placeholder values with real values, eg., replace the
<app-id>with actual KeyCloak client id in the{ "JWT": { "Audience": "<app-id>" } }field - Update the connection string to match the database
- Make note of or update the port for the API Server in Visual Studio or through the
properties/launchSettings.jsonfile.
- Copy
-
Configure the React development settings
- Create the
client/.env.development.localfile and add the following content
# use port value from step 3 REACT_APP_API_HOST=http://localhost:<api-port> REACT_APP_SSO_HOST=https://dev.ocid.gov.bc.ca/auth REACT_APP_SSO_CLIENT=<client-id> REACT_APP_SSO_REALM=<realm-id> REACT_APP_DEFAULT_PAGE_SIZE_OPTIONS=25,50,100,200 REACT_APP_DEFAULT_PAGE_SIZE=25 # Optional, default port is 3000 # PORT=3001- Replace the placeholder values
- Create the
Use the following steps to run the local development environment
-
Run the API Server
- F5 in Visual Studio
- Or from console
cd api/Crt.Api dotnet restore dotnet build dotnet run -
Run the React frontend
cd client npm install npm start
Deployments are managed through GitHub Actions and the CRT GitOps repository (bcgov-c/tenant-gitops-2d982c). The current deploy workflow is CD - Update GitOps repository, defined in .github/workflows/argo-cd.yml.
The deploy workflow updates the image tag in the target GitOps values file:
argocd/env-apps/values-dev.yamlargocd/env-apps/values-test.yamlargocd/env-apps/values-uat.yamlargocd/env-apps/values-prod.yaml
It then promotes the api, client, and twm GHCR images by adding the environment tag.
- Create a branch and open a pull request against
master. - The Build and Push to GHCR workflow builds PR images for
api,client, andtwm. - To deploy the pull request to
dev, comment/deployon the pull request. - After testing and merge, use Create Test rc Tag to create an
rc_*tag and optionally deploy it totest. - To promote a release candidate to production, use Create Production v Tag and optionally deploy it to
prod.
Pull requests should not be merged until the Builds Required status check passes. This check waits for the full Builds matrix in the Build and Push to GHCR workflow and fails if any component image build fails, is cancelled, or is skipped unexpectedly.
Configure the master branch protection rule or ruleset in GitHub to require the Builds Required status check before merging.
Comment /deploy on an open pull request to deploy that pull request's images to dev.
The CD - Deploy PR Comment workflow listens for pull request comments, verifies that the commenter has repository write, maintain, or admin access, checks that api, client, and twm images exist for the PR tag, and then calls CD - Update GitOps repository with:
environment:devtag:pr-<pull-request-number>
/deploy dev is also accepted. Other /deploy ... variants are ignored by this workflow.
After the workflow updates GitOps, Argo CD must sync the change before it reaches OpenShift.
Use CD - Update GitOps repository to deploy an existing image tag to dev, test, uat, or prod.
- Open Actions in GitHub.
- Select CD - Update GitOps repository.
- Select Run workflow.
- Choose the target
environment:dev,test,uat, orprod. - Enter the
tagto deploy. - Run the workflow.
Accepted tag inputs include:
sha-xxxxxxx, such assha-a1b2c3d- A full or short git commit SHA, which the workflow normalizes to
sha-xxxxxxx - An existing image tag, such as
pr-123,rc_1.2.3, orv1.2.3
The tag should already exist in GHCR for api, client, and twm before deploying.
Use Create Test rc Tag to create a release candidate tag from a git commit and optionally deploy it to test.
- Open Actions in GitHub.
- Select Create Test rc Tag.
- Select Run workflow.
- Enter
build_shaaslatest, a git ref, a full SHA, a short SHA, orsha-xxxxxxx. - Enter
rc_tagin the formatrc_x.y.z, such asrc_1.2.3. - Leave
deploy_to_tstenabled to deploy the RC tag totest, or disable it to only create the tag and GitHub pre-release. - Optionally enable
dry_runto validate the inputs without creating tags or deploying.
This workflow creates the RC git tag, retags the api, client, and twm images from the matching sha-xxxxxxx image tag to the RC tag, creates a GitHub pre-release, and calls CD - Update GitOps repository when deployment is enabled.
Use Create Production v Tag to promote an existing rc_* tag to a production v* tag and optionally deploy it to prod.
- Open Actions in GitHub.
- Select Create Production v Tag.
- Select Run workflow.
- Enter the source
rc_tag, such asrc_1.2.3. - Enable
deploy_to_prdif the production tag should be deployed immediately. - Run the workflow.