Skip to content

Commit 4012a81

Browse files
authored
Merge pull request #1361 from bcgov/test
Create Latest Release
2 parents 1a3c96e + 9ec8b25 commit 4012a81

File tree

67 files changed

+1107
-459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1107
-459
lines changed

.env.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ NEXT_PUBLIC_HELP_ISSUE_URL=https://github.com/bcgov/api-services-portal/issues
3636
NEXT_PUBLIC_HELP_API_DOCS_URL=/ds/api/v3/console/
3737
NEXT_PUBLIC_HELP_SUPPORT_URL=https://dev.developer.gov.bc.ca/docs/default/component/aps-infra-platform-docs/
3838
NEXT_PUBLIC_HELP_RELEASE_URL=https://dev.developer.gov.bc.ca/docs/default/component/aps-infra-platform-docs/reference/releases/
39-
NEXT_PUBLIC_HELP_STATUS_URL=https://uptime.com/s/bcgov-dss
39+
NEXT_PUBLIC_HELP_STATUS_URL=https://status.api.gov.bc.ca/
4040
NEXT_PUBLIC_DEVELOPER_IDS=idir,bceid,bcsc,github
4141
NEXT_PUBLIC_PROVIDER_IDS=idir
4242
NEXT_PUBLIC_ACCOUNT_BCEID_URL=https://www.test.bceid.ca/logon.aspx?returnUrl=/profile_management

.github/workflows/aps-cypress-e2e.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ env:
1616
GIT_COMMIT_AUTHOR: ${{ github.actor }}
1717
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
1818
GIT_REPO_URL: ${{ github.repository }}
19+
# Optional: avoids npm 403 from registry when multiple images run npm install in parallel
20+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1921

2022
jobs:
2123
cypress-run:
2224
runs-on: ubuntu-latest
2325
steps:
2426
- name: Build GWA API Image
2527
run: |
26-
git clone https://github.com/bcgov/gwa-api.git --branch v1.0.40
28+
git clone https://github.com/bcgov/gwa-api.git --branch v1.0.47
2729
cd gwa-api/microservices/gatewayApi
2830
docker build -t gwa-api:e2e .
2931

.github/workflows/ci-build-deploy.yaml

Lines changed: 149 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -92,65 +92,142 @@ jobs:
9292
if: github.ref != 'refs/heads/dev'
9393
run: |
9494
export PATH=$PATH:`pwd`/linux-amd64
95-
96-
echo '
97-
image:
98-
registry: docker.pkg.github.com
99-
repository: bcgov-dss/api-serv-infra/mongodb
100-
tag: 5.0-7a639fba
101-
pullPolicy: IfNotPresent
102-
pullSecrets:
103-
- dev-github-read-packages-creds
104-
105-
auth:
106-
rootPassword: "s3cr3t"
107-
108-
serviceAccount:
109-
create: false
110-
name: asp-service-account
111-
112-
arbiter:
113-
enabled: false
114-
115-
rbac:
116-
create: true
117-
118-
updateStrategy:
119-
type: RollingUpdate
120-
rollingUpdate:
121-
maxSurge: 0
122-
maxUnavailable: 100%
123-
124-
readinessProbe:
125-
timeoutSeconds: 30
126-
periodSeconds: 120
127-
128-
livenessProbe:
129-
timeoutSeconds: 30
130-
periodSeconds: 120
131-
132-
persistence:
133-
enabled: true
134-
size: 2Gi
135-
136-
resources:
137-
requests:
138-
cpu: 85m
139-
memory: 480M
140-
limits:
141-
cpu: 300m
142-
memory: 720M
143-
144-
podSecurityContext:
145-
enabled: true
146-
fsGroup: ${{ secrets.RUNNING_UID_GID }}
147-
148-
containerSecurityContext:
149-
enabled: true
150-
runAsUser: ${{ secrets.RUNNING_UID_GID }}
151-
' > values.yaml
152-
helm repo add bitnami https://charts.bitnami.com/bitnami
153-
helm upgrade --install proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-db --version 12.1.31 -f values.yaml --history-max 3 bitnami/mongodb
95+
DEPLOY_ID="${{ steps.set-deploy-id.outputs.DEPLOY_ID }}"
96+
DB_NAME="proto-asp-${DEPLOY_ID}-db"
97+
98+
# ConfigMap to create Keystone user and database on first Postgres start
99+
oc create configmap "${DB_NAME}-init" --from-literal=1-init.sql="CREATE ROLE keystonejsuser WITH LOGIN PASSWORD 'keystonejsuser'; CREATE DATABASE keystonejs OWNER keystonejsuser;" --dry-run=client -o yaml | oc apply -f -
100+
101+
# ConfigMap with Keystone schema (run by Job after Postgres is up)
102+
oc create configmap "${DB_NAME}-keystone-schema" --from-file=keystone-init.sql=local/db/keystone-init.sql --dry-run=client -o yaml | oc apply -f -
103+
104+
# PVC for Postgres data (persistence)
105+
cat <<EOF | oc apply -f -
106+
apiVersion: v1
107+
kind: PersistentVolumeClaim
108+
metadata:
109+
name: ${DB_NAME}-data
110+
spec:
111+
accessModes: [ReadWriteOnce]
112+
resources:
113+
requests:
114+
storage: ${{ startsWith(github.ref_name, 'feature/') && '1Gi' || '2Gi' }}
115+
EOF
116+
117+
# Postgres 15 Deployment (public image)
118+
cat <<EOF | oc apply -f -
119+
apiVersion: apps/v1
120+
kind: Deployment
121+
metadata:
122+
name: ${DB_NAME}
123+
spec:
124+
replicas: 1
125+
selector:
126+
matchLabels:
127+
app: ${DB_NAME}
128+
strategy:
129+
type: Recreate
130+
template:
131+
metadata:
132+
labels:
133+
app: ${DB_NAME}
134+
spec:
135+
containers:
136+
- name: postgres
137+
image: postgres:15
138+
ports:
139+
- containerPort: 5432
140+
env:
141+
- name: POSTGRES_USER
142+
value: postgres
143+
- name: POSTGRES_PASSWORD
144+
value: "s3cr3t"
145+
- name: PGDATA
146+
value: /var/lib/postgresql/data/pgdata
147+
volumeMounts:
148+
- name: data
149+
mountPath: /var/lib/postgresql/data
150+
- name: init
151+
mountPath: /docker-entrypoint-initdb.d
152+
resources:
153+
requests:
154+
cpu: 50m
155+
memory: 128Mi
156+
limits:
157+
memory: 256Mi
158+
volumes:
159+
- name: data
160+
persistentVolumeClaim:
161+
claimName: ${DB_NAME}-data
162+
- name: init
163+
configMap:
164+
name: ${DB_NAME}-init
165+
readinessProbe:
166+
exec:
167+
command: [pg_isready, -U, postgres]
168+
initialDelaySeconds: 5
169+
periodSeconds: 5
170+
timeoutSeconds: 5
171+
livenessProbe:
172+
exec:
173+
command: [pg_isready, -U, postgres]
174+
initialDelaySeconds: 30
175+
periodSeconds: 10
176+
timeoutSeconds: 5
177+
EOF
178+
179+
# Service for Postgres
180+
cat <<EOF | oc apply -f -
181+
apiVersion: v1
182+
kind: Service
183+
metadata:
184+
name: ${DB_NAME}
185+
spec:
186+
ports:
187+
- port: 5432
188+
targetPort: 5432
189+
name: postgres
190+
selector:
191+
app: ${DB_NAME}
192+
EOF
193+
194+
# Wait for Postgres to be ready
195+
oc rollout status deployment/${DB_NAME} --timeout=300s
196+
197+
# Run Keystone schema (Job)
198+
cat <<EOF | oc apply -f -
199+
apiVersion: batch/v1
200+
kind: Job
201+
metadata:
202+
name: ${DB_NAME}-keystone-init
203+
spec:
204+
ttlSecondsAfterFinished: 300
205+
backoffLimit: 5
206+
template:
207+
spec:
208+
restartPolicy: OnFailure
209+
containers:
210+
- name: run-schema
211+
image: postgres:15
212+
command:
213+
- /bin/sh
214+
- -c
215+
- |
216+
until PGPASSWORD=keystonejsuser psql -h ${DB_NAME} -U keystonejsuser -d keystonejs -c '\q' 2>/dev/null; do echo "Waiting for DB..."; sleep 2; done
217+
PGPASSWORD=keystonejsuser psql -h ${DB_NAME} -U keystonejsuser -d keystonejs -f /schema/keystone-init.sql
218+
env:
219+
- name: PGPASSWORD
220+
value: "keystonejsuser"
221+
volumeMounts:
222+
- name: schema
223+
mountPath: /schema
224+
volumes:
225+
- name: schema
226+
configMap:
227+
name: ${DB_NAME}-keystone-schema
228+
EOF
229+
230+
oc wait --for=condition=complete job/${DB_NAME}-keystone-init --timeout=300s
154231
155232
- name: 'Deploy Backend'
156233
if: github.ref != 'refs/heads/dev'
@@ -296,14 +373,20 @@ jobs:
296373
value: Oauth2Proxy
297374
KONG_URL:
298375
value: '${{ secrets.KONG_URL_DEV}}'
299-
MONGO_URL:
300-
value: 'mongodb://proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-db-mongodb:27017'
301-
MONGO_USER:
302-
value: root
376+
ADAPTER:
377+
value: knex
378+
KNEX_HOST:
379+
value: 'proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-db'
380+
KNEX_PORT:
381+
value: '5432'
382+
KNEX_USER:
383+
value: keystonejsuser
303384
secure: true
304-
MONGO_PASSWORD:
305-
value: s3cr3t
385+
KNEX_PASSWORD:
386+
value: keystonejsuser
306387
secure: true
388+
KNEX_DATABASE:
389+
value: keystonejs
307390
FEEDER_URL:
308391
value: 'http://proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-feeder-generic-api'
309392
GITHUB_API_TOKEN:
@@ -336,7 +419,7 @@ jobs:
336419
NEXT_PUBLIC_HELP_RELEASE_URL:
337420
value: 'https://developer.gov.bc.ca/docs/default/component/aps-infra-platform-docs/reference/releases/'
338421
NEXT_PUBLIC_HELP_STATUS_URL:
339-
value: 'https://uptime.com/s/bcgov-dss'
422+
value: 'https://status.api.gov.bc.ca/'
340423
NEXT_PUBLIC_DEVELOPER_IDS:
341424
value: 'idir,bceid,bcsc,github'
342425
NEXT_PUBLIC_PROVIDER_IDS:

.github/workflows/ci-feat-sonar.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ jobs:
1919
with:
2020
fetch-depth: 0
2121

22+
- name: Install deps
23+
run: |
24+
sudo apt update
25+
2226
- uses: actions/setup-node@v2
2327
with:
24-
node-version: '14'
28+
node-version: '22'
2529

2630
- name: Run Tests
2731
run: |
@@ -36,7 +40,7 @@ jobs:
3640
3741
cd src
3842
39-
npm i
43+
npm i --legacy-peer-deps
4044
npm run intg-build
4145
npm test
4246
@@ -45,13 +49,6 @@ jobs:
4549
4650
- name: SonarCloud Scan
4751
uses: sonarsource/sonarqube-scan-action@master
48-
with:
49-
args: >
50-
-Dsonar.organization=bcgov-oss
51-
-Dsonar.projectKey=aps-portal
52-
-Dsonar.host.url=https://sonarcloud.io
53-
-Dsonar.sources=src/auth,src/authz,src/batch,src/services
54-
-Dsonar.javascript.lcov.reportPaths=./src/__coverage__/lcov.info
5552
env:
5653
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5754
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/ci-remove.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ name: Delete Deployment
22

33
on:
44
delete:
5-
branches: [dev, main, feature/*]
65

76
jobs:
87
delete:
8+
name: Delete deployment
9+
if: github.event.ref_type == 'branch' && (startsWith(github.event.ref, 'refs/heads/feature/') || startsWith(github.event.ref, 'feature/'))
910
runs-on: ubuntu-latest
1011
steps:
1112
- name: Set DEPLOY_ID which will delete a custom deploy from 'dev' environment
@@ -41,11 +42,23 @@ jobs:
4142
curl -L -O https://get.helm.sh/helm-v3.4.2-linux-amd64.tar.gz
4243
tar -xf helm-v3.4.2-linux-amd64.tar.gz
4344
44-
- name: 'Delete ALL'
45+
- name: 'Delete DB (Postgres k8s resources)'
46+
run: |
47+
DEPLOY_ID="${{ steps.set-deploy-id.outputs.DEPLOY_ID }}"
48+
DB_NAME="proto-asp-${DEPLOY_ID}-db"
49+
oc delete deployment "${DB_NAME}" --ignore-not-found=true
50+
oc delete service "${DB_NAME}" --ignore-not-found=true
51+
oc delete pvc "${DB_NAME}-data" --ignore-not-found=true
52+
oc delete configmap "${DB_NAME}-init" "${DB_NAME}-keystone-schema" --ignore-not-found=true
53+
oc delete job "${DB_NAME}-keystone-init" --ignore-not-found=true
54+
55+
- name: 'Delete ALL (Helm releases)'
4556
run: |
4657
export PATH=$PATH:`pwd`/linux-amd64
4758
48-
helm delete proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-db
59+
# for old MongoDB Helm releases
60+
helm delete proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-db --ignore-not-found
61+
4962
helm delete proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}
5063
helm delete proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-routes
5164
helm delete proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-feeder

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@ Use the following configuration to run the Portal locally (outside of Docker) ag
7272
1. Start the OAuth2 Proxy locally:
7373

7474
```sh
75+
# mac
7576
hostip=$(ifconfig en0 | awk '$1 == "inet" {print $2}')
7677

78+
# WSL
79+
hostip=$(hostname -I | awk '{print $1}')
80+
7781
docker run -ti --rm --name proxy --net=host \
7882
--add-host portal.localtest.me:$hostip \
7983
-v `pwd`/local/oauth2-proxy/oauth2-proxy-dev.yaml:/oauth2.yaml \

0 commit comments

Comments
 (0)