Skip to content

Commit bac5614

Browse files
authored
Patchimprovement (#2924)
* patch improvement changes using base image * patch improvement changes using base image
1 parent 38c826c commit bac5614

File tree

7 files changed

+98
-70
lines changed

7 files changed

+98
-70
lines changed

OracleDatabase/RAC/OracleRealApplicationClusters/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ To create an Oracle RAC environment, follow these steps:
2222
- [Getting Oracle RAC Database Container Images](#getting-oracle-rac-database-container-images)
2323
- [Building Oracle RAC Database Container Image](#building-oracle-rac-database-container-image)
2424
- [Building Oracle RAC Database Container Slim Image](#building-oracle-rac-database-container-slim-image)
25+
- [Building Oracle RAC Database Container Base Image](#building-oracle-rac-database-container-base-image)
2526
- [Network Management](#network-management)
2627
- [Password Management](#password-management)
2728
- [Oracle RAC on Containers Deployment Scenarios](#oracle-rac-on-containers-deployment-scenarios)
@@ -137,6 +138,19 @@ Retag it as below as we are going to refer this image as `localhost/oracle/datab
137138
podman tag localhost/oracle/database-rac:21.3.0-slim localhost/oracle/database-rac:21c-slim
138139
```
139140

141+
### Building Oracle RAC Database Container Base Image
142+
In this document, an `Oracle RAC Database Container Base Image` refers to a container image that does not include installation of Oracle Grid Infrastructure and Oracle Database Software Binaries during the Oracle RAC Database Container Image creation. This image is extended to build patched image or extensions. To build an Oracle RAC Database Container Base Image run the following command:
143+
```bash
144+
./buildContainerImage.sh -v <Software Version> -i -b
145+
```
146+
Example: To build Oracle RAC Database Container Base Image for version 21.3.0, use the below command:
147+
```bash
148+
./buildContainerImage.sh -v 21.3.0 -i -b
149+
```
150+
To build an Oracle RAC Database Container Base Image, you need to use `-b`.
151+
152+
To change the Base Image during building Oracle RAC Database Container Images, you must use `--build-arg BASE_OL_IMAGE=oraclelinux:8`.
153+
140154
**Notes**
141155
- Usage of `./buildContainerImage.sh`:
142156
```text

OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/19.3.0/Containerfile

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ARG SLIMMING=false
2525
# Pull base image
2626
# ---------------
2727
# hadolint ignore=DL3006,DL3025
28-
FROM $BASE_OL_IMAGE AS base
28+
FROM $BASE_OL_IMAGE AS racbase
2929
ARG SLIMMING=false
3030
ARG VERSION
3131
# Labels
@@ -97,9 +97,10 @@ ENV SETUP_LINUX_FILE="setupLinuxEnv.sh" \
9797
# -------------------------------------------
9898
#############################################
9999

100-
FROM base AS rac-image-slim-false
100+
FROM racbase AS rac-image-slim-false
101101
ARG SLIMMING
102-
ARG VERSION
102+
ARG VERSION
103+
ENV CV_ASSUME_DISTID=OEL7.8
103104
# Environment variables required for this build (do NOT change)
104105
# -------------------------------------------------------------
105106
# Linux Env Variable
@@ -117,7 +118,7 @@ ENV INSTALL_SCRIPTS=$INSTALL_DIR/install \
117118
DB_PATH=$DB_HOME/bin:$DB_HOME/OPatch/:$DB_HOME/perl/bin:/usr/sbin:/bin:/sbin \
118119
GRID_LD_LIBRARY_PATH=$GRID_HOME/lib:/usr/lib:/lib \
119120
DB_LD_LIBRARY_PATH=$DB_HOME/lib:/usr/lib:/lib
120-
ENV CV_ASSUME_DISTID=OEL7.8
121+
121122
# Copy binaries
122123
# -------------
123124
# COPY Binaries
@@ -141,7 +142,7 @@ RUN chmod 755 $INSTALL_SCRIPTS/*.sh && \
141142
# Start new stage for slim image
142143
# -------------------------------------------
143144
#############################################
144-
FROM base AS rac-image-slim-true
145+
FROM racbase AS rac-image-slim-true
145146
ARG SLIMMING
146147
ARG VERSION
147148
ENV CV_ASSUME_DISTID=OEL7.8
@@ -255,4 +256,30 @@ HEALTHCHECK --interval=2m --start-period=30m \
255256

256257
# Define default command to start Oracle Grid and RAC Database setup.
257258
# hadolint ignore=DL3025
258-
ENTRYPOINT /usr/bin/$INITSH
259+
ENTRYPOINT /usr/bin/$INITSH
260+
################################################################
261+
# --------------------------------------------------------------
262+
# Start new stage for base image required by patching/extensions
263+
# --------------------------------------------------------------
264+
################################################################
265+
FROM final AS base
266+
ARG VERSION
267+
# Environment variables required for this build (do NOT change)
268+
# -------------------------------------------------------------
269+
# Linux Env Variable
270+
ENV GRID_BASE=/u01/app/grid \
271+
GRID_HOME=/u01/app/19c/grid \
272+
DB_BASE=/u01/app/oracle \
273+
DB_HOME=/u01/app/oracle/product/19c/dbhome_1 \
274+
SLIMMING=false
275+
# Use second ENV so that variable get substituted
276+
# hadolint ignore=DL3044
277+
ENV INSTALL_SCRIPTS=$INSTALL_DIR/install \
278+
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
279+
SCRIPT_DIR=$INSTALL_DIR/startup \
280+
RAC_SCRIPTS_DIR="scripts" \
281+
GRID_PATH=$GRID_HOME/bin:$GRID_HOME/OPatch/:$GRID_HOME/perl/bin:/usr/sbin:/bin:/sbin \
282+
DB_PATH=$DB_HOME/bin:$DB_HOME/OPatch/:$DB_HOME/perl/bin:/usr/sbin:/bin:/sbin \
283+
GRID_LD_LIBRARY_PATH=$GRID_HOME/lib:/usr/lib:/lib \
284+
DB_LD_LIBRARY_PATH=$DB_HOME/lib:/usr/lib:/lib
285+
COPY $VERSION/$ADDNODE_RSP $VERSION/$GRID_INSTALL_RSP $VERSION/$DBCA_RSP $SCRIPT_DIR/

OracleDatabase/RAC/OracleRealApplicationClusters/containerfiles/21.3.0/Containerfile

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ARG SLIMMING=false
2525
# Pull base image
2626
# ---------------
2727
# hadolint ignore=DL3006,DL3025
28-
FROM $BASE_OL_IMAGE AS base
28+
FROM $BASE_OL_IMAGE AS racbase
2929
ARG SLIMMING=false
3030
ARG VERSION
3131
# Labels
@@ -97,7 +97,7 @@ ENV SETUP_LINUX_FILE="setupLinuxEnv.sh" \
9797
# -------------------------------------------
9898
#############################################
9999

100-
FROM base AS rac-image-slim-false
100+
FROM racbase AS rac-image-slim-false
101101
ARG SLIMMING
102102
ARG VERSION
103103
# Environment variables required for this build (do NOT change)
@@ -124,7 +124,7 @@ ENV INSTALL_SCRIPTS=$INSTALL_DIR/install \
124124
COPY $VERSION/$SETUP_LINUX_FILE $VERSION/$GRID_SETUP_FILE $VERSION/$DB_SETUP_FILE $VERSION/$CHECK_SPACE_FILE $VERSION/$FIXUP_PREQ_FILE $INSTALL_SCRIPTS/
125125

126126
# Setup Scripts
127-
COPY $VERSION/$RUN_FILE $VERSION/$ADDNODE_RSP $VERSION/$SETUPSSH $VERSION/$GRID_INSTALL_RSP $VERSION/$DBCA_RSP $VERSION/$INITSH $SCRIPT_DIR/
127+
COPY $VERSION/$RUN_FILE $VERSION/$ADDNODE_RSP $VERSION/$SETUPSSH $VERSION/$GRID_INSTALL_RSP $VERSION/$DBCA_RSP $VERSION/$INITSH $SCRIPT_DIR/
128128

129129
COPY $RAC_SCRIPTS_DIR $SCRIPT_DIR/scripts
130130
# hadolint ignore=SC2086
@@ -141,7 +141,7 @@ RUN chmod 755 $INSTALL_SCRIPTS/*.sh && \
141141
# Start new stage for slim image
142142
# -------------------------------------------
143143
#############################################
144-
FROM base AS rac-image-slim-true
144+
FROM racbase AS rac-image-slim-true
145145
ARG SLIMMING
146146
ARG VERSION
147147
# Environment variables required for this build (do NOT change)
@@ -253,4 +253,29 @@ HEALTHCHECK --interval=2m --start-period=30m \
253253

254254
# Define default command to start Oracle Grid and RAC Database setup.
255255
# hadolint ignore=DL3025
256-
ENTRYPOINT /usr/bin/$INITSH
256+
ENTRYPOINT /usr/bin/$INITSH
257+
################################################################
258+
# --------------------------------------------------------------
259+
# Start new stage for base image required by patching/extensions
260+
# --------------------------------------------------------------
261+
################################################################
262+
FROM final AS base
263+
ARG SLIMMING
264+
ARG VERSION
265+
# Environment variables required for this build (do NOT change)
266+
# -------------------------------------------------------------
267+
# Linux Env Variable
268+
ENV GRID_BASE=/u01/app/grid \
269+
GRID_HOME=/u01/app/21c/grid \
270+
DB_BASE=/u01/app/oracle \
271+
DB_HOME=/u01/app/oracle/product/21c/dbhome_1
272+
# Use second ENV so that variable get substituted
273+
# hadolint ignore=DL3044
274+
ENV INSTALL_SCRIPTS=$INSTALL_DIR/install \
275+
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
276+
SCRIPT_DIR=$INSTALL_DIR/startup \
277+
RAC_SCRIPTS_DIR="scripts" \
278+
GRID_PATH=$GRID_HOME/bin:$GRID_HOME/OPatch/:$GRID_HOME/perl/bin:/usr/sbin:/bin:/sbin \
279+
DB_PATH=$DB_HOME/bin:$DB_HOME/OPatch/:$DB_HOME/perl/bin:/usr/sbin:/bin:/sbin \
280+
GRID_LD_LIBRARY_PATH=$GRID_HOME/lib:/usr/lib:/lib \
281+
DB_LD_LIBRARY_PATH=$DB_HOME/lib:/usr/lib:/lib

OracleDatabase/RAC/OracleRealApplicationClusters/samples/applypatch/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Example of how to create an Oracle RAC Database Container Patched Image
22
=============================================
33
## Pre-requisites
4-
After you build your base Oracle RAC image following the [README.md](../../../OracleRealApplicationClusters/README.md#building-oracle-rac-database-container-image), it is mandatory to create **Oracle RAC Slim image** following [README.md](../../../OracleRealApplicationClusters/README.md#building-oracle-rac-database-container-slim-image), then you can create a patched version of it.
4+
After you build your base Oracle RAC image following the [README.md](../../../OracleRealApplicationClusters/README.md#building-oracle-rac-database-container-image), it is mandatory to create **Oracle RAC Base image** following [README.md](../../../OracleRealApplicationClusters/README.md#building-oracle-rac-database-container-base-image), then you can create a patched version of it.
55
To build a patched image, you must provide the patch zip file.
66

77
**Notes:**
@@ -56,10 +56,10 @@ These directories are useful if you want to install multiple patches at once. Th
5656
-o: passes on container build option
5757
-p: patch label to be used for the tag
5858
```
59-
* The following is an example of building a patched image using 21.3.0. Note that `BASE_RAC_IMAGE=oracle/database-rac:21.3.0` is set to 21.3.0. You must set BASE_RAC_IMAGE and RAC_SLIM_IMAGE based on your enviornment.
59+
* The following is an example of building a patched image using 21.3.0. Note that `localhost/oracle/database-rac:21.3.0-base` is created before using [README.md](../../../OracleRealApplicationClusters/README.md#building-oracle-rac-database-container-base-image).
6060

6161
```bash
62-
# ./buildPatchedContainerImage.sh -v 21.3.0 -p 21.16.0 -o '--build-arg BASE_RAC_IMAGE=localhost/oracle/database-rac:21.3.0 --build-arg RAC_SLIM_IMAGE=localhost/oracle/database-rac:21.3.0-slim'
62+
./buildPatchedContainerImage.sh -v 21.3.0 -p 21.16.0
6363
```
6464

6565
Logs-
@@ -70,7 +70,7 @@ Logs-
7070

7171
Build completed in 1419 seconds.
7272
```
73-
Once Oracle RAC Patch image is built, lets retag it and it is referenced as 21c in this [README](../../README.md) documenation.
73+
Once Oracle RAC Patch image is built, lets retag it and it is referenced as 21c in this [README](../../docs/rac-container/racimage/README.md) documentation.
7474
```bash
7575
podman tag localhost/oracle/database-rac:21.3.0-21.16.0 localhost/oracle/database-rac:21c
7676
```
@@ -81,4 +81,4 @@ podman tag localhost/oracle/database-rac:21.3.0-21.16.0 localhost/oracle/databas
8181

8282
## Copyright
8383

84-
Copyright (c) 2014-2025 Oracle and/or its affiliates. All rights reserved.
84+
Copyright (c) 2014-2025 Oracle and/or its affiliates. All rights reserved.

OracleDatabase/RAC/OracleRealApplicationClusters/samples/applypatch/buildPatchedContainerImage.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ENTERPRISE=0
3737
STANDARD=0
3838
# shellcheck disable=SC2034
3939
LATEST="latest"
40-
VERSION='x'
40+
VERSION='19.3.0'
4141
PATCHLABEL="patch"
4242
DOCKEROPS=""
4343

@@ -103,17 +103,13 @@ echo "Building image '$IMAGE_NAME' ..."
103103

104104
# BUILD THE IMAGE (replace all environment variables)
105105
BUILD_START=$(date '+%s')
106-
docker build --no-cache=true $DOCKEROPS $PROXY_SETTINGS -t env -f ContainerfileEnv .
107-
# shellcheck disable=SC2046
108-
docker cp $(docker create --name env-070125 --rm env):/tmp/.env ./
109106
# shellcheck disable=SC2046
110107
docker build --no-cache=true $DOCKEROPS \
111-
--build-arg GRID_HOME=$(grep GRID_HOME .env | cut -d '=' -f2) \
112-
--build-arg DB_HOME=$(grep DB_HOME .env | cut -d '=' -f2) $PROXY_SETTINGS -t $IMAGE_NAME -f Containerfile . || {
108+
--build-arg VERSION=$VERSION \
109+
$PROXY_SETTINGS -t $IMAGE_NAME -f Containerfile . || {
113110
echo "There was an error building the image."
114111
exit 1
115112
}
116-
docker rmi -f env-070125
117113

118114
BUILD_END=$(date '+%s')
119115
BUILD_ELAPSED=`expr $BUILD_END - $BUILD_START`
@@ -132,4 +128,4 @@ EOF
132128

133129
else
134130
echo "Oracle Database Real Application Clusters container image was NOT successfully created. Check the output and correct any reported problems that occurred during the build operation."
135-
fi
131+
fi

OracleDatabase/RAC/OracleRealApplicationClusters/samples/applypatch/latest/Containerfile

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# LICENSE UPL 1.0
22
#
3-
# Copyright (c) 1982-2019 Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 1982-2025 Oracle and/or its affiliates. All rights reserved.
44
#
55
# ORACLE DOCKERFILES PROJECT
66
# --------------------------
@@ -16,13 +16,11 @@
1616
# Run:
1717
# $ docker build -f Dockerfile -t oracle/rac-database:21.3.0-<patch level> .
1818
#
19-
ARG BASE_RAC_IMAGE=localhost/oracle/database-rac:19.3.0
20-
ARG RAC_SLIM_IMAGE=localhost/oracle/database-rac:19.3.0-slim
19+
ARG VERSION=19.3.0
2120

2221
# Pull base image
2322
# ---------------
24-
# hadolint ignore=DL3006
25-
FROM $BASE_RAC_IMAGE as builder
23+
FROM localhost/oracle/database-rac:$VERSION as builder
2624

2725
# Argument to control removal of components not needed after db software installation
2826
ARG SLIMMING=false
@@ -71,54 +69,31 @@ USER root
7169

7270
RUN $PATCH_INSTALL_DIR/$FIXUP_PREQ_FILE && \
7371
rm -rf /etc/oracle && \
74-
rm -rf $PATCH_INSTALL_DIR
72+
rm -rf $PATCH_INSTALL_DIR && \
73+
rm -rf $PATCH_DIR/* $DB_HOME/.patch_storage $DB_HOME/.opatchauto_storage $GRID_HOME/.patch_storage $GRID_HOME/.opatchauto_storage
7574

7675
#####################
77-
# hadolint ignore=DL3006
78-
FROM $RAC_SLIM_IMAGE AS final
79-
80-
# Define build-time arguments
81-
ARG GRID_HOME
82-
ARG DB_HOME
83-
84-
#Set environment variables using build arguments
85-
ENV GRID_BASE=/u01/app/grid \
86-
GRID_HOME=$GRID_HOME \
87-
DB_BASE=/u01/app/oracle \
88-
DB_HOME=$DB_HOME \
89-
INSTALL_SCRIPTS=/opt/scripts/install \
90-
SCRIPT_DIR=/opt/scripts/startup \
91-
RAC_SCRIPTS_DIR="scripts"
92-
93-
ENV GRID_PATH=$GRID_HOME/bin:$GRID_HOME/OPatch/:$GRID_HOME/perl/bin:/usr/sbin:/bin:/sbin \
94-
DB_PATH=$DB_HOME/bin:$DB_HOME/OPatch/:$DB_HOME/perl/bin:/usr/sbin:/bin:/sbin \
95-
GRID_LD_LIBRARY_PATH=$GRID_HOME/lib:/usr/lib:/lib \
96-
DB_LD_LIBRARY_PATH=$DB_HOME/lib:/usr/lib:/lib
97-
98-
# Run some basic command to verify the environment variables (optional)
99-
RUN echo "GRID_BASE=$GRID_BASE" && \
100-
echo "GRID_HOME=$GRID_HOME" && \
101-
echo "DB_BASE=$DB_BASE" && \
102-
echo "DB_HOME=$DB_HOME"
76+
FROM localhost/oracle/database-rac:$VERSION-base AS final
10377

10478
RUN if [ -d "/u01" ]; then \
10579
rm -rf /u01 && \
10680
:; \
10781
fi
10882

10983
COPY --from=builder /u01 /u01
84+
#Fix SID detection
85+
# hadolint ignore=SC2086
86+
RUN $INVENTORY/orainstRoot.sh && \
87+
$GRID_HOME/root.sh && \
88+
$DB_HOME/root.sh && \
89+
sync
11090

11191
USER ${USER}
11292
VOLUME ["/common_scripts"]
11393
WORKDIR $WORKDIR
11494

11595
HEALTHCHECK --interval=2m --start-period=30m \
11696
CMD "$SCRIPT_DIR/scripts/main.py --checkracinst=true" >/dev/null || exit 1
117-
#Fix SID detection
118-
# hadolint ignore=SC2086
119-
RUN $INVENTORY/orainstRoot.sh && \
120-
$GRID_HOME/root.sh && \
121-
$DB_HOME/root.sh
12297
# Define default command to start Oracle Grid and RAC Database setup.
12398
# hadolint ignore=DL3025
12499
ENTRYPOINT /usr/bin/$INITSH

OracleDatabase/RAC/OracleRealApplicationClusters/samples/applypatch/latest/ContainerfileEnv

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)