Skip to content

Commit db28651

Browse files
Add prefix ARG to arg variables
1 parent fa907e4 commit db28651

File tree

7 files changed

+74
-42
lines changed

7 files changed

+74
-42
lines changed

samples/docker-domain/Dockerfile

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,25 @@
1717
#
1818
# Run:
1919
# $ sudo docker build \
20+
# --build-arg ADMIN_HOST=wlsadmin
21+
# --build-arg ADMIN_PORT=7001
22+
# --build-arg MS_PORT=8001
23+
# --build-arg DOMAIN_NAME=base_domain
2024
# --build-arg WDT_MODEL=simple-topology.yaml \
2125
# --build-arg WDT_ARCHIVE=archive.zip \
22-
# --build-arg WDT_VARIABLE=simple-topology.properties \
26+
# --build-arg WDT_VARIABLE=domain.properties \
2327
# --force-rm=true \
2428
# -t 12213-domain-wdt .
2529
#
30+
# If the ADMIN_HOST, ADMIN_PORT, MS_PORT, DOMAIN_NAME are not provided, the variables
31+
# are set to default values. (The values shown in the build statement).
32+
#
33+
# You must insure that the build arguments align with the values in the model.
34+
# The sample model replaces the attributes with tokens that are resolved fromn values in the
35+
# corresponding property file domain.properties. The container-scripts/setEnv.sh script
36+
# demonstrates parsing the variable file to build a string of --build-args that can
37+
# be passed on the docker builds command.
38+
#
2639
# Pull base image
2740
# ---------------
2841
# FROM store/oracle/weblogic:12.2.1.3
@@ -35,31 +48,36 @@ MAINTAINER Richard Killen <[email protected]>
3548
ARG WDT_ARCHIVE
3649
ARG WDT_VARIABLE
3750
ARG WDT_MODEL
38-
ARG ADMIN_HOST
39-
ARG ADMIN_PORT
40-
ARG MS_PORT
41-
ARG DOMAIN_DIR
42-
ARG DEBUG_PORT
51+
ARG ARG_ADMIN_HOST=wlsadmin
52+
ARG ARG_ADMIN_PORT=7001
53+
ARG ARG_MS_PORT=8001
54+
ARG ARG_DOMAIN_NAME=base_domain
55+
ARG ARG_DEBUG_PORT=8453
56+
57+
RUN echo DOMAIN_NAME=${DOMAIN_FOLDER_NAME}
58+
# Persist arguments - for ports to expose and container to use
59+
# Create a placeholder for the manager server name. This will be provided when run the container
60+
# ---------------------------
61+
ENV ADMIN_HOST=${ARG_ADMIN_HOST} \
62+
ADMIN_PORT=${ARG_ADMIN_PORT} \
63+
MS_NAME="" \
64+
MS_PORT=${ARG_MS_PORT} \
65+
DEBUG_PORT=${ARG_DEBUG_PORT} \
66+
DOMAIN_NAME=${ARG_DOMAIN_NAME} \
67+
ORACLE_HOME=/u01/oracle
68+
69+
ENV DOMAIN_PARENT=$ORACLE_HOME/user_projects/domains
4370

4471
# WLS Configuration - oracle home and domain home
4572
# The boot.properties will be created under the DOMAIN_HOME when the AdminServer container is run
73+
# WDT install location and container scripts location
4674
# ---------------------------
47-
ENV ORACLE_HOME=/u01/oracle \
48-
PROPERTIES_FILE_DIR="$ORACLE_HOME/properties" \
49-
DOMAIN_PARENT="${ORACLE_HOME}/user_projects/domains" \
50-
DOMAIN_HOME="${DOMAIN_PARENT}/${DOMAIN_DIR:-TESTDOMAON}" \
51-
ADMIN_HOST="${ADMIN_HOST:-wlsadmin}" \
52-
ADMIN_PORT="${ADMIN_PORT:-7001}" \
53-
MS_PORT="${MS_PORT:-8001}" \
54-
DEBUG_PORT="${DEBUG_PORT:-8453}" \
75+
ENV DOMAIN_HOME=$DOMAIN_PARENT/${DOMAIN_NAME} \
76+
PROPERTIES_FILE_DIR=$ORACLE_HOME/properties \
77+
WDT_HOME="/u01" \
78+
SCRIPT_HOME="${ORACLE_HOME}" \
5579
PATH=$PATH:${ORACLE_HOME}/oracle_common/common/bin:${ORACLE_HOME}/wlserver/common/bin:$DOMAIN_HOME/bin:${ORACLE_HOME}
5680

57-
# WDT install and WDT user files
58-
# ------------------------------------------------------------
59-
ENV WDT_HOME="/u01" \
60-
SCRIPT_HOME="${ORACLE_HOME}"
61-
62-
# Add files required to build this image and run a container from the image
6381
COPY weblogic-deploy.zip ${WDT_HOME}
6482
COPY container-scripts/* ${SCRIPT_HOME}/
6583

@@ -93,19 +111,20 @@ ENV WDT_HOME=$WDT_HOME/weblogic-deploy
93111

94112
# Set WORKDIR for @@PWD@@ global token in model file
95113
WORKDIR $ORACLE_HOME
96-
RUN if [ -n "$WDT_MODEL" ]; then MODEL_OPT="-model_file $PROPERTIES_FILE_DIR/$WDT_MODEL"; fi && \
97-
if [ -n "$WDT_ARCHIVE" ]; then ARCHIVE_OPT="-archive_file $PROPERTIES_FILE_DIR/$WDT_ARCHIVE"; fi && \
98-
if [ -n "$WDT_VARIABLE" ]; then VARIABLE_OPT="-variable_file $PROPERTIES_FILE_DIR/$WDT_VARIABLE"; fi && \
114+
RUN if [ -n "$WDT_MODEL" ]; then MODEL_OPT="-model_file $PROPERTIES_FILE_DIR/${WDT_MODEL##*/}"; fi && \
115+
if [ -n "$WDT_ARCHIVE" ]; then ARCHIVE_OPT="-archive_file $PROPERTIES_FILE_DIR/${WDT_ARCHIVE##*/}"; fi && \
116+
if [ -n "$WDT_VARIABLE" ]; then VARIABLE_OPT="-variable_file $PROPERTIES_FILE_DIR/${WDT_VARIABLE##*/}"; fi && \
117+
echo parent $DOMAIN_PARENT && \
99118
${WDT_HOME}/bin/createDomain.sh \
100-
-oracle_home ${ORACLE_HOME} \
101-
-java_home ${JAVA_HOME} \
102-
-domain_home ${DOMAIN_HOME} \
119+
-oracle_home $ORACLE_HOME \
120+
-java_home $JAVA_HOME \
121+
-domain_home $DOMAIN_HOME \
103122
-domain_type WLS \
104123
$VARIABLE_OPT \
105124
$MODEL_OPT \
106125
$ARCHIVE_OPT && \
107-
chown -R oracle:oracle ${DOMAIN_PARENT} && \
108-
rm -rf ${PROPERTIES_FILE_DIR}
126+
chown -R oracle:oracle $DOMAIN_PARENT && \
127+
rm -rf $PROPERTIES_FILE_DIR
109128

110129
VOLUME $DOMAIN_HOME
111130

samples/docker-domain/build.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
#
55
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
66
#
7-
. container-scripts/setEnv.sh ./simple-topology.properties
7+
8+
# parse the ADMIN_HOST, ADMIN_PORT, MS_PORT, and DOMAIN_NAME from the sample properties file and pass
9+
# as a string of --build-arg in the variable BUILD_ARG
10+
. container-scripts/setEnv.sh properties/docker-build/domain.properties
811

912

1013
docker build \
1114
$BUILD_ARG \
1215
--build-arg WDT_MODEL=simple-topology.yaml \
13-
--build-arg WDT_VARIABLE=simple-topology.properties \
16+
--build-arg WDT_VARIABLE=properties/docker-build/domain.properties \
1417
--build-arg WDT_ARCHIVE=archive.zip \
15-
-t 12213-domain-wdt-test .
18+
-t 12213-domain-wdt .
1619

samples/docker-domain/container-scripts/setEnv.sh

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
44
# The Universal Permissive License (UPL), Version 1.0
5-
BUILD_ARG=''
6-
if [ $# > 1 ]; then
7-
PROPERTIES_FILE=$1
8-
fi
5+
#
6+
# This example creates the BUILD_ARG environment variable as a string of --build-arg for
7+
# the arguments passed on the docker build command. The variable file that is used for the WDT
8+
# create domain step is the input to this script. This insures that the values persisted
9+
# as environment variables in the docker image match the configured domain home.
10+
11+
BUILD_ARG=''
12+
if [ $# > 1 ]; then
13+
PROPERTIES_FILE=$1
14+
fi
915

1016
if [ ! -e "${PROPERTIES_FILE}" ]; then
1117
echo "A properties file with variable definitions should be supplied."
@@ -20,34 +26,38 @@ if [ ! -n "$DOMAIN_DIR" ]; then
2026
fi
2127
fi
2228
if [ -n "$DOMAIN_DIR" ]; then
23-
export DOMAIN_DIR
24-
echo DOMAIN_DIR=$DOMAIN_DIR
25-
BUILD_ARG="$BUILD_ARG --build-arg DOMAIN_DIR=$DOMAIN_DIR"
29+
DOMAIN_NAME=$DOMAIN_DIR
30+
export DOMAIN_NAME
31+
echo DOMAIN_NAME=$DOMAIN_NAME
32+
BUILD_ARG="$BUILD_ARG --build-arg ARG_DOMAIN_NAME=$DOMAIN_NAME"
2633
fi
2734

2835
ADMIN_HOST=`awk '{print $1}' $PROPERTIES_FILE | grep ^ADMIN_HOST= | cut -d "=" -f2`
2936
if [ -n "$ADMIN_HOST" ]; then
3037
export ADMIN_HOST
3138
echo ADMIN_HOST=$ADMIN_HOST
32-
BUILD_ARG="$BUILD_ARG --build-arg ADMIN_HOST=$ADMIN_HOST"
39+
BUILD_ARG="$BUILD_ARG --build-arg ARG_ADMIN_HOST=$ADMIN_HOST"
3340
fi
3441

3542
ADMIN_PORT=`awk '{print $1}' $PROPERTIES_FILE | grep ^ADMIN_PORT= | cut -d "=" -f2`
3643
if [ -n "$ADMIN_PORT" ]; then
3744
export ADMIN_PORT
3845
echo ADMIN_PORT=$ADMIN_PORT
39-
BUILD_ARG="$BUILD_ARG --build-arg ADMIN_PORT=$ADMIN_PORT"
46+
BUILD_ARG="$BUILD_ARG --build-arg ARG_ADMIN_PORT=$ADMIN_PORT"
4047
fi
4148

4249
MS_PORT=`awk '{print $1}' $PROPERTIES_FILE | grep ^MS_PORT= | cut -d "=" -f2`
4350
if [ -n "$MS_PORT" ]; then
44-
export MS_PORT echo MS_PORT=$MS_PORT BUILD_ARG="$BUILD_ARG --build-arg MS_PORT=$MS_PORT" fi
51+
export MS_PORT
52+
echo MS_PORT=$MS_PORT
53+
BUILD_ARG="$BUILD_ARG --build-arg ARG_MS_PORT=$MS_PORT"
54+
fi
4555

4656
DEBUG_PORT=`awk '{print $1}' $PROPERTIES_FILE | grep ^DEBUG_PORT= | cut -d "=" -f2`
4757
if [ -n "$DEBUG_PORT" ]; then
4858
export DEBUG_PORT
4959
echo DEBUG_PORT=$DEBUG_PORT
50-
BUILD_ARG="$BUILD_ARG --build-arg DEBUG_PORT=$DEBUG_PORT"
60+
BUILD_ARG="$BUILD_ARG --build-arg ARG_DEBUG_PORT=$DEBUG_PORT"
5161
fi
5262

5363
echo BUILD_ARG=$BUILD_ARG

0 commit comments

Comments
 (0)