From 604a79bbf3f6177f6209a1cb5bf99a5aa3bed739 Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Tue, 8 Oct 2024 16:54:03 -0700 Subject: [PATCH 01/16] Test --- frontend/src/main.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index d04bad8..545ceca 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -6,7 +6,7 @@ import App from './App'; import MainPage from './Views/MainPage/MainPage.tsx'; import ExportPage from './Views/Export/ExportPage.tsx'; -// Test for openshift +// Test const router = createBrowserRouter([ { path: '/', From 9e4fd853f9d65f95546598eaf435a9ae86dc1a14 Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 11:30:44 -0700 Subject: [PATCH 02/16] Commenting out deploy step --- .github/workflows/analysis.yml | 86 +++++++++++++++++----------------- .github/workflows/pr-open.yml | 58 +++++++++++------------ 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 108c8fa..e313e59 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -14,48 +14,48 @@ concurrency: cancel-in-progress: true jobs: - tests: - name: Tests - if: ${{ ! github.event.pull_request.draft }} - runs-on: ubuntu-22.04 - timeout-minutes: 5 - services: - postgres: - image: postgres - env: - POSTGRES_PASSWORD: postgres - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - strategy: - matrix: - dir: [backend, frontend] - include: - - dir: backend - token: SONAR_TOKEN_BACKEND - - dir: frontend - token: SONAR_TOKEN_FRONTEND - steps: - - uses: bcgov-nr/action-test-and-analyse@v1.2.1 - with: - commands: | - npm ci - npm run test:cov - dir: ${{ matrix.dir }} - node_version: "22" - sonar_args: > - -Dsonar.exclusions=**/coverage/**,**/node_modules/**,**/*spec.ts - -Dsonar.organization=bcgov-sonarcloud - -Dsonar.projectKey=quickstart-openshift_${{ matrix.dir }} - -Dsonar.sources=src - -Dsonar.tests.inclusions=**/*spec.ts - -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info - sonar_token: ${{ secrets[matrix.token] }} - triggers: ('${{ matrix.dir }}/') + # tests: + # name: Tests + # if: ${{ ! github.event.pull_request.draft }} + # runs-on: ubuntu-22.04 + # timeout-minutes: 5 + # services: + # postgres: + # image: postgres + # env: + # POSTGRES_PASSWORD: postgres + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # - 5432:5432 + # strategy: + # matrix: + # dir: [backend, frontend] + # include: + # - dir: backend + # token: SONAR_TOKEN_BACKEND + # - dir: frontend + # token: SONAR_TOKEN_FRONTEND + # steps: + # - uses: bcgov-nr/action-test-and-analyse@v1.2.1 + # with: + # commands: | + # npm ci + # npm run test:cov + # dir: ${{ matrix.dir }} + # node_version: "22" + # sonar_args: > + # -Dsonar.exclusions=**/coverage/**,**/node_modules/**,**/*spec.ts + # -Dsonar.organization=bcgov-sonarcloud + # -Dsonar.projectKey=quickstart-openshift_${{ matrix.dir }} + # -Dsonar.sources=src + # -Dsonar.tests.inclusions=**/*spec.ts + # -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info + # sonar_token: ${{ secrets[matrix.token] }} + # triggers: ('${{ matrix.dir }}/') # https://github.com/marketplace/actions/aqua-security-trivy trivy: @@ -82,7 +82,7 @@ jobs: results: name: Analysis Results - needs: [tests, trivy] + # needs: [tests, trivy] if: always() runs-on: ubuntu-22.04 steps: diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 3d72ca1..307dd94 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -12,10 +12,10 @@ jobs: # https://github.com/bcgov-nr/action-builder-ghcr builds: name: Builds - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: - package: [backend, frontend, migrations] + package: [backend, frontend] timeout-minutes: 10 steps: - uses: bcgov-nr/action-builder-ghcr@v2.2.0 @@ -27,32 +27,32 @@ jobs: triggers: ('${{ matrix.package }}/') # https://github.com/bcgov/quickstart-openshift-helpers - deploys: - name: Deploys - needs: [builds] - uses: bcgov/quickstart-openshift-helpers/.github/workflows/.deployer.yml@v0.6.1 - secrets: - oc_namespace: ${{ secrets.OC_NAMESPACE }} - oc_token: ${{ secrets.OC_TOKEN }} - with: - triggers: ('backend/' 'frontend/' 'migrations/') - params: - --set global.secrets.persist=false + # deploys: + # name: Deploys + # needs: [builds] + # uses: bcgov/quickstart-openshift-helpers/.github/workflows/.deployer.yml@v0.6.1 + # secrets: + # oc_namespace: ${{ secrets.OC_NAMESPACE }} + # oc_token: ${{ secrets.OC_TOKEN }} + # with: + # triggers: ('backend/' 'frontend/' 'migrations/') + # params: + # --set global.secrets.persist=false - tests: - name: Tests - if: needs.deploys.outputs.triggered == 'true' - needs: [deploys] - uses: ./.github/workflows/.tests.yml - with: - target: ${{ github.event.number }} + # tests: + # name: Tests + # if: needs.deploys.outputs.triggered == 'true' + # needs: [deploys] + # uses: ./.github/workflows/.tests.yml + # with: + # target: ${{ github.event.number }} - results: - name: PR Results - needs: [builds, deploys, tests] - if: always() - runs-on: ubuntu-22.04 - steps: - - if: contains(needs.*.result, 'failure') - run: echo "At least one job has failed." && exit 1 - - run: echo "Success!" + # results: + # name: PR Results + # needs: [builds, deploys, tests] + # if: always() + # runs-on: ubuntu-22.04 + # steps: + # - if: contains(needs.*.result, 'failure') + # run: echo "At least one job has failed." && exit 1 + # - run: echo "Success!" From b0db1f75fa5ed013bf28736944ab908d072799f5 Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 11:46:09 -0700 Subject: [PATCH 03/16] WIP --- .github/workflows/pr-open.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 307dd94..3c9dcb0 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: package: [backend, frontend] - timeout-minutes: 10 + timeout-minutes: 20 steps: - uses: bcgov-nr/action-builder-ghcr@v2.2.0 with: From 099f90a63064de5ce88d25d1ed253359adb8e0c2 Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 13:54:21 -0700 Subject: [PATCH 04/16] WIP --- .github/workflows/pr-open.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 3c9dcb0..9fdae4e 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -13,6 +13,8 @@ jobs: builds: name: Builds runs-on: ubuntu-latest + permissions: + packages: write strategy: matrix: package: [backend, frontend] From 663305ebc1b42779f07095f02c3e3b65bb70f457 Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 13:58:30 -0700 Subject: [PATCH 05/16] WIP --- .github/workflows/pr-open.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 9fdae4e..7d781ce 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -12,12 +12,12 @@ jobs: # https://github.com/bcgov-nr/action-builder-ghcr builds: name: Builds - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 permissions: packages: write strategy: matrix: - package: [backend, frontend] + package: [backend, database, frontend] timeout-minutes: 20 steps: - uses: bcgov-nr/action-builder-ghcr@v2.2.0 From 1e63c0da261714bfd77291248dc3ba4efc002087 Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 14:18:52 -0700 Subject: [PATCH 06/16] WIP --- .github/workflows/pr-open.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 7d781ce..5582cab 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: bcgov-nr/action-builder-ghcr@v2.2.0 with: - keep_versions: 50 + # keep_versions: 50 package: ${{ matrix.package }} tag: ${{ github.event.number }} tag_fallback: latest From 20dd86339f7551eaf31872b680425331b13f62ba Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 14:22:21 -0700 Subject: [PATCH 07/16] WIP --- .github/workflows/pr-open.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 5582cab..9d7150f 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -13,8 +13,8 @@ jobs: builds: name: Builds runs-on: ubuntu-22.04 - permissions: - packages: write + # permissions: + # packages: write strategy: matrix: package: [backend, database, frontend] @@ -22,7 +22,7 @@ jobs: steps: - uses: bcgov-nr/action-builder-ghcr@v2.2.0 with: - # keep_versions: 50 + keep_versions: 50 package: ${{ matrix.package }} tag: ${{ github.event.number }} tag_fallback: latest From 23bb45c6c37878d518be8694af69fcafd7dfc412 Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 14:28:33 -0700 Subject: [PATCH 08/16] WIP --- .github/workflows/deploy.yml | 73 +++++++++++++++++++++++++++++++++++ .github/workflows/pr-open.yml | 34 ++++++---------- 2 files changed, 85 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..dce0172 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,73 @@ +name: .Deploys + +on: + workflow_call: + inputs: + environment: + description: GitHub environment; e.g. PR number (omit), TEST or PROD + required: false + type: string + tag: + description: Image tag; e.g. PR number or latest + default: ${{ github.event.number }} + required: false + type: string + target: + description: Deployment target; e.g. PR number (omit), test or prod + default: ${{ github.event.number }} + required: false + type: string + +jobs: + database: + name: Database + environment: ${{ inputs.environment }} + runs-on: ubuntu-22.04 + steps: + - name: Deploy Database + uses: bcgov-nr/action-deployer-openshift@v3.0.0 + with: + oc_namespace: ${{ vars.OC_NAMESPACE }} + oc_server: ${{ vars.OC_SERVER }} + oc_token: ${{ secrets.OC_TOKEN }} + file: database/openshift.deploy.yml + overwrite: false + parameters: + -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} + + backend: + name: Backend + needs: [database] + environment: ${{ inputs.environment }} + runs-on: ubuntu-22.04 + steps: + - name: Deploy Backend + uses: bcgov-nr/action-deployer-openshift@v3.0.0 + with: + oc_namespace: ${{ vars.OC_NAMESPACE }} + oc_server: ${{ vars.OC_SERVER }} + oc_token: ${{ secrets.OC_TOKEN }} + file: backend/openshift.deploy.yml + overwrite: true + parameters: + -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} + verification_path: /api/health + verification_retry_attempts: "5" + verification_retry_seconds: "15" + + frontend: + name: Frontend + needs: [backend] + environment: ${{ inputs.environment }} + runs-on: ubuntu-22.04 + steps: + - name: Deploy Frontend + uses: bcgov-nr/action-deployer-openshift@v3.0.0 + with: + oc_namespace: ${{ vars.OC_NAMESPACE }} + oc_server: ${{ vars.OC_SERVER }} + oc_token: ${{ secrets.OC_TOKEN }} + file: frontend/openshift.deploy.yml + overwrite: true + parameters: + -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 9d7150f..324cbdf 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -13,8 +13,6 @@ jobs: builds: name: Builds runs-on: ubuntu-22.04 - # permissions: - # packages: write strategy: matrix: package: [backend, database, frontend] @@ -29,17 +27,11 @@ jobs: triggers: ('${{ matrix.package }}/') # https://github.com/bcgov/quickstart-openshift-helpers - # deploys: - # name: Deploys - # needs: [builds] - # uses: bcgov/quickstart-openshift-helpers/.github/workflows/.deployer.yml@v0.6.1 - # secrets: - # oc_namespace: ${{ secrets.OC_NAMESPACE }} - # oc_token: ${{ secrets.OC_TOKEN }} - # with: - # triggers: ('backend/' 'frontend/' 'migrations/') - # params: - # --set global.secrets.persist=false + deploy: + name: Deploy + needs: [builds] + secrets: inherit + uses: ./.github/workflows/.deploy.yml # tests: # name: Tests @@ -49,12 +41,10 @@ jobs: # with: # target: ${{ github.event.number }} - # results: - # name: PR Results - # needs: [builds, deploys, tests] - # if: always() - # runs-on: ubuntu-22.04 - # steps: - # - if: contains(needs.*.result, 'failure') - # run: echo "At least one job has failed." && exit 1 - # - run: echo "Success!" + results: + name: PR Results + needs: [builds, deploy] + if: always() + runs-on: ubuntu-22.04 + steps: + - run: echo "Success!" From 7ea92c202a85f28ee616b2508937c74160237e81 Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 14:34:32 -0700 Subject: [PATCH 09/16] WIP --- .github/workflows/merge.yml | 80 ++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index b3f68af..f785d84 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -34,44 +34,44 @@ jobs: uses: bcgov-nr/action-get-pr@v0.0.1 # https://github.com/bcgov/quickstart-openshift-helpers - deploy-test: - name: Deploy (test) - uses: bcgov/quickstart-openshift-helpers/.github/workflows/.deployer.yml@v0.6.1 - secrets: - oc_namespace: ${{ secrets.OC_NAMESPACE }} - oc_token: ${{ secrets.OC_TOKEN }} - with: - environment: test + # deploy-test: + # name: Deploy (test) + # uses: bcgov/quickstart-openshift-helpers/.github/workflows/.deployer.yml@v0.6.1 + # secrets: + # oc_namespace: ${{ secrets.OC_NAMESPACE }} + # oc_token: ${{ secrets.OC_TOKEN }} + # with: + # environment: test - deploy-prod: - name: Deploy (prod) - needs: [deploy-test, vars] - uses: bcgov/quickstart-openshift-helpers/.github/workflows/.deployer.yml@v0.6.1 - secrets: - oc_namespace: ${{ secrets.OC_NAMESPACE }} - oc_token: ${{ secrets.OC_TOKEN }} - with: - environment: prod - params: - --set backend.deploymentStrategy=RollingUpdate - --set frontend.deploymentStrategy=RollingUpdate - --set global.autoscaling=true - --set frontend.pdb.enabled=true - --set backend.pdb.enabled=true - promote: - name: Promote Images - needs: [deploy-prod, vars] - runs-on: ubuntu-22.04 - permissions: - packages: write - strategy: - matrix: - package: [migrations, backend, frontend] - timeout-minutes: 1 - steps: - - uses: shrink/actions-docker-registry-tag@v4 - with: - registry: ghcr.io - repository: ${{ github.repository }}/${{ matrix.package }} - target: ${{ needs.vars.outputs.pr }} - tags: prod + # deploy-prod: + # name: Deploy (prod) + # needs: [deploy-test, vars] + # uses: bcgov/quickstart-openshift-helpers/.github/workflows/.deployer.yml@v0.6.1 + # secrets: + # oc_namespace: ${{ secrets.OC_NAMESPACE }} + # oc_token: ${{ secrets.OC_TOKEN }} + # with: + # environment: prod + # params: + # --set backend.deploymentStrategy=RollingUpdate + # --set frontend.deploymentStrategy=RollingUpdate + # --set global.autoscaling=true + # --set frontend.pdb.enabled=true + # --set backend.pdb.enabled=true + # promote: + # name: Promote Images + # needs: [deploy-prod, vars] + # runs-on: ubuntu-22.04 + # permissions: + # packages: write + # strategy: + # matrix: + # package: [migrations, backend, frontend] + # timeout-minutes: 1 + # steps: + # - uses: shrink/actions-docker-registry-tag@v4 + # with: + # registry: ghcr.io + # repository: ${{ github.repository }}/${{ matrix.package }} + # target: ${{ needs.vars.outputs.pr }} + # tags: prod From 06a54949c66121f03a9e75d0a73f20cbd56e44dd Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 14:37:54 -0700 Subject: [PATCH 10/16] WIP --- .github/workflows/{deploy.yml => .deploy.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{deploy.yml => .deploy.yml} (100%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/.deploy.yml similarity index 100% rename from .github/workflows/deploy.yml rename to .github/workflows/.deploy.yml From e6dee617fa81760f013d6a5e2d2110860d7ea3fc Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 14:58:46 -0700 Subject: [PATCH 11/16] WIP --- .github/workflows/.deploy.yml | 70 +++++++++++++++++------------------ .github/workflows/pr-open.yml | 6 +-- backend/openshift.deploy.yml | 2 +- database/openshift.deploy.yml | 2 +- frontend/openshift.deploy.yml | 4 +- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/.github/workflows/.deploy.yml b/.github/workflows/.deploy.yml index dce0172..5717677 100644 --- a/.github/workflows/.deploy.yml +++ b/.github/workflows/.deploy.yml @@ -35,39 +35,39 @@ jobs: parameters: -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} - backend: - name: Backend - needs: [database] - environment: ${{ inputs.environment }} - runs-on: ubuntu-22.04 - steps: - - name: Deploy Backend - uses: bcgov-nr/action-deployer-openshift@v3.0.0 - with: - oc_namespace: ${{ vars.OC_NAMESPACE }} - oc_server: ${{ vars.OC_SERVER }} - oc_token: ${{ secrets.OC_TOKEN }} - file: backend/openshift.deploy.yml - overwrite: true - parameters: - -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} - verification_path: /api/health - verification_retry_attempts: "5" - verification_retry_seconds: "15" + # backend: + # name: Backend + # needs: [database] + # environment: ${{ inputs.environment }} + # runs-on: ubuntu-22.04 + # steps: + # - name: Deploy Backend + # uses: bcgov-nr/action-deployer-openshift@v3.0.0 + # with: + # oc_namespace: ${{ vars.OC_NAMESPACE }} + # oc_server: ${{ vars.OC_SERVER }} + # oc_token: ${{ secrets.OC_TOKEN }} + # file: backend/openshift.deploy.yml + # overwrite: true + # parameters: + # -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} + # verification_path: /api/health + # verification_retry_attempts: "5" + # verification_retry_seconds: "15" - frontend: - name: Frontend - needs: [backend] - environment: ${{ inputs.environment }} - runs-on: ubuntu-22.04 - steps: - - name: Deploy Frontend - uses: bcgov-nr/action-deployer-openshift@v3.0.0 - with: - oc_namespace: ${{ vars.OC_NAMESPACE }} - oc_server: ${{ vars.OC_SERVER }} - oc_token: ${{ secrets.OC_TOKEN }} - file: frontend/openshift.deploy.yml - overwrite: true - parameters: - -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} + # frontend: + # name: Frontend + # needs: [backend] + # environment: ${{ inputs.environment }} + # runs-on: ubuntu-22.04 + # steps: + # - name: Deploy Frontend + # uses: bcgov-nr/action-deployer-openshift@v3.0.0 + # with: + # oc_namespace: ${{ vars.OC_NAMESPACE }} + # oc_server: ${{ vars.OC_SERVER }} + # oc_token: ${{ secrets.OC_TOKEN }} + # file: frontend/openshift.deploy.yml + # overwrite: true + # parameters: + # -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 324cbdf..9f24b4c 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - package: [backend, database, frontend] + package: [database] timeout-minutes: 20 steps: - uses: bcgov-nr/action-builder-ghcr@v2.2.0 @@ -27,7 +27,7 @@ jobs: triggers: ('${{ matrix.package }}/') # https://github.com/bcgov/quickstart-openshift-helpers - deploy: + deploys: name: Deploy needs: [builds] secrets: inherit @@ -43,7 +43,7 @@ jobs: results: name: PR Results - needs: [builds, deploy] + needs: [builds, deploys] if: always() runs-on: ubuntu-22.04 steps: diff --git a/backend/openshift.deploy.yml b/backend/openshift.deploy.yml index b3c00cf..e4ee7f9 100644 --- a/backend/openshift.deploy.yml +++ b/backend/openshift.deploy.yml @@ -3,7 +3,7 @@ kind: Template parameters: - name: APP description: Application name - value: nr-sustainment-capstone-2024 + value: nr-nmp - name: COMPONENT description: Component name value: backend diff --git a/database/openshift.deploy.yml b/database/openshift.deploy.yml index 64ca97f..b4fbc9e 100644 --- a/database/openshift.deploy.yml +++ b/database/openshift.deploy.yml @@ -3,7 +3,7 @@ kind: Template parameters: - name: APP description: Application name - value: nr-sustainment-capstone-2024 + value: nr-nmp - name: COMPONENT description: Component name value: database diff --git a/frontend/openshift.deploy.yml b/frontend/openshift.deploy.yml index 8713790..099a4bb 100644 --- a/frontend/openshift.deploy.yml +++ b/frontend/openshift.deploy.yml @@ -3,7 +3,7 @@ kind: Template parameters: - name: APP description: Application name - value: nr-sustainment-capstone-2024 + value: nr-nmp - name: COMPONENT description: Component name value: frontend @@ -101,7 +101,7 @@ objects: app: ${APP}-${TARGET} name: ${APP}-${TARGET}-${COMPONENT} spec: - host: better-berries-${TARGET}.apps.silver.devops.gov.bc.ca + host: nr-nmp-${TARGET}.apps.silver.devops.gov.bc.ca port: targetPort: http-5173 to: From b45ad800dced09ebd0d6d412cf6f6e0bc5f1ceec Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 15:02:32 -0700 Subject: [PATCH 12/16] WIP --- .github/workflows/pr-open.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 9f24b4c..0208289 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - package: [database] + package: [database, backend] timeout-minutes: 20 steps: - uses: bcgov-nr/action-builder-ghcr@v2.2.0 From 25c113f2c85da070559f216da9cc2d3893e6921e Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 15:06:23 -0700 Subject: [PATCH 13/16] WIP --- .github/workflows/.deploy.yml | 38 +++++++++++++++++------------------ .github/workflows/pr-open.yml | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/.deploy.yml b/.github/workflows/.deploy.yml index 5717677..1c64129 100644 --- a/.github/workflows/.deploy.yml +++ b/.github/workflows/.deploy.yml @@ -35,25 +35,25 @@ jobs: parameters: -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} - # backend: - # name: Backend - # needs: [database] - # environment: ${{ inputs.environment }} - # runs-on: ubuntu-22.04 - # steps: - # - name: Deploy Backend - # uses: bcgov-nr/action-deployer-openshift@v3.0.0 - # with: - # oc_namespace: ${{ vars.OC_NAMESPACE }} - # oc_server: ${{ vars.OC_SERVER }} - # oc_token: ${{ secrets.OC_TOKEN }} - # file: backend/openshift.deploy.yml - # overwrite: true - # parameters: - # -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} - # verification_path: /api/health - # verification_retry_attempts: "5" - # verification_retry_seconds: "15" + backend: + name: Backend + needs: [database] + environment: ${{ inputs.environment }} + runs-on: ubuntu-22.04 + steps: + - name: Deploy Backend + uses: bcgov-nr/action-deployer-openshift@v3.0.0 + with: + oc_namespace: ${{ vars.OC_NAMESPACE }} + oc_server: ${{ vars.OC_SERVER }} + oc_token: ${{ secrets.OC_TOKEN }} + file: backend/openshift.deploy.yml + overwrite: true + parameters: + -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} + verification_path: /api/health + verification_retry_attempts: "5" + verification_retry_seconds: "15" # frontend: # name: Frontend diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 0208289..e7537cf 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - package: [database, backend] + package: [database, backend, frontend] timeout-minutes: 20 steps: - uses: bcgov-nr/action-builder-ghcr@v2.2.0 From 31d0ff09eb030d60d7ee2939b3585e983fe27d83 Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 15:13:22 -0700 Subject: [PATCH 14/16] WIP --- .github/workflows/.deploy.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/.deploy.yml b/.github/workflows/.deploy.yml index 1c64129..dce0172 100644 --- a/.github/workflows/.deploy.yml +++ b/.github/workflows/.deploy.yml @@ -55,19 +55,19 @@ jobs: verification_retry_attempts: "5" verification_retry_seconds: "15" - # frontend: - # name: Frontend - # needs: [backend] - # environment: ${{ inputs.environment }} - # runs-on: ubuntu-22.04 - # steps: - # - name: Deploy Frontend - # uses: bcgov-nr/action-deployer-openshift@v3.0.0 - # with: - # oc_namespace: ${{ vars.OC_NAMESPACE }} - # oc_server: ${{ vars.OC_SERVER }} - # oc_token: ${{ secrets.OC_TOKEN }} - # file: frontend/openshift.deploy.yml - # overwrite: true - # parameters: - # -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} + frontend: + name: Frontend + needs: [backend] + environment: ${{ inputs.environment }} + runs-on: ubuntu-22.04 + steps: + - name: Deploy Frontend + uses: bcgov-nr/action-deployer-openshift@v3.0.0 + with: + oc_namespace: ${{ vars.OC_NAMESPACE }} + oc_server: ${{ vars.OC_SERVER }} + oc_token: ${{ secrets.OC_TOKEN }} + file: frontend/openshift.deploy.yml + overwrite: true + parameters: + -p TAG=${{ inputs.tag }} -p TARGET=${{ inputs.target }} From 78d6d2405e60e01c6b0901f42cca49074485d2f9 Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 15:49:51 -0700 Subject: [PATCH 15/16] WIP --- frontend/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index c66902c..182be49 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -12,6 +12,7 @@ RUN groupadd --gid ${APP_USER} appGroup && \ USER ${APP_USER} WORKDIR /app/ COPY --chown=${APP_USER} . ./ +COPY vite.config.ts /app/ RUN npm i && \ npm run build From ed2522bc37b6ac12be78637c45400097ea3300c2 Mon Sep 17 00:00:00 2001 From: Dallas Richmond Date: Wed, 9 Oct 2024 16:00:25 -0700 Subject: [PATCH 16/16] WIP --- frontend/Dockerfile | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 182be49..e6d1b4f 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,6 +1,7 @@ # Base image for the container FROM node:20.17.0 +# Set environment variables ENV npm_config_cache=/app/.npm ENV APP_USER=1011540000 @@ -8,13 +9,26 @@ ENV APP_USER=1011540000 RUN groupadd --gid ${APP_USER} appGroup && \ useradd --uid ${APP_USER} --gid appGroup --home /app ${APP_USER} -# Copy files, install dependencies and build +# Switch to the new user USER ${APP_USER} + +# Set the working directory WORKDIR /app/ + +# Copy package.json and package-lock.json first to leverage Docker cache +COPY --chown=${APP_USER} package.json package-lock.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of the application code COPY --chown=${APP_USER} . ./ -COPY vite.config.ts /app/ -RUN npm i && \ - npm run build -# Run in production mode, `npm run dev` for dev mode +# Ensure TypeScript is installed and compile the project +RUN npm run build + +# Expose the port that the app runs on +EXPOSE 5173 + +# Run the application in production mode CMD ["npm", "run", "serve", "--no-update-notifier", "--max-old-space-size=50"]