generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b31518
commit 6bc93e7
Showing
8 changed files
with
192 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/[email protected] | ||
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/[email protected] | ||
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/[email protected] | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/[email protected] | ||
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/[email protected] | ||
# 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: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,44 +34,44 @@ jobs: | |
uses: bcgov-nr/[email protected] | ||
|
||
# https://github.com/bcgov/quickstart-openshift-helpers | ||
deploy-test: | ||
name: Deploy (test) | ||
uses: bcgov/quickstart-openshift-helpers/.github/workflows/[email protected] | ||
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/[email protected] | ||
# 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/[email protected] | ||
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/[email protected] | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ jobs: | |
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
package: [backend, frontend, migrations] | ||
timeout-minutes: 10 | ||
package: [database, backend, frontend] | ||
timeout-minutes: 20 | ||
steps: | ||
- uses: bcgov-nr/[email protected] | ||
with: | ||
|
@@ -28,31 +28,23 @@ jobs: | |
|
||
# https://github.com/bcgov/quickstart-openshift-helpers | ||
deploys: | ||
name: Deploys | ||
name: Deploy | ||
needs: [builds] | ||
uses: bcgov/quickstart-openshift-helpers/.github/workflows/[email protected] | ||
secrets: | ||
oc_namespace: ${{ secrets.OC_NAMESPACE }} | ||
oc_token: ${{ secrets.OC_TOKEN }} | ||
with: | ||
triggers: ('backend/' 'frontend/' 'migrations/') | ||
params: | ||
--set global.secrets.persist=false | ||
secrets: inherit | ||
uses: ./.github/workflows/.deploy.yml | ||
|
||
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] | ||
needs: [builds, deploys] | ||
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!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
# Base image for the container | ||
FROM node:20.17.0 | ||
|
||
# Set environment variables | ||
ENV npm_config_cache=/app/.npm | ||
ENV APP_USER=1011540000 | ||
|
||
# Create user and group | ||
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} . ./ | ||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters