diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml
index ee57e4efef..32081bb567 100644
--- a/.github/workflows/merge.yml
+++ b/.github/workflows/merge.yml
@@ -156,6 +156,7 @@ jobs:
parameters:
-p ZONE=${{ env.ZONE }} -p NAME=${{ github.event.repository.name }}
-p PROMOTE=${{ github.repository }}/legacy:${{ env.ZONE }}
+ -p ENVIRONMENT=${{ secrets.OC_NAMESPACE }}
- name: Deploy Processor
uses: bcgov-nr/action-deployer-openshift@v3.0.0
@@ -356,7 +357,8 @@ jobs:
verification_path: health
parameters:
-p ZONE=${{ env.ZONE }} -p NAME=${{ github.event.repository.name }}
- -p PROMOTE=${{ github.repository }}/legacy:${{ env.PREV }}
+ -p PROMOTE=${{ github.repository }}/legacy:${{ env.PREV }}
+ -p ENVIRONMENT=${{ secrets.OC_NAMESPACE }}
- name: Deploy Processor
uses: bcgov-nr/action-deployer-openshift@v3.0.0
diff --git a/.github/workflows/pr-close.yml b/.github/workflows/pr-close.yml
index a0b664e1c5..4f9051d700 100644
--- a/.github/workflows/pr-close.yml
+++ b/.github/workflows/pr-close.yml
@@ -19,3 +19,31 @@ jobs:
with:
cleanup: label
packages: backend common database frontend legacy processor
+
+ tools-cleanup:
+ name: Cleanup tools environment
+ needs: [cleanup]
+ environment: tools
+ runs-on: ubuntu-22.04
+ steps:
+ - name: Remove the PR database
+ continue-on-error: true
+ run: |
+ oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
+ oc project ${{ secrets.OC_NAMESPACE }} # Safeguard!
+ # This removes a new pluggable database, user and service for the PR
+ for i in {1..5}; do
+ POD_NAME=$(oc get pods -l app=nr-forest-client-tools -l deployment=nr-forest-client-tools-legacydb -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
+ if [ -n "$POD_NAME" ]; then
+ echo "Pod found: $POD_NAME"
+ oc exec $POD_NAME -- /opt/oracle/removeDatabase "THE" "PR_${{ github.event.number }}"
+ break
+ else
+ echo "Pod not found, retrying in 10 seconds... ($i/5)"
+ sleep 10
+ fi
+ done
+
+ if [ -z "$POD_NAME" ]; then
+ echo "Failed to find the pod after 5 attempts."
+ fi
diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml
index 0bf382a2bc..581e3e02a1 100644
--- a/.github/workflows/pr-open.yml
+++ b/.github/workflows/pr-open.yml
@@ -49,7 +49,7 @@ jobs:
packages: write
strategy:
matrix:
- package: [backend, common, database, frontend, legacy, processor]
+ package: [backend, database, frontend, legacy, processor]
steps:
- uses: actions/checkout@v4
@@ -63,9 +63,107 @@ jobs:
build_args: |
APP_VERSION=${{ needs.vars.outputs.semver }}-${{ github.event.number }}
+ build-legacydb:
+ name: Builds (legacydb)
+ runs-on: ubuntu-22.04
+ needs: [vars]
+ permissions:
+ packages: write
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: bcgov-nr/action-builder-ghcr@v2.1.0
+ name: Build (Legacy db)
+ with:
+ package: legacydb
+ tag: latest
+ tag_fallback: test
+ triggers: ('legacydb/')
+ build_args: |
+ APP_VERSION=${{ needs.vars.outputs.semver }}-${{ github.event.number }}
+
+ deploy-tools:
+ name: Deploy Tools
+ needs: [build-legacydb, vars]
+ environment: tools
+ env:
+ DOMAIN: apps.silver.devops.gov.bc.ca
+ PREFIX: ${{ needs.vars.outputs.url }}
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Initializing Deployment
+ uses: bcgov-nr/action-deployer-openshift@v3.0.0
+ with:
+ file: legacydb/openshift.deploy.yml
+ oc_namespace: ${{ secrets.OC_NAMESPACE }}
+ oc_server: ${{ secrets.OC_SERVER }}
+ oc_token: ${{ secrets.OC_TOKEN }}
+ overwrite: false
+ parameters:
+ -p ZONE=tools
+ -p ORACLEDB_USER_W=THE
+ -p ORACLEDB_PASSWORD_W=${{ secrets.ORACLEDB_PASSWORD_W }}
+ -p TAG=latest
+
+ - name: Create the PR database
+ continue-on-error: true
+ run: |
+ oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
+ oc project ${{ secrets.OC_NAMESPACE }} # Safeguard!
+ # This creates a new pluggable database for the PR
+ for i in {1..5}; do
+ POD_NAME=$(oc get pods -l app=nr-forest-client-tools -l deployment=nr-forest-client-tools-legacydb -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
+ if [ -n "$POD_NAME" ]; then
+ echo "Pod found: $POD_NAME"
+ oc exec $POD_NAME -- /opt/oracle/createDatabase PR_${{ github.event.number }}
+ break
+ else
+ echo "Pod not found, retrying in 10 seconds... ($i/5)"
+ sleep 10
+ fi
+ done
+
+ if [ -z "$POD_NAME" ]; then
+ echo "Failed to find the pod after 5 attempts."
+ fi
+
+ - name: Create the PR user
+ continue-on-error: true
+ run: |
+ oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
+ oc project ${{ secrets.OC_NAMESPACE }} # Safeguard!
+ # This creates a new pluggable database for the PR
+ for i in {1..5}; do
+ POD_NAME=$(oc get pods -l app=nr-forest-client-tools -l deployment=nr-forest-client-tools-legacydb -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
+ if [ -n "$POD_NAME" ]; then
+ echo "Pod found: $POD_NAME"
+ oc exec $POD_NAME -- /opt/oracle/createAppUser "THE" "${{ secrets.ORACLEDB_PASSWORD_W }}_${{ github.event.number }}" "PR_${{ github.event.number }}"
+ break
+ else
+ echo "Pod not found, retrying in 10 seconds... ($i/5)"
+ sleep 10
+ fi
+ done
+
+ if [ -z "$POD_NAME" ]; then
+ echo "Failed to find the pod after 5 attempts."
+ fi
+
+ - name: Migrate the PR database
+ continue-on-error: true
+ run: |
+ BRANCH_NAME="${{ github.head_ref }}"
+ # Escape slashes and other special characters
+ ESCAPED_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/[\/&]/\\&/g')
+ oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
+ oc project ${{ secrets.OC_NAMESPACE }} # Safeguard!
+ oc create job --from=cronjob/nr-forest-client-tools-migratedb migrate-$(date +%s) --dry-run=client -o yaml | sed "s/value: main/value: ${ESCAPED_BRANCH_NAME}/" | sed "s/value: \"0\"/value: \"${{ github.event.number }}\"/" | oc apply -f -
+
deploy:
name: Deploy Application
- needs: [builds, vars]
+ needs: [deploy-tools, builds, vars]
environment: dev
env:
DOMAIN: apps.silver.devops.gov.bc.ca
@@ -86,11 +184,11 @@ jobs:
-p ZONE=${{ github.event.number }}
-p ORACLEDB_USER=${{ secrets.ORACLEDB_USERNAME }}
-p ORACLEDB_PASSWORD=${{ secrets.ORACLEDB_PASSWORD }}
- -p ORACLEDB_USER_W=${{ secrets.ORACLEDB_USERNAME_W }}
- -p ORACLEDB_PASSWORD_W=${{ secrets.ORACLEDB_PASSWORD_W }}
+ -p ORACLEDB_USER_W=THE
+ -p ORACLEDB_PASSWORD_W=${{ secrets.ORACLEDB_PASSWORD_W }}_${{ github.event.number }}
-p ORACLEDB_DATABASE=${{ secrets.ORACLEDB_DATABASE }}
- -p ORACLEDB_HOST=${{ secrets.ORACLEDB_HOST }}
- -p ORACLEDB_SERVICENAME=${{ secrets.ORACLEDB_SERVICENAME }}
+ -p ORACLEDB_HOST="nr-forest-client-tools-legacydb.d2723f-tools.svc.cluster.local"
+ -p ORACLEDB_SERVICENAME=PR_${{ github.event.number }}
-p ORACLEDB_SECRET=${{ secrets.ORACLEDB_SECRET }}
-p BCREGISTRY_KEY=${{ secrets.BCREGISTRY_KEY }}
-p BCREGISTRY_ACCOUNT=${{ secrets.BCREGISTRY_ACCOUNT }}
@@ -148,6 +246,8 @@ jobs:
parameters:
-p ZONE=${{ github.event.number }}
-p PROMOTE=${{ github.repository }}/legacy:${{ github.event.number }}
+ -p ENVIRONMENT=${{ secrets.OC_NAMESPACE }}
+ -p ORACLEDB_PORT=1521
- name: Deploy Processor
uses: bcgov-nr/action-deployer-openshift@v3.0.0
@@ -235,8 +335,6 @@ jobs:
-p LANDING_URL=${{ needs.vars.outputs.url }}
-p FRONTEND_URL=${{ needs.vars.outputs.url }}
-
-
cypress-run:
name: "User flow test"
runs-on: ubuntu-22.04
diff --git a/common/openshift.init.yml b/common/openshift.init.yml
index c2f31445b0..588f3c2ef3 100644
--- a/common/openshift.init.yml
+++ b/common/openshift.init.yml
@@ -132,29 +132,3 @@ objects:
- podSelector: {}
policyTypes:
- Ingress
- - kind: PersistentVolumeClaim
- apiVersion: v1
- metadata:
- name: ${NAME}-${ZONE}-index
- labels:
- app: ${NAME}-${ZONE}
- spec:
- accessModes:
- - ReadWriteOnce
- resources:
- requests:
- storage: ${IDX_PVC_SIZE}
- storageClassName: netapp-file-standard
- - kind: PersistentVolumeClaim
- apiVersion: v1
- metadata:
- name: ${NAME}-${ZONE}-index-backup
- labels:
- app: ${NAME}-${ZONE}
- spec:
- accessModes:
- - ReadWriteOnce
- resources:
- requests:
- storage: ${IDX_BKP_PVC_SIZE}
- storageClassName: netapp-file-standard
diff --git a/docker-compose.yml b/docker-compose.yml
index bbc318fb79..e179a4a4b4 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -22,7 +22,9 @@ services:
POSTGRES_USER: *POSTGRES_USER
POSTGRES_PASSWORD: *POSTGRES_PASSWORD
POSTGRES_DB: *POSTGRES_DATABASE
- image: postgres:15
+ build:
+ context: database
+ dockerfile: Dockerfile
ports: [5432:5432]
volumes: ["/pgdata"]
healthcheck:
@@ -34,17 +36,28 @@ services:
legacydb:
container_name: oracle
+ #build:
+ # context: legacydb
+ # dockerfile: Dockerfile
environment:
APP_USER_PASSWORD: default
APP_USER: THE
ORACLE_RANDOM_PASSWORD: yes
platform: "linux/amd64"
- image: gvenzl/oracle-xe:21.3.0-slim-faststart
+ image: gvenzl/oracle-free:23.3-slim-faststart
ports: [1521:1521]
- volumes: [/opt/oracle/oradata gvenzl/oracle-xe]
+ volumes: [/opt/oracle/oradata]
healthcheck:
test: [ "CMD-SHELL", "healthcheck.sh" ]
interval: 5s
timeout: 10s
retries: 10
<<: *defaults
+
+ legacyflyway:
+ container_name: flyway
+ image: flyway/flyway
+ command: -url=jdbc:oracle:thin:@legacydb:1521/FREEPDB1 -user=THE -password=default -connectRetries=60 migrate
+ volumes: [./legacy/src/test/resources/db/migration:/flyway/sql]
+ depends_on: [legacydb]
+ <<: *defaults
\ No newline at end of file
diff --git a/legacy/Dockerfile b/legacy/Dockerfile
index 7c8e2e1734..916fbf0f48 100644
--- a/legacy/Dockerfile
+++ b/legacy/Dockerfile
@@ -44,5 +44,7 @@ USER 1001
EXPOSE ${PORT}
HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"'
+ENV SPRING_PROFILES_ACTIVE=container
+
# Startup
-ENTRYPOINT ["/app/nr-forest-client-legacy", "--spring.profiles.active=container"]
\ No newline at end of file
+ENTRYPOINT ["/app/nr-forest-client-legacy"]
\ No newline at end of file
diff --git a/legacy/openshift.deploy.yml b/legacy/openshift.deploy.yml
index bfc62835f2..03b47922e9 100644
--- a/legacy/openshift.deploy.yml
+++ b/legacy/openshift.deploy.yml
@@ -13,6 +13,9 @@ parameters:
- name: ZONE
description: Deployment zone, e.g. pr-### or prod
required: true
+ - name: ENVIRONMENT
+ description: Environment name used by the application
+ value: prod
- name: IMAGE_TAG
description: Image tag to use
value: latest
@@ -25,7 +28,10 @@ parameters:
description: Image (namespace/name:tag) to promote/import
value: bcgov/nr-forest-client-legacy:prod
- name: ORACLEDB_KEYSTORE
- description: Oracle database keystore file
+ description: Oracle database keystore file
+ - name: ORACLEDB_PORT
+ description: Oracle database port
+ value: "1543"
- name: CPU_REQUEST
value: 75m
- name: CPU_LIMIT
@@ -38,8 +44,8 @@ parameters:
description: The amount of storage the cert PVC should have
value: 25Mi
objects:
- - apiVersion: v1
- kind: ImageStream
+ - kind: ImageStream
+ apiVersion: v1
metadata:
labels:
app: ${NAME}-${ZONE}
@@ -54,8 +60,8 @@ objects:
name: ${REGISTRY}/${PROMOTE}
referencePolicy:
type: Local
- - apiVersion: v1
- kind: PersistentVolumeClaim
+ - kind: PersistentVolumeClaim
+ apiVersion: v1
metadata:
labels:
app: ${NAME}-${ZONE}
@@ -67,11 +73,12 @@ objects:
requests:
storage: ${CERT_PVC_SIZE}
storageClassName: netapp-file-standard
- - apiVersion: v1
- kind: DeploymentConfig
+ - kind: DeploymentConfig
+ apiVersion: v1
metadata:
labels:
app: ${NAME}-${ZONE}
+ appkind: ${COMPONENT}
name: ${NAME}-${ZONE}-${COMPONENT}
spec:
replicas: 1
@@ -105,7 +112,7 @@ objects:
claimName: ${NAME}-${ZONE}-${COMPONENT}
initContainers:
- name: ${NAME}-init
- image: ${REGISTRY}/bcgov/${NAME}/common:${ZONE}
+ image: ${REGISTRY}/bcgov/nr-forest-client-commons/certextractor:0.2.0
imagePullPolicy: Always
env:
- name: ORACLEDB_HOST
@@ -119,7 +126,7 @@ objects:
name: ${NAME}-${ZONE}
key: oracle-secret
- name: ORACLEDB_PORT
- value: "1543"
+ value: ${ORACLEDB_PORT}
volumeMounts:
- name: ${NAME}-${ZONE}-certs
mountPath: /cert
@@ -161,7 +168,9 @@ objects:
name: ${NAME}-${ZONE}
key: oracle-service
- name: ORACLEDB_PORT
- value: "1543"
+ value: ${ORACLEDB_PORT}
+ - name: SPRING_PROFILES_ACTIVE
+ value: "container,${ENVIRONMENT}"
- name: ORACLEDB_SECRET
valueFrom:
secretKeyRef:
@@ -204,8 +213,8 @@ objects:
volumeMounts:
- mountPath: /cert
name: ${NAME}-${ZONE}-certs
- - apiVersion: v1
- kind: Service
+ - kind: Service
+ apiVersion: v1
metadata:
labels:
app: ${NAME}-${ZONE}
diff --git a/legacy/pom.xml b/legacy/pom.xml
index 8e0c2ccc95..3674afd27e 100644
--- a/legacy/pom.xml
+++ b/legacy/pom.xml
@@ -100,6 +100,7 @@
runtime
+
org.apache.commons
commons-lang3
@@ -137,12 +138,12 @@
org.testcontainers
- testcontainers
+ junit-jupiter
test
org.testcontainers
- junit-jupiter
+ testcontainers
test
diff --git a/legacy/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java b/legacy/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java
index 51cc5b72c2..0e2851352b 100644
--- a/legacy/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java
+++ b/legacy/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java
@@ -7,8 +7,11 @@
import ca.bc.gov.app.dto.ForestClientContactDto;
import ca.bc.gov.app.dto.ForestClientDto;
import ca.bc.gov.app.dto.ForestClientLocationDto;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.aot.hint.annotation.RegisterReflectionForBinding;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
@Configuration
@RegisterReflectionForBinding({
@@ -22,4 +25,9 @@
ForestClientLocationDto.class
})
public class GlobalServiceConfiguration {
+ @Bean
+ public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
+ return builder.build();
+ }
+
}
diff --git a/legacy/src/main/resources/application-d2723f-dev.yml b/legacy/src/main/resources/application-d2723f-dev.yml
new file mode 100644
index 0000000000..7a3e97af97
--- /dev/null
+++ b/legacy/src/main/resources/application-d2723f-dev.yml
@@ -0,0 +1,3 @@
+spring:
+ r2dbc:
+ url: r2dbc:oracle://${ca.bc.gov.nrs.oracle.host}:${ca.bc.gov.nrs.oracle.port}/${ca.bc.gov.nrs.oracle.service}
\ No newline at end of file
diff --git a/legacy/src/main/resources/application.yml b/legacy/src/main/resources/application.yml
index 49acfd3bd6..ebbbfe95da 100644
--- a/legacy/src/main/resources/application.yml
+++ b/legacy/src/main/resources/application.yml
@@ -21,6 +21,9 @@ spring:
maxIdleTime: 45000
maxCreateConnectionTime: 90000
poolName: FsaLegacyClientConPool
+ jackson:
+ serialization:
+ FAIL_ON_EMPTY_BEANS: false
http:
encoding:
charset: UTF-8
@@ -87,13 +90,12 @@ ca:
service: ${ORACLEDB_SERVICENAME:fsa-forest}
database: ${ORACLEDB_DATABASE:fsa-forest}
host: ${ORACLEDB_HOST:localhost}
- port: ${ORACLEDB_PORT:1521}
+ port: ${ORACLEDB_PORT:1543}
username: ${ORACLEDB_USER:user}
password: ${ORACLEDB_PASSWORD:passwd}
keystore: ${ORACLEDB_KEYSTORE:jssecacerts.jks}
secret: ${ORACLEDB_SECRET:changeit}
-
logging:
pattern:
correlation: "[${spring.application.name:},%X{${X-TRACE-ID:traceId}:-},%X{spanId:-}] "
@@ -116,4 +118,5 @@ spring:
logging:
pattern:
- console: "{\"time\": \"%d{${LOG_DATEFORMAT_PATTERN:yyyy-MM-dd HH:mm:ss.SSS}}\", \"level\": \"${LOG_LEVEL:%5p}\", \"app\":\"${spring.application.name:-}\", \"traceId\":\"%X{${X-TRACE-ID:traceId}:-}\", \"spanId\":\"%X{spanId:-}\", \"pid\": \"${PID: }\", \"thread\": \"%t\", \"source\": \"%logger{63}:%L\", \"message\": \"%m${LOG_EXCEPTION_CONVERSION_WORD:%wEx}\"}%n"
\ No newline at end of file
+ console: "{\"time\": \"%d{${LOG_DATEFORMAT_PATTERN:yyyy-MM-dd HH:mm:ss.SSS}}\", \"level\": \"${LOG_LEVEL:%5p}\", \"app\":\"${spring.application.name:-}\", \"traceId\":\"%X{${X-TRACE-ID:traceId}:-}\", \"spanId\":\"%X{spanId:-}\", \"pid\": \"${PID: }\", \"thread\": \"%t\", \"source\": \"%logger{63}:%L\", \"message\": \"%m${LOG_EXCEPTION_CONVERSION_WORD:%wEx}\"}%n"
+
diff --git a/legacy/src/test/resources/application-default.yml b/legacy/src/test/resources/application-default.yml
index 5cf095ccd3..bfff1f2d30 100644
--- a/legacy/src/test/resources/application-default.yml
+++ b/legacy/src/test/resources/application-default.yml
@@ -5,7 +5,7 @@ server:
spring:
r2dbc:
- url: r2dbc:oracle://${ca.bc.gov.nrs.oracle.host}:${ca.bc.gov.nrs.oracle.port}/${ca.bc.gov.nrs.oracle.database}
+ url: r2dbc:oracle://${ca.bc.gov.nrs.oracle.host}:${ca.bc.gov.nrs.oracle.port}/${ca.bc.gov.nrs.oracle.service}
flyway:
enabled: true
validate-on-migrate: true
@@ -13,7 +13,6 @@ spring:
password: ${ca.bc.gov.nrs.oracle.password}
url: jdbc:oracle:thin:@${ca.bc.gov.nrs.oracle.host}:${ca.bc.gov.nrs.oracle.port}/${ca.bc.gov.nrs.oracle.service}
-
ca:
bc:
gov:
@@ -27,7 +26,3 @@ logging:
springframework.test: OFF
testcontainers: OFF
com.github.dockerjava: OFF
- org.springframework.r2dbc: DEBUG
- io.r2dbc.oracle.QUERY: DEBUG
- io.r2dbc.oracle.PARAM: DEBUG
- ca.bc.gov.app: DEBUG
diff --git a/legacydb/Dockerfile b/legacydb/Dockerfile
new file mode 100644
index 0000000000..6859818fb0
--- /dev/null
+++ b/legacydb/Dockerfile
@@ -0,0 +1,12 @@
+FROM gvenzl/oracle-free:23.3-slim-faststart
+
+COPY --chown=oracle:oracle removeDatabase ${ORACLE_BASE}/removeDatabase
+RUN chmod +x ${ORACLE_BASE}/removeDatabase
+
+USER root
+RUN usermod -u 1011270000 oracle
+USER oracle
+
+HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["sh", "-c", "${ORACLE_BASE}/healthcheck.sh >/dev/null || exit 1"]
+
+ENTRYPOINT ["container-entrypoint.sh"]
\ No newline at end of file
diff --git a/legacydb/openshift.deploy.yml b/legacydb/openshift.deploy.yml
new file mode 100644
index 0000000000..523d9f5a6b
--- /dev/null
+++ b/legacydb/openshift.deploy.yml
@@ -0,0 +1,246 @@
+apiVersion: template.openshift.io/v1
+kind: Template
+labels:
+ app: ${NAME}-${ZONE}
+ app.kubernetes.io/part-of: ${NAME}-${ZONE}
+parameters:
+ - name: NAME
+ description: Product name
+ value: nr-forest-client
+ - name: COMPONENT
+ description: Component name
+ value: legacydb
+ - name: ZONE
+ description: Deployment zone, e.g. pr-### or prod
+ required: true
+ - name: TAG
+ description: Image tag to use
+ value: latest
+ - 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: ORACLEDB_USER_W
+ description: Oracle database user name with write permission
+ required: true
+ - name: ORACLEDB_PASSWORD_W
+ description: Oracle database password with write permission
+ required: true
+ - name: CPU_REQUEST
+ value: 125m
+ - name: CPU_LIMIT
+ value: 500m
+ - name: MEMORY_REQUEST
+ value: 3.5Gi
+ - name: MEMORY_LIMIT
+ value: 4Gi
+objects:
+ - kind: Secret
+ apiVersion: v1
+ metadata:
+ name: ${NAME}-${ZONE}
+ labels:
+ app: ${NAME}-${ZONE}
+ stringData:
+ oracle-user-write: ${ORACLEDB_USER_W}
+ oracle-password-write: ${ORACLEDB_PASSWORD_W}
+ - kind: Deployment
+ apiVersion: apps/v1
+ metadata:
+ name: ${NAME}-${ZONE}-${COMPONENT}
+ labels:
+ app: ${NAME}-${ZONE}
+ appkind: ${NAME}-${COMPONENT}
+ spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ deployment: ${NAME}-${ZONE}-${COMPONENT}
+ strategy:
+ type: Recreate
+ recreateParams:
+ timeoutSeconds: 600
+ activeDeadlineSeconds: 21600
+ template:
+ metadata:
+ name: ${NAME}-${ZONE}-${COMPONENT}
+ labels:
+ app: ${NAME}-${ZONE}
+ deployment: ${NAME}-${ZONE}-${COMPONENT}
+ spec:
+ containers:
+ - name: ${NAME}
+ image: ${REGISTRY}/${ORG}/${NAME}/${COMPONENT}:${TAG}
+ resources:
+ limits:
+ cpu: ${CPU_LIMIT}
+ memory: ${MEMORY_LIMIT}
+ requests:
+ cpu: ${CPU_REQUEST}
+ memory: ${MEMORY_REQUEST}
+ ports:
+ - containerPort: 1521
+ protocol: TCP
+ readinessProbe:
+ exec:
+ command:
+ - healthcheck.sh
+ failureThreshold: 30
+ initialDelaySeconds: 90
+ periodSeconds: 30
+ timeoutSeconds: 5
+ livenessProbe:
+ exec:
+ command:
+ - healthcheck.sh
+ failureThreshold: 30
+ initialDelaySeconds: 120
+ periodSeconds: 30
+ timeoutSeconds: 5
+ env:
+ - name: APP_USER_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: ${NAME}-${ZONE}
+ key: oracle-password-write
+ - name: ORACLE_RANDOM_PASSWORD
+ value: "true"
+ - name: APP_USER
+ valueFrom:
+ secretKeyRef:
+ name: ${NAME}-${ZONE}
+ key: oracle-user-write
+ terminationMessagePath: /dev/termination-log
+ terminationMessagePolicy: File
+ imagePullPolicy: Always
+ restartPolicy: Always
+ terminationGracePeriodSeconds: 30
+ dnsPolicy: ClusterFirst
+ schedulerName: default-scheduler
+ - kind: Service
+ apiVersion: v1
+ metadata:
+ labels:
+ app: ${NAME}-${ZONE}
+ name: ${NAME}-${ZONE}-${COMPONENT}
+ spec:
+ ports:
+ - name: legacydb
+ nodePort: 0
+ port: 1521
+ protocol: TCP
+ targetPort: 1521
+ selector:
+ deployment: ${NAME}-${ZONE}-${COMPONENT}
+ sessionAffinity: None
+ type: ClusterIP
+ - kind: NetworkPolicy
+ apiVersion: networking.k8s.io/v1
+ metadata:
+ name: allow-d2723f-dev-legacy-access
+ namespace: d2723f-tools
+ spec:
+ podSelector: {}
+ policyTypes:
+ - Ingress
+ ingress:
+ - from:
+ - namespaceSelector:
+ matchLabels:
+ environment: dev # Restrict to namespace d2723f-dev
+ name: d2723f # Restrict to namespace d2723f-dev
+ - kind: NetworkPolicy
+ apiVersion: networking.k8s.io/v1
+ metadata:
+ name: allow-same-namespace
+ labels:
+ template: quickstart-network-security-policy
+ spec:
+ podSelector: {}
+ ingress:
+ - from:
+ - podSelector: {}
+ policyTypes:
+ - Ingress
+ - kind: CronJob
+ apiVersion: batch/v1
+ metadata:
+ name: ${NAME}-${ZONE}-migratedb
+ labels:
+ app: ${NAME}-${ZONE}
+ cronjob: ${NAME}-${ZONE}
+ spec:
+ schedule: "0 0 31 2 *"
+ concurrencyPolicy: "Replace"
+ jobTemplate:
+ metadata:
+ labels:
+ app: ${NAME}-${ZONE}
+ cronjob: ${NAME}-${ZONE}
+ spec:
+ template:
+ metadata:
+ labels:
+ app: ${NAME}-${ZONE}
+ cronjob: ${NAME}-${ZONE}
+ spec:
+ initContainers:
+ - name: curl-container
+ image: curlimages/curl
+ command: ["/bin/sh", "-c"]
+ args:
+ - |
+ echo "Downloading zip file from GitHub repository bcgov/nr-forest-client/ branch ${BRANCH_NAME}"
+ curl -L https://github.com/bcgov/nr-forest-client/archive/refs/heads/${BRANCH_NAME}.zip -o /data/nr-forest-client.zip
+
+ unzip -q /data/nr-forest-client.zip -d /data
+ MIGRATION_DIR=$(find "/data" -type d -path "*/legacy/src/test/resources/db/migration" -print -quit)
+
+ # Check if migration directory was found
+ if [ -z "$MIGRATION_DIR" ]; then
+ echo "Migration directory not found!"
+ exit 1
+ fi
+
+ # Move the contents to the target directory
+ mkdir -p "/data/sql"
+ mv "$MIGRATION_DIR"/* "/data/sql"
+
+ # Clean up
+ rm -rf "nr-forest-client*"
+
+ echo "Migration files moved to /data/sql"
+ env:
+ - name: BRANCH_NAME
+ value: "main"
+ volumeMounts:
+ - name: data-volume
+ mountPath: /data
+ containers:
+ - name: flyway
+ image: flyway/flyway
+ command: ["/bin/sh", "-c"]
+ args:
+ - |
+ flyway -url=${FLYWAY_URL}_${PR_NUMBER} -user=${FLYWAY_USER} -password=${FLYWAY_PASSWORD}_${PR_NUMBER} -locations=filesystem:/data/sql migrate
+ env:
+ - name: FLYWAY_URL
+ value: "jdbc:oracle:thin:@nr-forest-client-tools-legacydb.d2723f-tools.svc.cluster.local:1521/PR"
+ - name: FLYWAY_USER
+ value: THE
+ - name: FLYWAY_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: ${NAME}-${ZONE}
+ key: oracle-password-write
+ - name: PR_NUMBER
+ value: "0"
+ volumeMounts:
+ - name: data-volume
+ mountPath: /data
+ restartPolicy: OnFailure
+ volumes:
+ - name: data-volume
+ emptyDir: {}
\ No newline at end of file
diff --git a/legacydb/removeDatabase b/legacydb/removeDatabase
new file mode 100644
index 0000000000..4ef24d6142
--- /dev/null
+++ b/legacydb/removeDatabase
@@ -0,0 +1,62 @@
+#!/bin/bash
+set -Eeuo pipefail
+
+APP_USER="${1}"
+PDB_TO_REMOVE="${2:-}"
+
+# Kill any sessions connected to the user
+if [ -n "${APP_USER}" ]; then
+ sqlplus -s / as sysdba <