diff --git a/OracleDatabase/SingleInstance/dockerfiles/19.3.0/runOracle.sh b/OracleDatabase/SingleInstance/dockerfiles/19.3.0/runOracle.sh index ca2141a8dd..b5f9b23a41 100755 --- a/OracleDatabase/SingleInstance/dockerfiles/19.3.0/runOracle.sh +++ b/OracleDatabase/SingleInstance/dockerfiles/19.3.0/runOracle.sh @@ -203,7 +203,10 @@ else fi; # Check whether database is up and running -if "$ORACLE_BASE"/"$CHECK_DB_FILE"; then +"$ORACLE_BASE"/"$CHECK_DB_FILE" +status=$? + +if [ $status -eq 0 ]; then echo "#########################" echo "DATABASE IS READY TO USE!" echo "#########################" @@ -222,6 +225,11 @@ else echo "#####################################" fi; +# Exiting the script without waiting on the tail logs +if [ "$1" = "--nowait" ]; then + exit $status; +fi + # Tail on alert log and wait (otherwise container will exit) echo "The following output is now a tail of the alert.log:" tail -f "$ORACLE_BASE"/diag/rdbms/*/*/trace/alert*.log & diff --git a/OracleDatabase/SingleInstance/dockerfiles/21.3.0/runOracle.sh b/OracleDatabase/SingleInstance/dockerfiles/21.3.0/runOracle.sh index da687a57fe..789d62529a 100644 --- a/OracleDatabase/SingleInstance/dockerfiles/21.3.0/runOracle.sh +++ b/OracleDatabase/SingleInstance/dockerfiles/21.3.0/runOracle.sh @@ -242,7 +242,11 @@ else fi; # Check whether database is up and running -if "$ORACLE_BASE"/"$CHECK_DB_FILE"; then +"$ORACLE_BASE"/"$CHECK_DB_FILE" +status=$? + +# Check whether database is up and running +if [ $status -eq 0 ]; then echo "#########################" echo "DATABASE IS READY TO USE!" echo "#########################" @@ -262,6 +266,11 @@ else echo "#####################################" fi; +# Exiting the script without waiting on the tail logs +if [ "$1" = "--nowait" ]; then + exit $status; +fi + # Tail on alert log and wait (otherwise container will exit) echo "The following output is now a tail of the alert.log:" tail -f "$ORACLE_BASE"/diag/rdbms/*/*/trace/alert*.log & diff --git a/OracleDatabase/SingleInstance/extensions/prebuiltdb/Dockerfile b/OracleDatabase/SingleInstance/extensions/prebuiltdb/Dockerfile new file mode 100644 index 0000000000..f32f7335b5 --- /dev/null +++ b/OracleDatabase/SingleInstance/extensions/prebuiltdb/Dockerfile @@ -0,0 +1,35 @@ +# LICENSE UPL 1.0 +# +# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. +# +# ORACLE DOCKERFILES PROJECT +# -------------------------- +# This Dockerfile extends the base container image with pre-created database, intending improved startup in CI/CD pipelines +# +# REQUIREMENTS FOR THIS IMAGE +# ---------------------------------- +# Oracle Single Instance Database container image version 19c onwards +# +# HOW TO BUILD THIS IMAGE +# ----------------------- +# +# Run: +# $ docker build -t . --build-arg BASE_IMAGE=21.3.0-ee +# + +ARG BASE_IMAGE=oracle/database:21.3.0-ee +FROM ${BASE_IMAGE} + +ARG ORACLE_SID +ARG ORACLE_PDB +ARG ORACLE_PWD +ARG ENABLE_ARCHIVELOG + +# Option to enable archivelog in pre-built database +ENV ENABLE_ARCHIVELOG=${ENABLE_ARCHIVELOG:-false} +ENV ORACLE_SID=${ORACLE_SID:-ORCLCDB} +ENV ORACLE_PDB=${ORACLE_PDB:-ORCLPDB1} +ENV ORACLE_PWD=${ORACLE_PWD} + +# Creating the database +RUN $ORACLE_BASE/$RUN_FILE --nowait diff --git a/OracleDatabase/SingleInstance/extensions/prebuiltdb/README.md b/OracleDatabase/SingleInstance/extensions/prebuiltdb/README.md new file mode 100644 index 0000000000..7ac55014f1 --- /dev/null +++ b/OracleDatabase/SingleInstance/extensions/prebuiltdb/README.md @@ -0,0 +1,44 @@ +# Pre-built Database (prebuiltdb) Extension + +This extension extends [the base Oracle Single Instance Database image](../../README.md) in such a way that the resultant image has a pre-built database. So, when a container is started using this extended image, the start-up time is quite fast. + +The configurable parameters while building this extension are as follows: + +- ORACLE_SID +- ORACLE_PDB +- ORACLE_PWD +- ENABLE_ARCHIVELOG + +Example command for building this extension is as: + +``` +./buildExtensions.sh -b -t -x 'prebuiltdb' -o '--build-arg ORACLE_SID= --build-arg ENABLE_ARCHIVELOG=true --build-arg ORACLE_PWD=' +``` + +The detailed instructions for building extensions are [here](../README.md). + +This extended image can be run as follows: + +``` +docker run -dt --name -p :1521 -p :5500 oracle/database:ext +``` + +**NOTE:** +- This extension supports Oracle Single Instance Database container image from version 19.3.0 onwards. +- The user should override 'persistence' to 'null' explicitly while deploying this image on Kubernetes. For example, + +``` +helm install db21c --set image=,persistence=null oracle-db-1.0.0.tgz +``` + +## Advantages + +This extended image includes an already setup database inside the image itself. Although the image size is larger, the startup time of the container includes only the database startup itself, which makes the container startup duration just a couple of seconds. + +This extended image would be very useful in CI/CD scenarios, where database would be used for conducting tests, experiments and the workflow is simple. + +## Limitations + +Some limitations are listed as follows: +- **External volume can not be used** for database persistence (as data files are inside the image itself). +- In Kubernetes environment, **the single replica mode** (i.e. replicas=1) can be used for database deployments. \ No newline at end of file diff --git a/OracleDatabase/SingleInstance/helm-charts/oracle-db/templates/deployment.yaml b/OracleDatabase/SingleInstance/helm-charts/oracle-db/templates/deployment.yaml index e62d149933..8e7a7fb67d 100644 --- a/OracleDatabase/SingleInstance/helm-charts/oracle-db/templates/deployment.yaml +++ b/OracleDatabase/SingleInstance/helm-charts/oracle-db/templates/deployment.yaml @@ -55,16 +55,20 @@ spec: - containerPort: 5500 readinessProbe: exec: - command: [ "/bin/sh", "-c", "$ORACLE_BASE/checkDBLockStatus.sh" ] + command: [ "/bin/sh", "-c", "if [ -f $ORACLE_BASE/checkDBLockStatus.sh ]; then $ORACLE_BASE/checkDBLockStatus.sh ; else $ORACLE_BASE/checkDBStatus.sh; fi " ] initialDelaySeconds: 20 periodSeconds: 40 timeoutSeconds: 20 + {{- if .Values.persistence }} volumeMounts: - mountPath: /opt/oracle/oradata name: datamount + {{- end }} {{- include "oracle-db-env" . | indent 10 }} + {{- if .Values.persistence }} volumes: - name: datamount persistentVolumeClaim: claimName: {{ template "fullname" . }} + {{- end }} diff --git a/OracleDatabase/SingleInstance/helm-charts/oracle-db/templates/pvc.yaml b/OracleDatabase/SingleInstance/helm-charts/oracle-db/templates/pvc.yaml index 4eda42b88c..792c96d35f 100644 --- a/OracleDatabase/SingleInstance/helm-charts/oracle-db/templates/pvc.yaml +++ b/OracleDatabase/SingleInstance/helm-charts/oracle-db/templates/pvc.yaml @@ -3,6 +3,7 @@ # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. # +{{- if .Values.persistence }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -15,3 +16,4 @@ spec: requests: storage: {{ .Values.persistence.size | quote }} storageClassName: {{ .Values.persistence.storageClass | quote }} +{{- end }} diff --git a/OracleDatabase/SingleInstance/helm-charts/oracle-db/values.yaml b/OracleDatabase/SingleInstance/helm-charts/oracle-db/values.yaml index 4a27d04655..f404977a78 100644 --- a/OracleDatabase/SingleInstance/helm-charts/oracle-db/values.yaml +++ b/OracleDatabase/SingleInstance/helm-charts/oracle-db/values.yaml @@ -25,8 +25,9 @@ enable_archivelog: false ## Enable persistence using Persistent Volume Claims ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ +## Override 'persistence' to 'null' using '--set' option, if persistence is not desired (e.g. using the extended image with 'prebuiltdb' extension) persistence: - ## Oracle database data Persistent Volume Storage Class, nfs or block + ## Oracle Database data Persistent Volume Storage Class, nfs or block storageClass: "" size: 100Gi @@ -35,6 +36,7 @@ persistence: availabilityDomain: ## Deploy multiple replicas for fast fail over +## If 'persistence' is 'null' then fast fail over will not happen even if replicas>1 (as no persistence) replicas: 1 ## deploy LoadBalancer service