forked from oracle/docker-images
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install DB and apply patches in a single layer
The oracle-docker-images repository allows patches to be applied, but the resulting image size is doubled (see oracle#1990). Instead, we would like to apply the patches in the same layer where the database binaries are installed. I have applied this only to the 19c and 21c Dockerfiles since the other versions are either at or rapidly approaching end of life. Changes: - Set SLIMMING to false to ensure that all files required for patching are present. - Copied patchDBBinaries.sh, runDatapatch.sh and savePatchSummary.sh from the extensions/patch directory. - Modified patchDBBinaries.sh to delete temporary files to reduce image size. - Added steps to builder stage in Dockerfile to copy the patches to the container and run the patchDBBinaries.sh script. - Added steps to Dockerfile to copy datapatch and lspatches scripts under $ORACLE_BASE.
- Loading branch information
1 parent
0596473
commit b868b60
Showing
12 changed files
with
360 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
99 changes: 99 additions & 0 deletions
99
OracleDatabase/SingleInstance/dockerfiles/19.3.0/patchDBBinaries.sh
This file contains 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,99 @@ | ||
#!/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 || { | ||
echo "RU application failed for patchset: ${ru_patch}"; | ||
exit 1; | ||
} | ||
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 || { | ||
echo "Patch application failed for ${patch}"; | ||
exit 1; | ||
} | ||
done | ||
|
||
# Remove not needed components | ||
# APEX | ||
rm -rf "$ORACLE_HOME"/apex && \ | ||
# ORDS | ||
rm -rf "$ORACLE_HOME"/ords && \ | ||
# SQL Developer | ||
rm -rf "$ORACLE_HOME"/sqldeveloper && \ | ||
# UCP connection pool | ||
rm -rf "$ORACLE_HOME"/ucp && \ | ||
# All installer files | ||
rm -rf "$ORACLE_HOME"/lib/*.zip && \ | ||
# OUI backup | ||
rm -rf "$ORACLE_HOME"/inventory/backup/* && \ | ||
# Network tools help | ||
rm -rf "$ORACLE_HOME"/network/tools/help && \ | ||
# Database upgrade assistant | ||
rm -rf "$ORACLE_HOME"/assistants/dbua && \ | ||
# Database migration assistant | ||
rm -rf "$ORACLE_HOME"/dmu && \ | ||
# Remove pilot workflow installer | ||
rm -rf "$ORACLE_HOME"/install/pilot && \ | ||
# Support tools | ||
rm -rf "$ORACLE_HOME"/suptools && \ | ||
# Temp location | ||
rm -rf /tmp/* && \ | ||
# Database files directory | ||
rm -rf "$INSTALL_DIR"/database | ||
# Database patch directories | ||
rm -rf $PATCH_DIR/* $ORACLE_HOME/.patch_storage |
Empty file.
Empty file.
38 changes: 38 additions & 0 deletions
38
OracleDatabase/SingleInstance/dockerfiles/19.3.0/runDatapatch.sh
This file contains 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,38 @@ | ||
#!/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. | ||
# | ||
|
||
if [ "${SKIP_DATAPATCH}" = "true" ]; then | ||
echo "Skipping Datapatch" | ||
exit 0; | ||
fi | ||
|
||
# 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 |
16 changes: 16 additions & 0 deletions
16
OracleDatabase/SingleInstance/dockerfiles/19.3.0/savePatchSummary.sh
This file contains 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}; |
This file contains 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
99 changes: 99 additions & 0 deletions
99
OracleDatabase/SingleInstance/dockerfiles/21.3.0/patchDBBinaries.sh
This file contains 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,99 @@ | ||
#!/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 || { | ||
echo "RU application failed for patchset: ${ru_patch}"; | ||
exit 1; | ||
} | ||
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 || { | ||
echo "Patch application failed for ${patch}"; | ||
exit 1; | ||
} | ||
done | ||
|
||
# Remove not needed components | ||
# APEX | ||
rm -rf "$ORACLE_HOME"/apex && \ | ||
# ORDS | ||
rm -rf "$ORACLE_HOME"/ords && \ | ||
# SQL Developer | ||
rm -rf "$ORACLE_HOME"/sqldeveloper && \ | ||
# UCP connection pool | ||
rm -rf "$ORACLE_HOME"/ucp && \ | ||
# All installer files | ||
rm -rf "$ORACLE_HOME"/lib/*.zip && \ | ||
# OUI backup | ||
rm -rf "$ORACLE_HOME"/inventory/backup/* && \ | ||
# Network tools help | ||
rm -rf "$ORACLE_HOME"/network/tools/help && \ | ||
# Database upgrade assistant | ||
rm -rf "$ORACLE_HOME"/assistants/dbua && \ | ||
# Database migration assistant | ||
rm -rf "$ORACLE_HOME"/dmu && \ | ||
# Remove pilot workflow installer | ||
rm -rf "$ORACLE_HOME"/install/pilot && \ | ||
# Support tools | ||
rm -rf "$ORACLE_HOME"/suptools && \ | ||
# Temp location | ||
rm -rf /tmp/* && \ | ||
# Database files directory | ||
rm -rf "$INSTALL_DIR"/database | ||
# Database patch directories | ||
rm -rf $PATCH_DIR/* $ORACLE_HOME/.patch_storage |
Empty file.
Empty file.
Oops, something went wrong.