-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Extension to support patching in 19.3 docker images #1695
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1113fe7
added patching extension to support patching in Docker images
rishabh20 c77980d
added script patchDBBinaries.sh which patches the oracle home with th…
rishabh20 e0d31ad
added script savePatchSummary.sh which saves the installed patches su…
rishabh20 367d11c
added script runDatapatch.sh which runs datapatch if datafiles are at…
rishabh20 d1cda68
added script buildExtensions.sh which builds all the extensions prese…
rishabh20 3f70cff
updated README for patching and buildExtensions.sh usage
rishabh20 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Build Extensions | ||
|
||
After creating the base image using buildDockerImage.sh, use buildExtensions.sh to build an extended image that will include all features present under the extensions folder. | ||
|
||
Once you have created the base image, go into the **extensions** folder and run the **buildExtensions.sh** script: | ||
|
||
[oracle@localhost dockerfiles]$ ./buildExtensions.sh -h | ||
|
||
Usage: buildExtensions.sh -a -x [extensions] -b [base image] -t [image name] [-o] [Docker build option] | ||
Builds one of more Docker Image Extensions. | ||
|
||
Parameters: | ||
-a: Build all extensions | ||
-x: Space separated extensions to build. Defaults to all | ||
Choose from : patching | ||
-b: Base image to use | ||
-t: name:tag for the extended image | ||
-o: passes on Docker build option | ||
|
||
LICENSE UPL 1.0 | ||
|
||
Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
|
||
The resulting image can be used in the same fashion as the base image. |
148 changes: 148 additions & 0 deletions
148
OracleDatabase/SingleInstance/extensions/buildExtensions.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
#!/bin/bash -e | ||
# | ||
# Since: Mar, 2020 | ||
# Author: [email protected] | ||
# Description: Build script for building Docker Image Extensions | ||
# | ||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
# | ||
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
# | ||
|
||
SCRIPT_DIR=$(dirname $0) | ||
SCRIPT_NAME=$(basename $0) | ||
|
||
usage() { | ||
cat << EOF | ||
|
||
Usage: $SCRIPT_NAME -a -x [extensions] -b [base image] -t [image name] [-o] [Docker build option] | ||
Builds one of more Docker Image Extensions. | ||
|
||
Parameters: | ||
-a: Build all extensions | ||
-x: Space separated extensions to build. Defaults to all | ||
Choose from : $(for i in $(cd "$SCRIPT_DIR" && ls -d */); do echo -n "${i%%/} "; done) | ||
-b: Base image to use | ||
-t: name:tag for the extended image | ||
-o: passes on Docker build option | ||
|
||
LICENSE UPL 1.0 | ||
|
||
Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
|
||
EOF | ||
|
||
} | ||
|
||
############## | ||
#### MAIN #### | ||
############## | ||
|
||
# Parameters | ||
DOCKEROPS="" | ||
DOCKERFILE="Dockerfile" | ||
BASE_IMAGE="oracle/database:19.3.0-ee" | ||
IMAGE_NAME="oracle/database:ext" | ||
|
||
if [ "$#" -eq 0 ]; then | ||
usage; | ||
exit 1; | ||
fi | ||
|
||
while getopts "ax:b:t:o:h" optname; do | ||
case "$optname" in | ||
a) | ||
EXTENSIONS=$(for i in $(cd "$SCRIPT_DIR" && ls -d */); do echo -n "${i%%/} "; done) | ||
;; | ||
x) | ||
EXTENSIONS="$OPTARG" | ||
;; | ||
b) | ||
BASE_IMAGE="$OPTARG" | ||
;; | ||
t) | ||
IMAGE_NAME="$OPTARG" | ||
;; | ||
o) | ||
DOCKEROPS="$OPTARG" | ||
;; | ||
h|?) | ||
usage; | ||
exit 1; | ||
;; | ||
*) | ||
# Should not occur | ||
echo "Unknown error while processing options inside buildDockerImage.sh" | ||
;; | ||
esac | ||
done | ||
|
||
echo "==========================" | ||
echo "DOCKER info:" | ||
docker info | ||
echo "==========================" | ||
|
||
# Proxy settings | ||
PROXY_SETTINGS="" | ||
if [ "${http_proxy}" != "" ]; then | ||
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg http_proxy=${http_proxy}" | ||
fi | ||
|
||
if [ "${https_proxy}" != "" ]; then | ||
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg https_proxy=${https_proxy}" | ||
fi | ||
|
||
if [ "${ftp_proxy}" != "" ]; then | ||
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg ftp_proxy=${ftp_proxy}" | ||
fi | ||
|
||
if [ "${no_proxy}" != "" ]; then | ||
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg no_proxy=${no_proxy}" | ||
fi | ||
|
||
if [ "$PROXY_SETTINGS" != "" ]; then | ||
echo "Proxy settings were found and will be used during the build." | ||
fi | ||
|
||
# ################## # | ||
# BUILDING THE IMAGE # | ||
# ################## # | ||
|
||
BUILD_START=$(date '+%s') | ||
|
||
cd "$SCRIPT_DIR" | ||
for x in $EXTENSIONS; do | ||
echo "Building extension $x..." | ||
# Go into version folder | ||
cd "$x" || { | ||
echo "Could not find extension directory '$x'"; | ||
exit 1; | ||
} | ||
docker build --force-rm=true --build-arg BASE_IMAGE="$BASE_IMAGE" \ | ||
$DOCKEROPS $PROXY_SETTINGS -t $IMAGE_NAME -f $DOCKERFILE . || { | ||
echo "" | ||
echo "ERROR: Oracle Database Docker Image was NOT successfully created." | ||
echo "ERROR: Check the output and correct any reported problems with the docker build operation." | ||
exit 1 | ||
} | ||
BASE_IMAGE="$IMAGE_NAME" | ||
cd .. | ||
done | ||
|
||
# Remove dangling images (intermitten images with tag <none>) | ||
docker image prune -f > /dev/null | ||
|
||
BUILD_END=$(date '+%s') | ||
BUILD_ELAPSED=`expr $BUILD_END - $BUILD_START` | ||
|
||
echo "" | ||
echo "" | ||
|
||
cat<<EOF | ||
Oracle Database Docker Image extended: | ||
|
||
--> $IMAGE_NAME | ||
|
||
Build completed in $BUILD_ELAPSED seconds. | ||
|
||
EOF |
67 changes: 67 additions & 0 deletions
67
OracleDatabase/SingleInstance/extensions/patching/Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# LICENSE UPL 1.0 | ||
# | ||
# Copyright (c) 1982-2020 Oracle and/or its affiliates. All rights reserved. | ||
# | ||
# ORACLE DOCKERFILES PROJECT | ||
# -------------------------- | ||
# This is the Dockerfile for Oracle Database with patching support | ||
# | ||
# REQUIREMETNS FOR THIS IMAGE | ||
# ---------------------------------- | ||
# | ||
# | ||
# HOW TO BUILD THIS IMAGE | ||
# ----------------------- | ||
# | ||
# Run: | ||
# $ docker build -t <extended_image_name> . --build-arg BASE_IMAGE=oracle/database:18.3.0-ee | ||
# | ||
# Pull base image | ||
# --------------- | ||
ARG BASE_IMAGE=oracle/database:19.3.0-ee | ||
FROM ${BASE_IMAGE} as patching | ||
|
||
# Environment variables required for this build (do NOT change) | ||
# ------------------------------------------------------------- | ||
ENV HOST_PATCH_DIR="patches" \ | ||
PATCH_DIR=/opt/install/patches \ | ||
PATCH_DB_BINARIES_FILE="patchDBBinaries.sh" | ||
|
||
# Copy DB patches | ||
COPY --chown=oracle:dba $HOST_PATCH_DIR $PATCH_DB_BINARIES_FILE $PATCH_DIR/ | ||
|
||
# Apply DB Patch | ||
RUN chmod ug+x $PATCH_DIR/*.sh && \ | ||
sync && \ | ||
$PATCH_DIR/$PATCH_DB_BINARIES_FILE && \ | ||
rm -rf $PATCH_DIR/* $ORACLE_HOME/.patch_storage | ||
|
||
|
||
## New stage for minimal layer size | ||
FROM ${BASE_IMAGE} | ||
ENV DATAPATCH_FILE="runDatapatch.sh" \ | ||
LSPATCHES_FILE="savePatchSummary.sh" | ||
|
||
# Extn name | ||
ARG EXTENSION_NAME="patching" | ||
|
||
# Copying patched oracle_base from previous layer | ||
COPY --chown=oracle:dba --from=patching $ORACLE_BASE $ORACLE_BASE | ||
|
||
# Copy script to run datapatch | ||
COPY --chown=oracle:dba $DATAPATCH_FILE $ORACLE_BASE/scripts/startup | ||
RUN chmod ug+x $ORACLE_BASE/scripts/startup/*.sh && sync | ||
|
||
# Copy script to run lspatches | ||
COPY --chown=oracle:dba $LSPATCHES_FILE $ORACLE_BASE/scripts/setup | ||
RUN chmod ug+x $ORACLE_BASE/scripts/setup/*.sh && sync | ||
|
||
# backup origin runOracle | ||
RUN mv "$ORACLE_BASE/$RUN_FILE" "$ORACLE_BASE/$RUN_FILE.$EXTENSION_NAME" | ||
|
||
# Copy updated runOracle.sh | ||
COPY --chown=oracle:dba $RUN_FILE $ORACLE_BASE/ | ||
RUN chmod ug+x $ORACLE_BASE/*.sh && sync | ||
|
||
# Append a call to main runOracle | ||
RUN echo -e "\n. $ORACLE_BASE/$RUN_FILE.$EXTENSION_NAME" >> "$ORACLE_BASE/$RUN_FILE" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# PATCH APPLICATION | ||
|
||
Applies patches on oracle home. Multiple one-offs can be applied in a single build but only 1 RU can be applied. | ||
|
||
Download the release update and one-offs and place them under extensions/patching/patches directory inside subfolders release_update and one_offs respectively. | ||
|
||
Once the patches have been placed in the correct directories, use the buildExtensions.sh script to build the extended image with patch support. | ||
63 changes: 63 additions & 0 deletions
63
OracleDatabase/SingleInstance/extensions/patching/patchDBBinaries.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
# LICENSE UPL 1.0 | ||
# | ||
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
# | ||
# Since: March, 2020 | ||
# Author: [email protected] | ||
# Description: Applies the patches provided by the user on the oracle home. | ||
# | ||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
# | ||
|
||
RU_DIR="${PATCH_DIR}/release_update" | ||
ONE_OFFS_DIR="${PATCH_DIR}/one_offs" | ||
|
||
ru_count=$(ls $RU_DIR/*.zip 2> /dev/null | wc -l) | ||
if [ $ru_count -ge 2 ]; then | ||
echo "Error: Only 1 Release Update can be applied." | ||
exit 1; | ||
elif [ $ru_count == 1 ]; then | ||
ru_patch="$(ls $RU_DIR/*.zip)" | ||
echo "Unzipping $ru_patch"; | ||
unzip -qo $ru_patch -d $PATCH_DIR; | ||
ru_patch=$(echo ${ru_patch##*/} | cut -d_ -f1 | cut -dp -f2) | ||
else | ||
echo "No Release Update to be installed." | ||
fi | ||
|
||
ONE_OFFS_LIST=() | ||
|
||
if ls $ONE_OFFS_DIR/*.zip 2> /dev/null; then | ||
for patch_zip in $ONE_OFFS_DIR/*.zip; do | ||
patch_no=$(echo ${patch_zip##*/} | cut -d_ -f1 | cut -dp -f2) | ||
if [ $patch_no == "6880880" ]; then | ||
echo "Removing directory ${ORACLE_HOME}/OPatch"; | ||
rm -rf ${ORACLE_HOME}/OPatch; | ||
echo "Unzipping OPatch archive $patch_zip to ${ORACLE_HOME}"; | ||
unzip -qo $patch_zip -d $ORACLE_HOME; | ||
else | ||
ONE_OFFS_LIST+=($patch_no); | ||
echo "Unzipping $patch_zip"; | ||
unzip -qo $patch_zip -d $PATCH_DIR; | ||
fi | ||
done | ||
else | ||
echo "No one-offs to be installed." | ||
fi | ||
|
||
export PATH=${ORACLE_HOME}/perl/bin:$PATH; | ||
|
||
if [ ! -z $ru_patch ]; then | ||
echo "Applying Release Update: $ru_patch"; | ||
cmd="${ORACLE_HOME}/OPatch/opatchauto apply -binary -oh $ORACLE_HOME ${PATCH_DIR}/${ru_patch} -target_type rac_database"; | ||
echo "Running: $cmd"; | ||
$cmd; | ||
fi | ||
|
||
for patch in ${ONE_OFFS_LIST[@]}; do | ||
echo "Applying patch: $patch"; | ||
cmd="${ORACLE_HOME}/OPatch/opatchauto apply -binary -oh $ORACLE_HOME ${PATCH_DIR}/${patch} -target_type rac_database"; | ||
echo "Running: $cmd"; | ||
$cmd; | ||
done |
Empty file.
Empty file.
33 changes: 33 additions & 0 deletions
33
OracleDatabase/SingleInstance/extensions/patching/runDatapatch.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
# LICENSE UPL 1.0 | ||
# | ||
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
# | ||
# Since: March, 2020 | ||
# Author: [email protected] | ||
# Description: Runs datapatch in a container while using existing datafiles if container is at different RU level | ||
# than the container which created the datafiles | ||
# | ||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
# | ||
|
||
# LSPATCHES_FILE will have the patch summary of the datafiles. | ||
DBCONFIG_DIR="${ORACLE_BASE}/oradata/dbconfig/${ORACLE_SID}" | ||
LSPATCHES_FILE="${DBCONFIG_DIR}/${ORACLE_SID}.lspatches" | ||
|
||
# tmp.lspatches will have the patch summary of the oracle home. | ||
temp_lspatches_file="/tmp/tmp.lspatches" | ||
$ORACLE_HOME/OPatch/opatch lspatches > ${temp_lspatches_file}; | ||
|
||
if diff ${LSPATCHES_FILE} ${temp_lspatches_file} 2> /dev/null; then | ||
echo "Datafiles are already patched. Skipping datapatch run." | ||
else | ||
echo "Running datapatch..."; | ||
if ! $ORACLE_HOME/OPatch/datapatch -skip_upgrade_check; then | ||
echo "Datapatch execution has failed."; | ||
exit 1; | ||
else | ||
echo "DONE: Datapatch execution." | ||
cp ${temp_lspatches_file} ${LSPATCHES_FILE}; | ||
fi | ||
fi |
11 changes: 11 additions & 0 deletions
11
OracleDatabase/SingleInstance/extensions/patching/runOracle.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
# LICENSE UPL 1.0 | ||
# | ||
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
# | ||
# Since: March, 2020 | ||
# Author: [email protected] | ||
# Description: runOracle.sh for the patching extension | ||
# | ||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
# |
16 changes: 16 additions & 0 deletions
16
OracleDatabase/SingleInstance/extensions/patching/savePatchSummary.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
# LICENSE UPL 1.0 | ||
# | ||
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
# | ||
# Since: March, 2020 | ||
# Author: [email protected] | ||
# Description: Runs lspatches to save summary of installed patches just after new db is created. | ||
# | ||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
# | ||
|
||
LSPATCHES_FILE="${ORACLE_SID}.lspatches" | ||
LSPATCHES_FILE_PATH="${ORACLE_BASE}/oradata/dbconfig/${ORACLE_SID}/${LSPATCHES_FILE}" | ||
|
||
$ORACLE_HOME/OPatch/opatch lspatches > ${LSPATCHES_FILE_PATH}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.