Skip to content

Commit

Permalink
chore(ci): use vanilla postgres container (#1523)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts authored Aug 16, 2024
1 parent 68a21de commit 7d0b07a
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 51 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jobs:
overwrite: true
parameters:
-p ZONE=${{ inputs.target }}
-p DB_PASSWORD='${{ secrets.DB_PASSWORD }}'
-p FORESTCLIENTAPI_KEY='${{ secrets.FORESTCLIENTAPI_KEY }}'
-p ORACLE_PASSWORD='${{ secrets.ORACLE_PASSWORD }}'
-p ORACLE_SERVICE='${{ vars.ORACLE_SERVICE }}'
Expand All @@ -96,12 +97,10 @@ jobs:
oc_namespace: ${{ vars.OC_NAMESPACE }}
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
file: database/openshift.deploy.yml
file: common/openshift.database.yml
overwrite: false
parameters:
-p TAG=${{ inputs.tag }}
-p ZONE=${{ inputs.target }}
-p DB_PASSWORD='${{ secrets.DB_PASSWORD }}'
${{ github.event_name == 'pull_request' && '-p DB_PVC_SIZE=192Mi' || '' }}
${{ github.event_name == 'pull_request' && '-p MEMORY_REQUEST=100Mi' || '' }}
${{ github.event_name == 'pull_request' && '-p MEMORY_LIMIT=200Mi' || '' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ jobs:
oc_token: ${{ secrets.OC_TOKEN }}
with:
cleanup: label
packages: database backend frontend oracle-api sync
packages: backend frontend oracle-api sync

2 changes: 1 addition & 1 deletion .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
packages: write
strategy:
matrix:
package: [database, backend, frontend, oracle-api, sync]
package: [backend, frontend, oracle-api, sync]
steps:
- uses: bcgov-nr/[email protected]
id: build
Expand Down
4 changes: 2 additions & 2 deletions backend/openshift.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ parameters:
- name: FORESTCLIENTAPI_ADDRESS
value: "https://nr-forest-client-api-prod.api.gov.bc.ca/api"
- name: CPU_REQUEST
value: 15m
value: 25m
- name: CPU_LIMIT
value: 60m
value: 100m
- name: MEMORY_REQUEST
value: 150Mi
- name: MEMORY_LIMIT
Expand Down
File renamed without changes.
35 changes: 5 additions & 30 deletions database/openshift.deploy.yml → common/openshift.database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@ parameters:
- name: ZONE
description: Deployment zone, e.g. pr-### or prod
required: true
- name: TAG
description: Image tag; e.g. PR number, latest or prod
required: true
- name: REGISTRY
description: Container registry to import from (internal is image-registry.openshift-image-registry.svc:5000)
value: ghcr.io
- name: ORG
description: Organization name
value: bcgov
- name: PVC_MOUNT_PATH
description: Where to mount the PVC, subpath (e.g. data/)
value: /var/lib/postgresql
- name: CPU_REQUEST
value: 25m
- name: CPU_LIMIT
Expand All @@ -33,24 +21,9 @@ parameters:
- name: MEMORY_LIMIT
value: 4Gi
- name: DB_PVC_SIZE
description: Volume space available for data, e.g. 512Mi, 2Gi.
displayName: Database Volume Capacity
description: Volume space available for data, e.g. 512Mi, 2Gi
value: 1.8Gi
- name: DB_PASSWORD
description: Password for the PostgreSQL connection user
required: true
objects:
- apiVersion: v1
kind: Secret
metadata:
name: ${NAME}-${ZONE}-${COMPONENT}
labels:
app: ${NAME}-${ZONE}
stringData:
database-name: ${NAME}
database-password: ${DB_PASSWORD}
database-port: "5432"
database-user: ${NAME}
- kind: PersistentVolumeClaim
apiVersion: v1
metadata:
Expand Down Expand Up @@ -93,7 +66,7 @@ objects:
claimName: ${NAME}-${ZONE}-${COMPONENT}
containers:
- name: ${NAME}-${ZONE}
image: ${REGISTRY}/${ORG}/${NAME}/${COMPONENT}:${TAG}
image: postgis/postgis:15-master
resources:
requests:
cpu: ${CPU_REQUEST}
Expand All @@ -111,6 +84,8 @@ objects:
- bash
- '-ce'
- exec pg_isready -U $POSTGRES_USER -d "dbname=$POSTGRES_DB" -h 127.0.0.1 -p 5432
periodSeconds: 30
timeoutSeconds: 10
livenessProbe:
exec:
command:
Expand Down Expand Up @@ -138,7 +113,7 @@ objects:
key: database-user
volumeMounts:
- name: ${NAME}-${ZONE}-${COMPONENT}
mountPath: ${PVC_MOUNT_PATH}
mountPath: /var/lib/postgresql
terminationMessagePath: "/dev/termination-log"
terminationMessagePolicy: File
imagePullPolicy: Always
Expand Down
14 changes: 14 additions & 0 deletions common/openshift.init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ parameters:
- name: ZONE
description: Deployment zone, e.g. pr-### or prod
required: true
- name: DB_PASSWORD
description: Password for the PostgreSQL connection user
required: true
- name: FORESTCLIENTAPI_KEY
required: true
- name: ORACLE_HOST
Expand Down Expand Up @@ -35,6 +38,17 @@ parameters:
description: Cognito user pools web client ID
required: true
objects:
- apiVersion: v1
kind: Secret
metadata:
name: ${NAME}-${ZONE}-database
labels:
app: ${NAME}-${ZONE}
stringData:
database-name: ${NAME}
database-password: ${DB_PASSWORD}
database-port: "5432"
database-user: ${NAME}
- apiVersion: v1
kind: Secret
metadata:
Expand Down
10 changes: 0 additions & 10 deletions database/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ x-frontend: &frontend
services:
database:
container_name: database
build: ./database
image: postgis/postgis:15-master
environment:
<<: *postgres-vars
volumes:
- "/pgdata"
- "./database/init_db:/init_db"
- "./common/init_db:/init_db"
ports: ["5432:5432"]
healthcheck:
test: psql -q -U $${POSTGRES_USER} -d $${POSTGRES_DB} -c 'SELECT 1'
Expand Down
4 changes: 2 additions & 2 deletions oracle-api/openshift.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ parameters:
- name: DOMAIN
value: apps.silver.devops.gov.bc.ca
- name: CPU_REQUEST
value: 15m
value: 25m
- name: CPU_LIMIT
value: 50m
value: 100m
- name: MEMORY_REQUEST
value: 150Mi
- name: MEMORY_LIMIT
Expand Down

0 comments on commit 7d0b07a

Please sign in to comment.