Skip to content

Pre-built Database extension #2188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 "#########################"
Expand All @@ -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 &
Expand Down
11 changes: 10 additions & 1 deletion OracleDatabase/SingleInstance/dockerfiles/21.3.0/runOracle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "#########################"
Expand All @@ -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 &
Expand Down
35 changes: 35 additions & 0 deletions OracleDatabase/SingleInstance/extensions/prebuiltdb/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <extended_image_name> . --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
44 changes: 44 additions & 0 deletions OracleDatabase/SingleInstance/extensions/prebuiltdb/README.md
Original file line number Diff line number Diff line change
@@ -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 <base-image> -t <target-image> -x 'prebuiltdb' -o '--build-arg ORACLE_SID=<Database SID> --build-arg ENABLE_ARCHIVELOG=true --build-arg ORACLE_PWD=<database-password>'
```

The detailed instructions for building extensions are [here](../README.md).

This extended image can be run as follows:

```
docker run -dt --name <container-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=<image-url>,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.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -15,3 +16,4 @@ spec:
requests:
storage: {{ .Values.persistence.size | quote }}
storageClassName: {{ .Values.persistence.storageClass | quote }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down