Skip to content

Commit a86e9c0

Browse files
committed
Merge branch 'opatch-73' into 'main'
Changed file permissions to allow OPatch lsinventory to run in an OpenShift container See merge request weblogic-cloud/weblogic-image-tool!475
2 parents e5f4c31 + e72b615 commit a86e9c0

File tree

6 files changed

+40
-21
lines changed

6 files changed

+40
-21
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void initializeOptions() throws InvalidCredentialException, IOException, Invalid
186186
}
187187

188188
if (kubernetesTarget == KubernetesTarget.OPENSHIFT) {
189-
dockerfileOptions.setDomainGroupAsUser(true);
189+
dockerfileOptions.useOwnerPermsForGroup(true);
190190
// if the user did not set the OS user:group, make the default oracle:root, instead of oracle:oracle
191191
if (!isChownSet()) {
192192
dockerfileOptions.setGroupId("root");

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/DockerfileOptions.java

+19-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2019, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package com.oracle.weblogic.imagetool.util;
@@ -70,7 +70,7 @@ public class DockerfileOptions {
7070
private PackageManagerType pkgMgr;
7171
private List<String> patchFilenames;
7272
private MiddlewareInstall mwInstallers;
73-
private boolean domainGroupAsUser;
73+
private boolean useOwnerPermsForGroup;
7474
private boolean usingBusybox;
7575
private List<String> buildArgs;
7676

@@ -102,7 +102,7 @@ public DockerfileOptions(String buildId) {
102102
updateOpatch = false;
103103
skipJavaInstall = false;
104104
skipMiddlewareInstall = false;
105-
domainGroupAsUser = false;
105+
useOwnerPermsForGroup = false;
106106
usingBusybox = false;
107107
buildArgs = new ArrayList<>();
108108

@@ -1087,14 +1087,26 @@ public DockerfileOptions setWdtBase(String value) {
10871087
return this;
10881088
}
10891089

1090-
public DockerfileOptions setDomainGroupAsUser(boolean value) {
1091-
domainGroupAsUser = value;
1090+
/**
1091+
* Let the Dockerfile know that additional write permissions are required.
1092+
* When running in OpenShift, 755 permissions is inadequate for some tools
1093+
* and write permissions must be enabled. For example, OPatch will fail
1094+
* with code 73 if it does not have write permissions to the cfgtoollogs folder.
1095+
* @param value true if additional group write permissions are required.
1096+
* @return this
1097+
*/
1098+
public DockerfileOptions useOwnerPermsForGroup(boolean value) {
1099+
useOwnerPermsForGroup = value;
10921100
return this;
10931101
}
10941102

1103+
/**
1104+
* Returns true if additional write permissions should be used for the OS group.
1105+
* @return true if group should equal owner permissions for some files/dirs.
1106+
*/
10951107
@SuppressWarnings("unused")
1096-
public boolean domainGroupAsUser() {
1097-
return domainGroupAsUser;
1108+
public boolean useOwnerPermsForGroup() {
1109+
return useOwnerPermsForGroup;
10981110
}
10991111

11001112
/**

imagetool/src/main/resources/docker-files/Rebase_Image.mustache

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019, 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2019, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
#
44

@@ -79,9 +79,9 @@ RUN mkdir -p {{domain_home}}
7979
{{/isWdtModelHomeOutsideWdtHome}}
8080
{{/modelOnly}}
8181

82-
{{#domainGroupAsUser}}
82+
{{#useOwnerPermsForGroup}}
8383
RUN chmod -R g=u {{{domain_home}}}
84-
{{/domainGroupAsUser}}
84+
{{/useOwnerPermsForGroup}}
8585

8686
WORKDIR {{{work_dir}}}
8787

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2021, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
#
44
# Copy WDT files or domain into the final image
@@ -10,13 +10,13 @@
1010
{{#isWdtModelHomeOutsideWdtHome}}
1111
COPY --from=wdt_build --chown={{userid}}:{{groupid}} {{wdt_model_home}} {{wdt_model_home}}/
1212
{{/isWdtModelHomeOutsideWdtHome}}
13-
{{#domainGroupAsUser}}
13+
{{#useOwnerPermsForGroup}}
1414
RUN chmod -R g=u {{{domain_parent}}} {{{wdt_home}}} {{{wdt_model_home}}}
15-
{{/domainGroupAsUser}}
15+
{{/useOwnerPermsForGroup}}
1616
{{/modelOnly}}
1717
{{^modelOnly}}
1818
COPY --from=wdt_build --chown={{userid}}:{{groupid}} {{{domain_home}}} {{{domain_home}}}/
19-
{{#domainGroupAsUser}}
19+
{{#useOwnerPermsForGroup}}
2020
RUN chmod -R g=u {{{domain_home}}}
21-
{{/domainGroupAsUser}}
21+
{{/useOwnerPermsForGroup}}
2222
{{/modelOnly}}

imagetool/src/main/resources/docker-files/install-middleware.mustache

+7
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ RUN echo "INSTALLING MIDDLEWARE" \
5757
&& chmod -R g+r {{{oracle_home}}} \
5858
|| (grep -vh "NOTIFICATION" /tmp/OraInstall*/install*.log && exit 1)
5959

60+
{{#useOwnerPermsForGroup}}
61+
# OPatch needs write permissions to the logs folder and lock file when running in OpenShift
62+
RUN mkdir ${ORACLE_HOME}/cfgtoollogs \
63+
&& chmod g=u ${ORACLE_HOME}/cfgtoollogs \
64+
&& chmod g=u ${ORACLE_HOME}/inventory/locks/oh.lock
65+
{{/useOwnerPermsForGroup}}
66+
6067
{{> fmw-patching}}
6168

6269
{{#afterFmwInstall}}

imagetool/src/main/resources/docker-files/run-wdt.mustache

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2021, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
#
44
# Create WLS domain (or model)
@@ -61,18 +61,18 @@ RUN test -d {{{wdt_home}}}/weblogic-deploy && rm -rf {{{wdt_home}}}/weblogic-dep
6161
-run_rcu \
6262
{{/runRcu}}
6363
{{{wdtVariableFileArgument}}} {{{wdtModelFileArgument}}} {{{wdtArchiveFileArgument}}}
64-
{{#domainGroupAsUser}}
64+
{{#useOwnerPermsForGroup}}
6565
RUN chmod -R g=u {{{domain_home}}}
66-
{{/domainGroupAsUser}}
66+
{{/useOwnerPermsForGroup}}
6767
{{/modelOnly}}
6868
{{#isWdtValidateEnabled}}
6969
RUN cd {{{wdt_home}}}/weblogic-deploy/bin \
7070
&& rm ./*.cmd \
71-
{{#domainGroupAsUser}}
71+
{{#useOwnerPermsForGroup}}
7272
&& chmod -R g=u {{{wdt_home}}}/weblogic-deploy/lib \
7373
&& mkdir {{{wdt_home}}}/weblogic-deploy/logs \
7474
&& chmod g=u {{{wdt_home}}}/weblogic-deploy/logs \
75-
{{/domainGroupAsUser}}
75+
{{/useOwnerPermsForGroup}}
7676
&& ./validateModel.sh {{^strictValidation}}-method lax{{/strictValidation}} \
7777
-oracle_home {{{oracle_home}}} \
7878
-domain_type {{domainType}} \

0 commit comments

Comments
 (0)