From 299ce5f74bb24cfe8968eb9de149b1f618b4ee9a Mon Sep 17 00:00:00 2001 From: Joze RIHTARSIC <joze.RIHTARSIC@ext.ec.europa.eu> Date: Fri, 3 Jun 2022 17:43:00 +0200 Subject: [PATCH] set weblogic cluster --- .../smp/security/.disable_default_excludes | 4 + .../data/smp/security/.gitignore | 5 + .../data/weblogic/.disable_default_excludes | 4 + .../weblogic-oracle/data/weblogic/.gitignore | 5 + .../weblogic-oracle/docker-compose.yml | 65 +++++-- .../weblogic-init/datasource.properties | 9 + .../weblogic-init/domain.properties | 4 + .../weblogic-init/domain_security.properties | 2 + .../weblogic-init/smp.config.properties | 8 + smp-docker/images/build-docker-images.sh | 8 +- .../images/weblogic-12.2-smp/Dockerfile | 119 ++++++------ .../init-scripts/create-wls-domain.py | 39 ++-- .../init-scripts/createWLSDomain.sh | 154 +++++++++++----- .../init-scripts/deploySMPToDomain.sh | 47 +++-- .../init-scripts/ds-deploy.py | 23 ++- .../init-scripts/smp-app-deploy.py | 26 +-- .../container-scripts/startAdminServer.sh | 170 ++++++++++-------- .../container-scripts/startManagedServer.sh | 46 +++-- .../properties/docker-build/domain.properties | 18 -- .../docker-build/domain_security.properties | 2 - .../properties/docker-run/security.properties | 4 - .../properties/init/datasource.properties | 9 + .../properties/init/domain.properties | 4 + .../properties/init/smp.config.properties | 8 + 24 files changed, 491 insertions(+), 292 deletions(-) create mode 100644 smp-docker/compose/weblogic-oracle/data/smp/security/.disable_default_excludes create mode 100644 smp-docker/compose/weblogic-oracle/data/smp/security/.gitignore create mode 100644 smp-docker/compose/weblogic-oracle/data/weblogic/.disable_default_excludes create mode 100644 smp-docker/compose/weblogic-oracle/data/weblogic/.gitignore create mode 100644 smp-docker/compose/weblogic-oracle/properties/weblogic-init/datasource.properties create mode 100644 smp-docker/compose/weblogic-oracle/properties/weblogic-init/domain.properties create mode 100644 smp-docker/compose/weblogic-oracle/properties/weblogic-init/domain_security.properties create mode 100644 smp-docker/compose/weblogic-oracle/properties/weblogic-init/smp.config.properties delete mode 100644 smp-docker/images/weblogic-12.2-smp/properties/docker-build/domain.properties delete mode 100644 smp-docker/images/weblogic-12.2-smp/properties/docker-build/domain_security.properties delete mode 100644 smp-docker/images/weblogic-12.2-smp/properties/docker-run/security.properties create mode 100644 smp-docker/images/weblogic-12.2-smp/properties/init/datasource.properties create mode 100644 smp-docker/images/weblogic-12.2-smp/properties/init/domain.properties create mode 100644 smp-docker/images/weblogic-12.2-smp/properties/init/smp.config.properties diff --git a/smp-docker/compose/weblogic-oracle/data/smp/security/.disable_default_excludes b/smp-docker/compose/weblogic-oracle/data/smp/security/.disable_default_excludes new file mode 100644 index 000000000..e5d41c1ef --- /dev/null +++ b/smp-docker/compose/weblogic-oracle/data/smp/security/.disable_default_excludes @@ -0,0 +1,4 @@ +.gitignore is excluded when sharing artifacts on bamboo +http://ant.apache.org/manual/dirtasks.html + +And we want this folder to be shared in order to keep the project structure. \ No newline at end of file diff --git a/smp-docker/compose/weblogic-oracle/data/smp/security/.gitignore b/smp-docker/compose/weblogic-oracle/data/smp/security/.gitignore new file mode 100644 index 000000000..2c487cd0d --- /dev/null +++ b/smp-docker/compose/weblogic-oracle/data/smp/security/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +.. +# Except the following +!.gitignore +!.disable_default_excludes \ No newline at end of file diff --git a/smp-docker/compose/weblogic-oracle/data/weblogic/.disable_default_excludes b/smp-docker/compose/weblogic-oracle/data/weblogic/.disable_default_excludes new file mode 100644 index 000000000..e5d41c1ef --- /dev/null +++ b/smp-docker/compose/weblogic-oracle/data/weblogic/.disable_default_excludes @@ -0,0 +1,4 @@ +.gitignore is excluded when sharing artifacts on bamboo +http://ant.apache.org/manual/dirtasks.html + +And we want this folder to be shared in order to keep the project structure. \ No newline at end of file diff --git a/smp-docker/compose/weblogic-oracle/data/weblogic/.gitignore b/smp-docker/compose/weblogic-oracle/data/weblogic/.gitignore new file mode 100644 index 000000000..2c487cd0d --- /dev/null +++ b/smp-docker/compose/weblogic-oracle/data/weblogic/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +.. +# Except the following +!.gitignore +!.disable_default_excludes \ No newline at end of file diff --git a/smp-docker/compose/weblogic-oracle/docker-compose.yml b/smp-docker/compose/weblogic-oracle/docker-compose.yml index 817f4c64f..3d2f7144e 100644 --- a/smp-docker/compose/weblogic-oracle/docker-compose.yml +++ b/smp-docker/compose/weblogic-oracle/docker-compose.yml @@ -1,8 +1,7 @@ version: "3.0" services: - database: + smp-oracle-db: image: smp-oradb-${ORA_VERSION}-${ORA_EDITION}:${SMP_VERSION} - container_name: smp_oracle_db hostname: smp-database.local environment: - ORACLE_CHARACTERSET=AL32UTF8 # set database encoding @@ -14,22 +13,66 @@ services: - 1921:1521 shm_size: '1gb' - weblogic: + smp-wls-admin: depends_on: - - database -# command: [bash, -c, "for i in `seq 10`; do timeout 1 bash -c '</dev/tcp/database/1521'; if [ $$? -eq 0 ] ; then break;fi;sleep 1; done;"] - command: [bash, -c, "for i in `seq 150`; do timeout 1 bash -c 'echo \" $$(ls /u01/status/)\"'; if [ -f '/u01/status/database.status' ] && [ \"$$( cat /u01/status/database.status )\" == 'DATABASE IS READY TO USE!' ] ; then break;fi; echo \"$$i. Wait for database!\"; sleep 10; done; /u01/oracle/startAdminServer.sh"] - image: smp-weblogic-122:${SMP_VERSION} - container_name: smp-wls-admin + - smp-oracle-db + command: [bash, -c, "rm -rf /u01/status/wls-admin.started;for i in `seq 150`; do timeout 1 bash -c 'echo \" $$(ls /u01/status/)\"'; if [ -f '/u01/status/database.status' ] && [ \"$$( cat /u01/status/database.status )\" == 'DATABASE IS READY TO USE!' ] ; then break;fi; echo \"$$i. Wait for database!\"; sleep 10; done; /u01/oracle/startAdminServer.sh"] + image: smp-weblogic-122:${SMP_VERSION:-4.2-RC2-SNAPSHOT} hostname: smp-wls-admin environment: - - MANAGED_SERV_NAME=smp-node - JAVA_OPTIONS="-Dweblogic.webservice.i18n.charset=utf-8" +# ports: +# - 7902:7001 volumes: - - ./properties/weblogic:/u01/oracle/properties + - ./properties/weblogic-init:/u01/init/ + - ./data:/data - ./status-folder:/u01/status/ + + smp-node-01: + # depend of the startup of the db + depends_on: + - smp-wls-admin + command: [bash, -c, "for i in `seq 200`; do timeout 1 bash -c 'echo \" $$(ls /u01/status/)\"'; if [ -f '/u01/status/wls-admin.started' ] ; then break;fi; echo \"$$i. Wait for admin server!\"; sleep 10; done; /u01/oracle/startManagedServer.sh"] + environment: + - WL_ADMIN_HOST=smp-wls-admin + - WL_MANAGED_SERV_NAME=smp-node-1 + image: smp-weblogic-122:${SMP_VERSION:-4.2-RC2-SNAPSHOT} + # ports: + # - "18453:8453" + # - "18001:8001" + volumes: + - ./data:/data + - ./status-folder:/u01/status/ + smp-node-02: + # depend of the startup of the db + depends_on: + - smp-wls-admin + command: [bash, -c, "for i in `seq 200`; do timeout 1 bash -c 'echo \" $$(ls /u01/status/)\"'; if [ -f '/u01/status/wls-admin.started' ] ; then break;fi; echo \"$$i. Wait for admin server!\"; sleep 10; done; /u01/oracle/startManagedServer.sh"] + environment: + - WL_ADMIN_HOST=smp-wls-admin + - WL_MANAGED_SERV_NAME=smp-node-2 + image: smp-weblogic-122:${SMP_VERSION:-4.2-RC2-SNAPSHOT} + # ports: + # - "18453:8453" + # - "18001:8001" + volumes: + - ./data:/data + - ./status-folder:/u01/status/ + + smp-httpd: + depends_on: + - smp-node-01 + - smp-node-02 + image: edelivery-docker.devops.tech.ec.europa.eu/domibustest/edelivery-httpd:2.4.39 + environment: + - VHOST_CORNER_HOSTNAME=smp.edelivery.eu + - NODES_COUNT=2 + - NODE_HOSTNAMES=smp-node-01,smp-node-02 + - NODE_PORT_NUMBERS=8001,8001 ports: - - 7901:7001 + - "7901:80" + restart: always + volumes: shared-status-folder: diff --git a/smp-docker/compose/weblogic-oracle/properties/weblogic-init/datasource.properties b/smp-docker/compose/weblogic-oracle/properties/weblogic-init/datasource.properties new file mode 100644 index 000000000..1f77d6d79 --- /dev/null +++ b/smp-docker/compose/weblogic-oracle/properties/weblogic-init/datasource.properties @@ -0,0 +1,9 @@ +dsname=eDeliverySmpDs +dsdbname=default;create=true +dsjndiname=jdbc/eDeliverySmpDs +dsdriver=oracle.jdbc.OracleDriver +dsurl=jdbc:oracle:thin:@//smp-oracle-db:1521/xe +dsusername=smp +dspassword=test +dstestquery=SQL SELECT 1 FROM DUAL +dsmaxcapacity=1 diff --git a/smp-docker/compose/weblogic-oracle/properties/weblogic-init/domain.properties b/smp-docker/compose/weblogic-oracle/properties/weblogic-init/domain.properties new file mode 100644 index 000000000..d7ac9c8f6 --- /dev/null +++ b/smp-docker/compose/weblogic-oracle/properties/weblogic-init/domain.properties @@ -0,0 +1,4 @@ +CLUSTER_TYPE=DYNAMIC +JAVA_OPTIONS=-Dweblogic.StdoutDebugEnabled=false +T3_CHANNEL_PORT=30012 +T3_PUBLIC_ADDRESS=kubernetes \ No newline at end of file diff --git a/smp-docker/compose/weblogic-oracle/properties/weblogic-init/domain_security.properties b/smp-docker/compose/weblogic-oracle/properties/weblogic-init/domain_security.properties new file mode 100644 index 000000000..3674a461b --- /dev/null +++ b/smp-docker/compose/weblogic-oracle/properties/weblogic-init/domain_security.properties @@ -0,0 +1,2 @@ +username=wls-smp +password=wls-pass-01 \ No newline at end of file diff --git a/smp-docker/compose/weblogic-oracle/properties/weblogic-init/smp.config.properties b/smp-docker/compose/weblogic-oracle/properties/weblogic-init/smp.config.properties new file mode 100644 index 000000000..d6cc55361 --- /dev/null +++ b/smp-docker/compose/weblogic-oracle/properties/weblogic-init/smp.config.properties @@ -0,0 +1,8 @@ + +configuration.dir=/data/smp/security +hibernate.dialect=org.hibernate.dialect.Oracle10gDialect +datasource.jndi=jdbc/eDeliverySmpDs +authentication.blueCoat.enabled=true +smp.truststore.password={DEC}{test123} +smp.keystore.password={DEC}{test123} +log.folder=./logs/ diff --git a/smp-docker/images/build-docker-images.sh b/smp-docker/images/build-docker-images.sh index 8ad17dc1a..6f0a43b2e 100755 --- a/smp-docker/images/build-docker-images.sh +++ b/smp-docker/images/build-docker-images.sh @@ -177,21 +177,21 @@ buildImages() { # build docker image for oracle database # ----------------------------------------------------------------------------- # oracle 1.2.0.2-xe (https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2) - #docker build -f ./oracle/oracle-db-${ORA_VERSION}/${ORACLE_DOCKERFILE} -t "smp-oradb-${ORA_VERSION}-${ORA_EDITION}:${SMP_VERSION}" --build-arg DB_EDITION=${ORA_EDITION} ./oracle/oracle-db-${ORA_VERSION}/ + docker build -f ./oracle/oracle-db-${ORA_VERSION}/${ORACLE_DOCKERFILE} -t "smp-oradb-${ORA_VERSION}-${ORA_EDITION}:${SMP_VERSION}" --build-arg DB_EDITION=${ORA_EDITION} ./oracle/oracle-db-${ORA_VERSION}/ # ----------------------------------------------------------------------------- # build docker image for oracle database # ----------------------------------------------------------------------------- # create docker OS image with java (https://github.com/oracle/docker-images/tree/master/OracleJava/java-8) - #docker build -t oracle/serverjre:8 ./oracle/OracleJava/java-8/ + docker build -t oracle/serverjre:8 ./oracle/OracleJava/java-8/ # create weblogic basic (https://github.com/oracle/docker-images/tree/master/OracleWebLogic/dockerfiles/12.2.1.3) - #docker build -f ./oracle/weblogic-12.2.1.4/Dockerfile.developer -t oracle/weblogic:12.2.1.4-developer ./oracle/weblogic-12.2.1.4/ + docker build -f ./oracle/weblogic-12.2.1.4/Dockerfile.developer -t oracle/weblogic:12.2.1.4-developer ./oracle/weblogic-12.2.1.4/ # build SMP deployment. docker build -t "smp-weblogic-122:${SMP_VERSION}" ./weblogic-12.2-smp/ --build-arg SMP_VERSION="$SMP_VERSION" # build tomcat mysql image deployment. - #docker build -t "smp-sml-tomcat-mysql:${SMP_VERSION}" ./tomcat-mysql-smp-sml/ --build-arg SMP_VERSION=${SMP_VERSION} + docker build -t "smp-sml-tomcat-mysql:${SMP_VERSION}" ./tomcat-mysql-smp-sml/ --build-arg SMP_VERSION=${SMP_VERSION} } function pushImageToDockerhub() { diff --git a/smp-docker/images/weblogic-12.2-smp/Dockerfile b/smp-docker/images/weblogic-12.2-smp/Dockerfile index 6286fc1b9..563aafa31 100644 --- a/smp-docker/images/weblogic-12.2-smp/Dockerfile +++ b/smp-docker/images/weblogic-12.2-smp/Dockerfile @@ -21,79 +21,80 @@ FROM oracle/weblogic:12.2.1.4-developer # Define variable ARG SMP_VERSION -ARG WL_ADMIN_HOST="${WL_ADMIN_HOST:-localhost}" -ARG CUSTOM_DOMAIN_NAME="${CUSTOM_DOMAIN_NAME:-domain1}" -ARG CUSTOM_ADMIN_PORT="${CUSTOM_ADMIN_PORT:-7001}" -ARG CUSTOM_ADMIN_HTTPS_PORT="${CUSTOM_ADMIN_HTTPS_PORT:-7002}" -ARG CUSTOM_MANAGED_SERVER_PORT="${CUSTOM_MANAGED_SERVER_PORT:-8001}" -ARG CUSTOM_DEBUG_PORT="${CUSTOM_DEBUG_PORT:-8453}" -ARG CUSTOM_ADMIN_NAME="${CUSTOM_ADMIN_NAME:-admin-server}" -ARG CUSTOM_ADMIN_HOST="${CUSTOM_ADMIN_HOST:-wlsadmin}" -ARG CUSTOM_CLUSTER_NAME="${CUSTOM_CLUSTER_NAME:-DockerCluster}" -ARG WL_SERVER_TLS_KEYSTORE_PASS="${WL_SERVER_TLS_KEYSTORE_PASS:-test123}" +ARG LC_ALL=en_US.UTF-8 +ARG LANG="en_US.UTF-8" +ARG LANGUAGE="en_US" +ARG ORACLE_HOME=/u01/oracle +ARG WL_DOMAIN_NAME="${WL_DOMAIN_NAME:-smp-domain}" +ARG WL_DOMAIN_HOME="${ORACLE_HOME}/user_projects/domains/${WL_DOMAIN_NAME}" +ARG WL_MANAGED_SERV_NAME=${WL_MANAGED_SERV_NAME:-smp-node-1} +ARG WL_MANAGED_SERV_BASE_NAME=${WL_MANAGED_SERV_BASE_NAME:-smp-node-} +ARG WL_MANAGED_SERVER_COUNT=${WL_MANAGED_SERVER_COUNT:-10} +ARG WL_ADMIN_NAME=${WL_ADMIN_NAME:-admin-server} +ARG WL_CLUSTER_NAME=${WL_CLUSTER_NAME:-smp-cluster} +ARG WL_DEBUG_PORT="${WL_DEBUG_PORT:-8453}" +ARG WL_ADMIN_PORT="${WL_ADMIN_PORT:-7001}" +ARG WL_ADMIN_PORT_HTTPS="${WL_ADMIN_PORT_HTTPS:-7002}" +ARG WL_MANAGED_SERVER_PORT="${WL_MANAGED_SERVER_PORT:-8001}" +ARG SMP_CONFIG_DIR=/data/smp +# set following build arguments also the environment arguments ENV APP_VERSION=$SMP_VERSION \ - LC_ALL=en_US.UTF-8 \ - LANG="en_US.UTF-8" \ - LANGUAGE="en_US" \ - ORACLE_HOME=/u01/oracle \ - PROPERTIES_FILE_DIR="${ORACLE_HOME}/properties" \ - DOMAIN_NAME="${CUSTOM_DOMAIN_NAME}" \ - DOMAIN_HOME="${ORACLE_HOME}/user_projects/domains/${CUSTOM_DOMAIN_NAME}" \ - ADMIN_PORT="${CUSTOM_ADMIN_PORT}" \ - ADMIN_HTTPS_PORT="${CUSTOM_ADMIN_HTTPS_PORT}" \ - ADMIN_NAME="${CUSTOM_ADMIN_NAME}" \ - ADMIN_HOST="${CUSTOM_ADMIN_HOST}" \ - CLUSTER_NAME="${CUSTOM_CLUSTER_NAME}" \ - MANAGED_SERVER_PORT="${CUSTOM_MANAGED_SERVER_PORT}" \ - MANAGED_SERV_NAME="${MANAGED_SERV_NAME}" \ - # set following build arguments also the environment arguments + LC_ALL=$LC_ALL \ + LANG=$LANG \ + LANGUAGE=$LANGUAGE \ + ORACLE_HOME=$ORACLE_HOME \ + DOCKER_DATA=/data \ + WL_INIT_PROPERTIES="/u01/init/" \ + WL_DOMAIN_NAME="${WL_DOMAIN_NAME}" \ + WL_DOMAIN_HOME="${ORACLE_HOME}/user_projects/domains/${WL_DOMAIN_NAME}" \ + WL_MANAGED_SERV_BASE_NAME="${WL_MANAGED_SERV_BASE_NAME}" \ + WL_MANAGED_SERVER_COUNT=${WL_MANAGED_SERVER_COUNT} \ WL_DEBUG_PORT="${WL_DEBUG_PORT}" \ - WL_ADMIN_NAME="${WL_ADMIN_NAME}" \ WL_ADMIN_PORT="${WL_ADMIN_PORT}" \ - WL_ADMIN_HOST="${WL_ADMIN_HOST}" \ + WL_ADMIN_PORT_HTTPS="${WL_ADMIN_PORT_HTTPS}" \ + WL_MANAGED_SERVER_PORT="${WL_MANAGED_SERVER_PORT}" \ + WL_ADMIN_NAME="${WL_ADMIN_NAME}" \ WL_CLUSTER_NAME="${WL_CLUSTER_NAME}" \ - ENABLE_JACOCO="${ENABLE_JACOCO}" \ - # set path variable for script execution - PATH=$PATH:/u01/oracle/oracle_common/common/bin:/u01/oracle/wlserver/common/bin:${DOMAIN_HOME}:${DOMAIN_HOME}/bin:/u01/oracle + SMP_CONFIG_DIR=${SMP_CONFIG_DIR} \ + CLASSPATH=${SMP_CONFIG_DIR}/config \ + WL_SECURITY_FILE=/data/weblogic/security.properties \ + PATH=$PATH:/u01/oracle/oracle_common/common/bin:/u01/oracle/wlserver/common/bin:${WL_DOMAIN_HOME}:${WL_DOMAIN_HOME}/bin:${ORACLE_HOME} \ + # configurable argumentst at containe start + WL_ADMIN_HOST="${WL_ADMIN_HOST:-localhost}" \ + WL_SERVER_TLS_KEYSTORE_PASS="${WL_SERVER_TLS_KEYSTORE_PASS:-test123}" \ + WL_DEBUG_FLAG="${WL_DEBUG_FLAG:-true}" \ + WL_PRODUCTION_MODE_ENABLED="${WL_PRODUCTION_MODE_ENABLED:-false}" \ + WL_MANAGED_SERV_NAME="${WL_MANAGED_SERV_NAME}" \ + WL_STATUS_FOLDER=${WL_STATUS_FOLDER:-/u01/status/} \ + ENABLE_JACOCO="${ENABLE_JACOCO:-false}" # Add files required to build this image COPY container-scripts/* ${ORACLE_HOME}/ -COPY container-scripts/init-scripts ${ORACLE_HOME}/init-scripts -COPY artefacts/smp.war ${ORACLE_HOME}/ -COPY properties/docker-build/domain*.properties ${PROPERTIES_FILE_DIR}/ +COPY container-scripts/init-scripts ${ORACLE_HOME}/init/scripts/ +COPY properties/init ${ORACLE_HOME}/init/properties/ +COPY artefacts/smp.war ${ORACLE_HOME}/init/ + + #Create directory where domain will be written to USER root -RUN chmod +xw ${ORACLE_HOME}/*.sh && \ - chmod +xw ${ORACLE_HOME}/init-scripts/*.sh && \ - chmod +xw ${ORACLE_HOME}/init-scripts/*.py && \ - mkdir -p ${PROPERTIES_FILE_DIR} && \ - chown -R oracle:oracle ${PROPERTIES_FILE_DIR} && \ - mkdir -p $DOMAIN_HOME && \ - chown -R oracle:oracle $DOMAIN_HOME && \ - chmod -R a+xwr $DOMAIN_HOME +WORKDIR $ORACLE_HOME +RUN mkdir -p $WL_DOMAIN_HOME && \ + mkdir -p $DOCKER_DATA && \ + chown -R oracle:oracle $ORACLE_HOME && \ + chown -R oracle:oracle $WL_DOMAIN_HOME && \ + chown -R oracle:oracle $DOCKER_DATA && \ + chmod +xw ${ORACLE_HOME}/*.sh && \ + chmod +xw ${ORACLE_HOME}/init/scripts/*.sh && \ + chmod +xw ${ORACLE_HOME}/init/scripts/*.py && \ + chmod -R +xwr $WL_DOMAIN_HOME -# Configuration of WLS Domain -#RUN /u01/oracle/createWLSDomain.sh && \ -# echo ". $DOMAIN_HOME/bin/setDomainEnv.sh" >> /u01/oracle/.bashrc && \ -# chmod -R a+x $DOMAIN_HOME/bin/*.sh && \ -# rm ${PROPERTIES_FILE_DIR}/*.properties - +USER oracle +WORKDIR $WL_DOMAIN_HOME # Expose ports for admin, managed server, and debug -EXPOSE $ADMIN_PORT $CUSTOM_ADMIN_HTTPS_PORT $MANAGED_SERVER_PORT $DEBUG_PORT - -WORKDIR $DOMAIN_HOME - - - -#RUN /u01/oracle/deploySMPToDomain.sh && \ -# wlst -loadProperties /u01/oracle/datasource.properties.oracle /u01/oracle/ds-deploy.py \ - # set enforce-valid-basic-auth-credentials false to allow basic authentication for rest services -# && sed -i -e "s/<\/security-configuration>/ <enforce-valid-basic-auth-credentials>false<\/enforce-valid-basic-auth-credentials>\n<\/security-configuration>/g" "/u01/oracle/user_projects/domains/domain1/config/config.xml" - - +EXPOSE $WL_ADMIN_PORT $WL_ADMIN_HTTPS_PORT $WL_MANAGED_SERVER_PORT $WL_DEBUG_PORT # Define default command to start bash. CMD ["startManagedServer.sh"] diff --git a/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/create-wls-domain.py b/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/create-wls-domain.py index 0d485eec1..7a1788e80 100644 --- a/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/create-wls-domain.py +++ b/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/create-wls-domain.py @@ -22,11 +22,9 @@ def getEnvVar(var): # This python script is used to create a WebLogic domain -#domain_uid = DOMAIN_UID server_port = int(MANAGED_SERVER_PORT) -domain_path = os.environ.get("DOMAIN_HOME") +domain_path = os.environ.get("WL_DOMAIN_HOME") cluster_name = CLUSTER_NAME -print('cluster_name : [%s]' % cluster_name); admin_server_name = ADMIN_NAME admin_port = int(ADMIN_PORT) admin_https_port = int(ADMIN_HTTPS_PORT) @@ -43,19 +41,18 @@ ksIdentityPassword = SERVER_TLS_KEYSTORE_PASS # Read the domain secrets from the common python file #execfile('%s/read-domain-secret.py' % script_dir) -print('domain_path : [%s]' % domain_path); -print('domain_name : [%s]' % domain_name); -print('admin_server_name : [%s]' % admin_server_name); -print('admin_port : [%s]' % admin_port); -print('cluster_name : [%s]' % cluster_name); -print('server_port : [%s]' % server_port); -print('number_of_ms : [%s]' % number_of_ms); -print('cluster_type : [%s]' % cluster_type); -print('managed_server_name_base : [%s]' % managed_server_name_base); -print('production_mode_enabled : [%s]' % production_mode_enabled); -#print('dsname : [%s]' % dsname); -print('t3_channel_port : [%s]' % t3_channel_port); -print('t3_public_address : [%s]' % t3_public_address); +print('domain_path : [%s]' % domain_path) +print('domain_name : [%s]' % domain_name) +print('admin_server_name : [%s]' % admin_server_name) +print('admin_port : [%s]' % admin_port) +print('cluster_name : [%s]' % cluster_name) +print('server_port : [%s]' % server_port) +print('number_of_ms : [%s]' % number_of_ms) +print('cluster_type : [%s]' % cluster_type) +print('managed_server_name_base : [%s]' % managed_server_name_base) +print('production_mode_enabled : [%s]' % production_mode_enabled) +print('t3_channel_port : [%s]' % t3_channel_port) +print('t3_public_address : [%s]' % t3_public_address) # Open default domain template # ============================ @@ -135,14 +132,7 @@ else: print('Done creating Server Template: %s' % templateName) cd('/ServerTemplates/%s' % templateName) cmo.setListenPort(server_port) -# cmo.setListenAddress('%s-%s${id}' % (domain_uid, managed_server_name_base_svc)) cmo.setCluster(cl) -# create(templateName,'Log') -# cd('Log/%s' % templateName) -# set('FileName', '%s${id}.log' % (managed_server_name_base)) -# print('Done setting attributes for Server Template: %s' % templateName); - - cd('/Clusters/%s' % cluster_name) create(cluster_name, 'DynamicServers') cd('DynamicServers/%s' % cluster_name) @@ -152,10 +142,11 @@ else: set('MaxDynamicClusterSize', number_of_ms) set('CalculatedListenPorts', false) - print('Done setting attributes for Dynamic Cluster: %s' % cluster_name); + print('Done setting attributes for Dynamic Cluster: %s' % cluster_name) # Write Domain # ============ +print('Write domain to: %s' % domain_path) writeDomain(domain_path) closeTemplate() print 'Domain Created' diff --git a/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/createWLSDomain.sh b/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/createWLSDomain.sh index 9e33085c7..2667fc1e1 100755 --- a/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/createWLSDomain.sh +++ b/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/createWLSDomain.sh @@ -4,23 +4,25 @@ # #Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. -#Define DOMAIN_HOME -echo "Domain Home is: " $DOMAIN_HOME +#Define WL_DOMAIN_HOME +INIT_SCRIPTS=$1 +echo "Domain Home is: $WL_DOMAIN_HOME" +echo "Scripts folder is: $INIT_SCRIPTS" # If AdminServer.log does not exists, container is starting for 1st time # So it should start NM and also associate with AdminServer # Otherwise, only start NM (container restarted) ########### SIGTERM handler ############ function _term() { - echo "Stopping container." - echo "SIGTERM received, shutting down the server!" - ${DOMAIN_HOME}/bin/stopWebLogic.sh + echo "Stopping container." + echo "SIGTERM received, shutting down the server!" + ${WL_DOMAIN_HOME}/bin/stopWebLogic.sh } ########### SIGKILL handler ############ function _kill() { - echo "SIGKILL received, shutting down the server!" - kill -9 $childPID + echo "SIGKILL received, shutting down the server!" + kill -9 $childPID } # Set SIGTERM handler @@ -30,60 +32,116 @@ trap _term SIGTERM trap _kill SIGKILL #Loop determining state of WLS -function check_wls { - action=$1 - host=$2 - port=$3 - sleeptime=$4 - while true - do - sleep $sleeptime - if [ "$action" == "started" ]; then - started_url="http://$host:$port/weblogic/ready" - echo -e "Waiting for WebLogic server to get $action, checking $started_url" - status=`/usr/bin/curl -s -i $started_url | grep "200 OK"` - echo "Status:" $status - if [ ! -z "$status" ]; then - break - fi - elif [ "$action" == "shutdown" ]; then - shutdown_url="http://$host:$port" - echo -e "Waiting for WebLogic server to get $action, checking $shutdown_url" - status=`/usr/bin/curl -s -i $shutdown_url | grep "500 Can't connect"` - if [ ! -z "$status" ]; then - break - fi - fi - done - echo -e "WebLogic Server has $action" +function check_wls() { + action=$1 + host=$2 + port=$3 + sleeptime=$4 + while true; do + sleep $sleeptime + if [ "$action" == "started" ]; then + started_url="http://$host:$port/weblogic/ready" + echo -e "Waiting for WebLogic server to get $action, checking $started_url" + status=$(/usr/bin/curl -s -i $started_url | grep "200 OK") + echo "Status:" $status + if [ ! -z "$status" ]; then + break + fi + elif [ "$action" == "shutdown" ]; then + shutdown_url="http://$host:$port" + echo -e "Waiting for WebLogic server to get $action, checking $shutdown_url" + status=$(/usr/bin/curl -s -i $shutdown_url | grep "500 Can't connect") + if [ ! -z "$status" ]; then + break + fi + fi + done + echo -e "WebLogic Server has $action" } +if [ -f ${WL_DOMAIN_HOME}/servers/${WL_ADMIN_NAME}/logs/${WL_ADMIN_NAME}.log ]; then + echo "Admin log file: [${WL_DOMAIN_HOME}/servers/${WL_ADMIN_NAME}/logs/${WL_ADMIN_NAME}.log] already exists - Skip domain creation!" + exit +fi + +DOMAIN_PROPERTY_DIR=/tmp/create-domain/properties +mkdir -p "${DOMAIN_PROPERTY_DIR}" -ADD_DOMAIN=1 -if [ -f ${DOMAIN_HOME}/servers/${ADMIN_NAME}/logs/${ADMIN_NAME}.log ]; then - exit +DOMAIN_PROPERTIES_FILE=${DOMAIN_PROPERTY_DIR}/domain.properties +SEC_PROPERTIES_FILE=${DOMAIN_PROPERTY_DIR}/domain_security.properties + +# copy domain properties - check first init folder else use default +if [ -e "${WL_INIT_PROPERTIES}/domain.properties" ]; then + cp -f "${WL_INIT_PROPERTIES}/domain.properties" "${DOMAIN_PROPERTIES_FILE}" +else + cp -f "${INIT_SCRIPTS}"/../properties/domain.properties "${DOMAIN_PROPERTIES_FILE}" +fi +# copy security properties - check first init folder else use default +if [ -e "${WL_INIT_PROPERTIES}/domain_security.properties" ]; then + cp -f "${WL_INIT_PROPERTIES}/domain_security.properties" "${SEC_PROPERTIES_FILE}" +else + cp -f "${INIT_SCRIPTS}"/../properties/domain_security.properties "${SEC_PROPERTIES_FILE}" fi -# Create Domain only if 1st execution -DOMAIN_PROPERTIES_FILE=${PROPERTIES_FILE_DIR}/domain.properties -SEC_PROPERTIES_FILE=${PROPERTIES_FILE_DIR}/domain_security.properties + + if [ ! -e "${SEC_PROPERTIES_FILE}" ]; then - echo "A properties file with the username and password needs to be supplied." - exit + echo "To increase security please provide custom admin username and password in ${SEC_PROPERTIES_FILE}." + defUsername=weblogic + randPass=$(LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 64) + echo "username=${defUsername}" >"${SEC_PROPERTIES_FILE}" + echo "password=${randPass}" >>"${SEC_PROPERTIES_FILE}" + echo "Generated WebLogic admin user with credentials: ${defUsername}/${randPass}" fi # Get Username -USER=`awk '{print $1}' ${SEC_PROPERTIES_FILE} | grep username | cut -d "=" -f2` +USER=$(awk '{print $1}' ${SEC_PROPERTIES_FILE} | grep username | cut -d "=" -f2) if [ -z "${USER}" ]; then - echo "The domain username is blank. The Admin username must be set in the properties file." - exit + echo "The domain username is blank. The Admin username must be set in the properties file." + exit fi # Get Password -PASS=`awk '{print $1}' ${SEC_PROPERTIES_FILE} | grep password | cut -d "=" -f2` +PASS=$(awk '{print $1}' ${SEC_PROPERTIES_FILE} | grep password | cut -d "=" -f2) if [ -z "${PASS}" ]; then - echo "The domain password is blank. The Admin password must be set in the properties file." - exit + echo "The domain password is blank. The Admin password must be set in the properties file." + exit fi + +cat <<EOT >> "${DOMAIN_PROPERTIES_FILE}" + +DOMAIN_NAME=${WL_DOMAIN_NAME} +ADMIN_PORT=${WL_ADMIN_PORT} +ADMIN_HTTPS_PORT=${WL_ADMIN_PORT_HTTPS} +ADMIN_NAME=${WL_ADMIN_NAME} +ADMIN_HOST=${WL_ADMIN_HOST} +MANAGED_SERVER_PORT=${WL_MANAGED_SERVER_PORT} +MANAGED_SERVER_NAME_BASE=${WL_MANAGED_SERV_BASE_NAME} +CONFIGURED_MANAGED_SERVER_COUNT=${WL_MANAGED_SERVER_COUNT} +CLUSTER_NAME=${WL_CLUSTER_NAME} +DEBUG_FLAG=${WL_DEBUG_FLAG} +PRODUCTION_MODE_ENABLED=${WL_PRODUCTION_MODE_ENABLED} +SERVER_TLS_KEYSTORE_PASS=${WL_SERVER_TLS_KEYSTORE_PASS} +EOT + +echo "Init domain with following properties" +cat ${DOMAIN_PROPERTIES_FILE} +echo "Show domain home $WL_DOMAIN_HOME" # Create domain -wlst.sh -skipWLSModuleScanning -loadProperties ${DOMAIN_PROPERTIES_FILE} -loadProperties ${SEC_PROPERTIES_FILE} /u01/oracle/create-wls-domain.py \ No newline at end of file +wlst.sh -skipWLSModuleScanning -loadProperties "${DOMAIN_PROPERTIES_FILE}" -loadProperties "${SEC_PROPERTIES_FILE}" "$INIT_SCRIPTS/create-wls-domain.py" + +ENC_PASS=$(java -cp $ORACLE_HOME/wlserver/server/lib/weblogic.jar -Dweblogic.RootDirectory=${WL_DOMAIN_HOME} weblogic.security.Encrypt ${PASS}); + +cat <<EOT > "$WL_SECURITY_FILE" +username=${USER} +password=${PASS} +EOT + + +if [ ! -z "$AS_SECURITY" ];then + mkdir -p ${AS_SECURITY} + cat <<EOT > "${AS_SECURITY}/boot.properties" +username=${USER} +password=${ENC_PASS} +EOT +fi diff --git a/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/deploySMPToDomain.sh b/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/deploySMPToDomain.sh index f74d954fe..9793ba9fa 100755 --- a/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/deploySMPToDomain.sh +++ b/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/deploySMPToDomain.sh @@ -1,27 +1,36 @@ #!/bin/bash -#Define DOMAIN_HOME -echo "Domain Home is: " $DOMAIN_HOME - - -if [ ! -d "$DOMAIN_HOME/classes" ]; then - mkdir -p "$DOMAIN_HOME/classes"; +#Define WL_DOMAIN_HOME +INIT_SCRIPTS=$1 +echo "Domain Home is: $WL_DOMAIN_HOME" +echo "Scripts folder is: $INIT_SCRIPTS" + +# set datasource property +DATA_SOURCE_PROPERTY_FILE="${INIT_SCRIPTS}/../properties/datasource.properties" +if [ -f "${WL_INIT_PROPERTIES}/datasource.properties" ]; then + DATA_SOURCE_PROPERTY_FILE="${WL_INIT_PROPERTIES}/datasource.properties" fi -# create smp property file -echo "hibernate.dialect=org.hibernate.dialect.Oracle10gDialect" > "$DOMAIN_HOME/classes/smp.config.properties" -echo "datasource.jndi=jdbc/eDeliverySmpDs" >> "$DOMAIN_HOME/classes/smp.config.properties" -echo "authentication.blueCoat.enabled=true" >> "$DOMAIN_HOME/classes/smp.config.properties" -echo "smp.truststore.password={DEC}{test123}" >> "$DOMAIN_HOME/classes/smp.config.properties" -echo "smp.keystore.password={DEC}{test123}" >> "$DOMAIN_HOME/classes/smp.config.properties" -echo "log.folder=./logs/" >> "$DOMAIN_HOME/classes/smp.config.properties" - -# create weblogic classpath to classes folder -echo "export CLASSPATH=\${CLASSPATH}:\${DOMAIN_HOME}/classes" >> "$DOMAIN_HOME/bin/setDomainEnv.sh" - - -cp /u01/oracle/smp.war "$DOMAIN_HOME/" +#deploy smp datasource +wlst.sh -loadProperties "${DATA_SOURCE_PROPERTY_FILE}" "${INIT_SCRIPTS}/ds-deploy.py" + +# copy smp startup configuration - check first init folder else use default +if [ -f "${WL_INIT_PROPERTIES}/smp.config.properties" ]; then + cat "${WL_INIT_PROPERTIES}/smp.config.properties" > "${SMP_CONFIG_DIR}/config/smp.config.properties" +elif [ -f "${INIT_SCRIPTS}/../properties/smp.config.properties" ]; then + cat "${INIT_SCRIPTS}/../properties/smp.config.properties" > "${SMP_CONFIG_DIR}/config/smp.config.properties" +else + cat <<EOT >"${SMP_CONFIG_DIR}/config/smp.config.properties" +hibernate.dialect=org.hibernate.dialect.Oracle10gDialect +datasource.jndi=jdbc/eDeliverySmpDs +authentication.blueCoat.enabled=true +log.folder=./logs/ +configuration.dir=${SMP_CONFIG_DIR}/security +EOT +fi +cp /u01/oracle/init/smp.war "${WL_DOMAIN_HOME}/" +ls -ltr "${WL_DOMAIN_HOME}/" # Deploy Application wlst.sh -skipWLSModuleScanning /u01/oracle/smp-app-deploy.py diff --git a/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/ds-deploy.py b/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/ds-deploy.py index 5c53fcefc..bcdc93c31 100644 --- a/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/ds-deploy.py +++ b/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/ds-deploy.py @@ -9,14 +9,25 @@ import os # Deployment Information -domainname = os.environ.get('DOMAIN_NAME', 'base_domain') -domainhome = os.environ.get('DOMAIN_HOME', '/u01/oracle/user_projects/domains/' + domainname) -cluster_name = "cluster-1" -admin_name = os.environ.get("ADMIN_NAME", "AdminServer") +domain_name = os.environ.get('WL_DOMAIN_NAME', 'base_domain') +domain_home = os.environ.get('WL_DOMAIN_HOME', '/u01/oracle/user_projects/domains/' + domain_name) +cluster_name = os.environ.get('WL_CLUSTER_NAME') +admin_name = os.environ.get("WL_ADMIN_NAME", "AdminServer") + + +print('Domain Home : [%s]' % domain_home) +print('Admin Name : [%s]' % admin_name) +print('Cluster Name : [%s]' % cluster_name) +print('Datasource name : [%s]' % dsname) +print('Datasource JNDI : [%s]' % dsjndiname) +print('Datasource URL : [%s]' % dsurl) +print('Datasource Driver: [%s]' % dsdriver) +print('Datasource User : [%s]' % dsusername) +print('Datasource Test : [%s]' % dstestquery) # Read Domain in Offline Mode # =========================== -readDomain(domainhome) +readDomain(domain_home) # Create Datasource # ================== @@ -54,7 +65,7 @@ print 'create JDBCConnectionPoolParams' cd('/JDBCSystemResource/' + dsname + '/JdbcResource/' + dsname) create('myJdbcConnectionPoolParams','JDBCConnectionPoolParams') cd('JDBCConnectionPoolParams/NO_NAME_0') -set('TestTableName','SQL SELECT 1 FROM DUAL') +set('TestTableName',dstestquery) # Assign # ====== diff --git a/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/smp-app-deploy.py b/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/smp-app-deploy.py index 5a77263a7..db6bd1c8a 100644 --- a/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/smp-app-deploy.py +++ b/smp-docker/images/weblogic-12.2-smp/container-scripts/init-scripts/smp-app-deploy.py @@ -11,21 +11,21 @@ import os # Deployment Information -domainhome = os.environ.get('DOMAIN_HOME', '/u01/oracle/user_projects/domains/base_domain') -admin_name = os.environ.get('ADMIN_NAME', 'AdminServer') -appVersion = os.environ.get('APP_VERSION', '4.2') -appfilename = os.environ.get('APP_FILE_NAME', 'smp') -appname = os.environ.get('APP_NAME', appfilename+'#'+appVersion) +domainhome = os.environ.get('WL_DOMAIN_HOME', '/u01/oracle/user_projects/domains/base_domain') +admin_name = os.environ.get('WL_ADMIN_NAME', 'AdminServer') +appVersion = os.environ.get('SMP_VERSION', '4.2') +appfilename = os.environ.get('WL_APP_FILE_NAME', 'smp') +appname = os.environ.get('WL_APP_NAME', appfilename+'#'+appVersion) appfile = os.environ.get('APP_FILE', 'smp.war') -appdir = os.environ.get('DOMAIN_HOME') -cluster_name = "cluster-1" +appdir = os.environ.get('WL_DOMAIN_HOME') +cluster_name = os.environ.get('WL_CLUSTER_NAME') -print('Domain Home : [%s]' % domainhome); -print('Admin Name : [%s]' % admin_name); -print('Cluster Name : [%s]' % cluster_name); -print('Application Name : [%s]' % appname); -print('appfile : [%s]' % appfile); -print('appdir : [%s]' % appdir); +print('Domain Home : [%s]' % domainhome) +print('Admin Name : [%s]' % admin_name) +print('Cluster Name : [%s]' % cluster_name) +print('Application Name : [%s]' % appname) +print('appfile : [%s]' % appfile) +print('appdir : [%s]' % appdir) # Read Domain in Offline Mode # =========================== readDomain(domainhome) diff --git a/smp-docker/images/weblogic-12.2-smp/container-scripts/startAdminServer.sh b/smp-docker/images/weblogic-12.2-smp/container-scripts/startAdminServer.sh index 9fb0bf62b..d18c686d2 100755 --- a/smp-docker/images/weblogic-12.2-smp/container-scripts/startAdminServer.sh +++ b/smp-docker/images/weblogic-12.2-smp/container-scripts/startAdminServer.sh @@ -5,20 +5,30 @@ #Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. #Define DOMAIN_HOME -echo "Domain Home is: " $DOMAIN_HOME - +echo "Oracle Home is: " "$ORACLE_HOME" +echo "Domain Home is: " "${WL_DOMAIN_HOME}" + +# init setup properties +STATUS_FILE=${WL_STATUS_FOLDER}/wls-admin.started +# delete status file if already exists.. +[ -e "${STATUS_FILE}" ] && rm "${STATUS_FILE}" + +function initWebLogicDomain(){ + echo "Init WebLogic domain" + INIT_SCRIPTS=$1 + echo "Start createWLSDomain.sh from ${INIT_SCRIPTS}" + "${INIT_SCRIPTS}"/createWLSDomain.sh "${INIT_SCRIPTS}" + echo "Set execution flag for all sh scripts in ${WL_DOMAIN_HOME}/bin" + chmod -R a+x ${WL_DOMAIN_HOME}/bin/*.sh +} function deploy_smp() { echo "Deploy SMP" - /u01/oracle/createWLSDomain.sh - echo ". $DOMAIN_HOME/bin/setDomainEnv.sh" >> /u01/oracle/.bashrc - chmod -R a+x $DOMAIN_HOME/bin/*.sh - rm ${PROPERTIES_FILE_DIR}/*.properties + INIT_SCRIPTS=$1 + "${INIT_SCRIPTS}"/deploySMPToDomain.sh "${INIT_SCRIPTS}" - /u01/oracle/deploySMPToDomain.sh - wlst -loadProperties /u01/oracle/datasource.properties.oracle /u01/oracle/ds-deploy.py \ - # set enforce-valid-basic-auth-credentials false to allow basic authentication for rest services - sed -i -e "s/<\/security-configuration>/ <enforce-valid-basic-auth-credentials>false<\/enforce-valid-basic-auth-credentials>\n<\/security-configuration>/g" "/u01/oracle/user_projects/domains/domain1/config/config.xml" + # set enforce-valid-basic-auth-credentials false to allow basic authentication for rest services + sed -i -e "s/<\/security-configuration>/ <enforce-valid-basic-auth-credentials>false<\/enforce-valid-basic-auth-credentials>\n<\/security-configuration>/g" "${WL_DOMAIN_HOME}/config/config.xml" } @@ -27,15 +37,15 @@ function deploy_smp() { # Otherwise, only start NM (container restarted) ########### SIGTERM handler ############ function _term() { - echo "Stopping container." - echo "SIGTERM received, shutting down the server!" - ${DOMAIN_HOME}/bin/stopWebLogic.sh + echo "Stopping container." + echo "SIGTERM received, shutting down the server!" + ${DOMAIN_HOME}/bin/stopWebLogic.sh } ########### SIGKILL handler ############ function _kill() { - echo "SIGKILL received, shutting down the server!" - kill -9 $childPID + echo "SIGKILL received, shutting down the server!" + kill -9 $childPID } # Set SIGTERM handler @@ -45,93 +55,107 @@ trap _term SIGTERM trap _kill SIGKILL #Loop determining state of WLS -function check_wls { - action=$1 - host=$2 - port=$3 - sleeptime=$4 - while true - do - sleep $sleeptime - if [ "$action" == "started" ]; then - started_url="http://$host:$port/weblogic/ready" - echo -e "Waiting for WebLogic server to get $action, checking $started_url" - status=`/usr/bin/curl -s -i $started_url | grep "200 OK"` - echo "Status:" $status - if [ ! -z "$status" ]; then - break - fi - elif [ "$action" == "shutdown" ]; then - shutdown_url="http://$host:$port" - echo -e "Waiting for WebLogic server to get $action, checking $shutdown_url" - status=`/usr/bin/curl -s -i $shutdown_url | grep "500 Can't connect"` - if [ ! -z "$status" ]; then - break - fi - fi - done - echo -e "WebLogic Server has $action" +function check_wls() { + action=$1 + host=$2 + port=$3 + sleeptime=$4 + echo "action:$action,host:$host,port:$port,sleeptime:$sleeptime," + while true; do + sleep $sleeptime + if [ "$action" == "started" ]; then + started_url="http://$host:$port/weblogic/ready" + echo -e "Waiting for WebLogic server to get $action, checking $started_url" + status=$(/usr/bin/curl -s -i $started_url | grep "200 OK") + echo "Status:" $status + if [ ! -z "$status" ]; then + break + fi + elif [ "$action" == "shutdown" ]; then + shutdown_url="http://$host:$port" + echo -e "Waiting for WebLogic server to get $action, checking $shutdown_url" + status=$(/usr/bin/curl -s -i $shutdown_url | grep "500 Can't connect") + if [ ! -z "$status" ]; then + break + fi + fi + done + echo -e "WebLogic Server has $action" } -export AS_HOME="${DOMAIN_HOME}/servers/${ADMIN_NAME}" +export AS_HOME="${WL_DOMAIN_HOME}/servers/${WL_ADMIN_NAME}" export AS_SECURITY="${AS_HOME}/security" -if [ -f ${AS_HOME}/logs/${ADMIN_NAME}.log ]; then - exit + + +if [ -f ${AS_HOME}/logs/${ADMIN_NAME}.log ]; then + exit fi echo "Admin Server Home: ${AS_HOME}" echo "Admin Server Security: ${AS_SECURITY}" -SEC_PROPERTIES_FILE=${PROPERTIES_FILE_DIR}/security.properties +# WL_SECURITY_FILE should be created in createWLSDomain script +SEC_PROPERTIES_FILE=${WL_SECURITY_FILE} if [ ! -e "${SEC_PROPERTIES_FILE}" ]; then - echo "A security.properties file with the username and password needs to be supplied." - exit + echo "A security.properties file with the username and password needs to be supplied." + exit fi -# Get Username -USER=`awk '{print $1}' ${SEC_PROPERTIES_FILE} | grep username | cut -d "=" -f2` -if [ -z "${USER}" ]; then - echo "The domain username is blank. The Admin username must be set in the properties file." - exit +# initialize docker image +cd ~ || exit 13 +if [ ! -f ".initialized" ]; then + INIT_SCRIPTS=${ORACLE_HOME}/init/scripts + initWebLogicDomain "${INIT_SCRIPTS}" + deploy_smp "${INIT_SCRIPTS}" + [ -f "${DOCKER_DATA}/${WL_CLUSTER_NAME}.jar" ] && rm -rf "${DOCKER_DATA}/${WL_CLUSTER_NAME}.jar" + pack.sh -domain="${WL_DOMAIN_HOME}" \ + -template="${DOCKER_DATA}/${WL_CLUSTER_NAME}.jar" \ + -template_name="${WL_CLUSTER_NAME}" \ + -managed="true" \ + -template_desc="${DOMAIN_NAME}-managed-template-for-SMP-${SMP_VERSION}" + + touch ~/.initialized fi + +# Get Username +#USER=$(awk '{print $1}' ${SEC_PROPERTIES_FILE} | grep username | cut -d "=" -f2) +#if [ -z "${USER}" ]; then +# echo "The domain username is blank. The Admin username must be set in the properties file." +# exit +#fi # Get Password -PASS=`awk '{print $1}' ${SEC_PROPERTIES_FILE} | grep password | cut -d "=" -f2` -if [ -z "${PASS}" ]; then - echo "The domain password is blank. The Admin password must be set in the properties file." - exit -fi +#PASS=$(awk '{print $1}' ${SEC_PROPERTIES_FILE} | grep password | cut -d "=" -f2) +#if [ -z "${PASS}" ]; then +# echo "The domain password is blank. The Admin password must be set in the properties file." +# exit +#fi #Define Java Options -JAVA_OPTIONS=`awk '{print $1}' ${SEC_PROPERTIES_FILE} | grep ^JAVA_OPTIONS= | cut -d "=" -f2` +JAVA_OPTIONS=$(awk '{print $1}' ${SEC_PROPERTIES_FILE} | grep ^JAVA_OPTIONS= | cut -d "=" -f2) if [ -z "${JAVA_OPTIONS}" ]; then - JAVA_OPTIONS="-Dweblogic.StdoutDebugEnabled=false" + JAVA_OPTIONS="-Dweblogic.StdoutDebugEnabled=false" fi export JAVA_OPTIONS=${JAVA_OPTIONS} -# Create domain -mkdir -p ${AS_SECURITY} -echo "username=${USER}" >> ${AS_SECURITY}/boot.properties -echo "password=${PASS}" >> ${AS_SECURITY}/boot.properties -${DOMAIN_HOME}/bin/setDomainEnv.sh -# initialize docker image -cd ~ || exit 13 -if [ ! -f ".initialized" ]; then - deploy_smp - touch ~/.initialized -fi +# Create domain +#mkdir -p ${AS_SECURITY} +#echo "username=${USER}" >>${AS_SECURITY}/boot.properties +#echo "password=${PASS}" >>${AS_SECURITY}/boot.properties +#${WL_DOMAIN_HOME}/bin/setDomainEnv.sh #echo 'Running Admin Server in background' -${DOMAIN_HOME}/bin/startWebLogic.sh & +${WL_DOMAIN_HOME}/bin/startWebLogic.sh & #echo 'Waiting for Admin Server to reach RUNNING state' -check_wls "started" localhost ${ADMIN_PORT} 2 +check_wls "started" localhost ${WL_ADMIN_PORT} 2 +echo "Smp admin server started" >>"$STATUS_FILE" # tail the Admin Server Logs -tail -f ${AS_HOME}/logs/${ADMIN_NAME}.log & +tail -f ${AS_HOME}/logs/${WL_ADMIN_NAME}.log & childPID=$! wait $childPID diff --git a/smp-docker/images/weblogic-12.2-smp/container-scripts/startManagedServer.sh b/smp-docker/images/weblogic-12.2-smp/container-scripts/startManagedServer.sh index 471b0e09d..97541ad33 100755 --- a/smp-docker/images/weblogic-12.2-smp/container-scripts/startManagedServer.sh +++ b/smp-docker/images/weblogic-12.2-smp/container-scripts/startManagedServer.sh @@ -6,25 +6,47 @@ # So it should start NM and also associate with AdminServer, as well Managed Server # Otherwise, only start NM (container is being restarted)o -export MS_HOME="${DOMAIN_HOME}/servers/${MANAGED_SERV_NAME}" +function initWebLogicDomain(){ + echo "Init WebLogic domain" + INIT_SCRIPTS=$1 + echo "Start createWLSDomain.sh from ${INIT_SCRIPTS}" + "${INIT_SCRIPTS}"/createWLSDomain.sh "${INIT_SCRIPTS}" + echo "Set execution flag for all sh scripts in ${WL_DOMAIN_HOME}/bin" + chmod -R a+x ${WL_DOMAIN_HOME}/bin/*.sh +} + + +export MS_HOME="${WL_DOMAIN_HOME}/servers/${WL_MANAGED_SERV_NAME}" export MS_SECURITY="${MS_HOME}/security" -if [ -f ${MS_HOME}/logs/${MANAGED_SERV_NAME}.log ]; then +if [ -f ${MS_HOME}/logs/${WL_MANAGED_SERV_NAME}.log ]; then + echo "Log file already exists ${MS_HOME}/logs/${WL_MANAGED_SERV_NAME}.log" exit fi # Wait for AdminServer to become available for any subsequent operation /u01/oracle/waitForAdminServer.sh -echo "Managed Server Name: ${MANAGED_SERV_NAME}" +echo "Managed Server Name: ${WL_MANAGED_SERV_NAME}" echo "Managed Server Home: ${MS_HOME}" echo "Managed Server Security: ${MS_SECURITY}" -SEC_PROPERTIES_FILE=${PROPERTIES_FILE_DIR}/security.properties +# initialize docker image +cd ~ || exit 13 +if [ ! -f ".initialized" ]; then + INIT_SCRIPTS=${ORACLE_HOME}/init/scripts + echo "create domain folder ${WL_DOMAIN_HOME}" + unpack.sh -template="${DOCKER_DATA}/${WL_CLUSTER_NAME}.jar" -domain="${WL_DOMAIN_HOME}" -app_dir="${WL_DOMAIN_HOME}" + touch ~/.initialized +fi + + +SEC_PROPERTIES_FILE=${WL_SECURITY_FILE} if [ ! -e "${SEC_PROPERTIES_FILE}" ]; then - echo "A properties file with the username and password needs to be supplied." + echo "A properties file with the username and password needs to be supplied. Use default properties" exit fi + # Get Username USER=`awk '{print $1}' ${SEC_PROPERTIES_FILE} | grep username | cut -d "=" -f2` if [ -z "${USER}" ]; then @@ -47,17 +69,19 @@ export JAVA_OPTIONS=${JAVA_OPTIONS} echo "Java Options: ${JAVA_OPTIONS}" # Create Managed Server -mkdir -p ${MS_SECURITY} -echo "username=${USER}" >> ${MS_SECURITY}/boot.properties -echo "password=${PASS}" >> ${MS_SECURITY}/boot.properties -${DOMAIN_HOME}/bin/setDomainEnv.sh +mkdir -p "${MS_SECURITY}" +echo "username=${USER}" >> "${MS_SECURITY}"/boot.properties +echo "password=${PASS}" >> "${MS_SECURITY}"/boot.properties + + +"${WL_DOMAIN_HOME}"/bin/setDomainEnv.sh # Start 'ManagedServer' echo "Start Managed Server" -${DOMAIN_HOME}/bin/startManagedWebLogic.sh ${MANAGED_SERV_NAME} http://${ADMIN_HOST}:${ADMIN_PORT} +"${WL_DOMAIN_HOME}"/bin/startManagedWebLogic.sh ${WL_MANAGED_SERV_NAME} http://${WL_ADMIN_HOST}:${WL_ADMIN_PORT} # tail Managed Server log -tail -f ${MS_HOME}/logs/${MANAGED_SERV_NAME}.log & +tail -f ${MS_HOME}/logs/"${WL_MANAGED_SERV_NAME}".log & childPID=$! wait $childPID diff --git a/smp-docker/images/weblogic-12.2-smp/properties/docker-build/domain.properties b/smp-docker/images/weblogic-12.2-smp/properties/docker-build/domain.properties deleted file mode 100644 index 9f8cc3296..000000000 --- a/smp-docker/images/weblogic-12.2-smp/properties/docker-build/domain.properties +++ /dev/null @@ -1,18 +0,0 @@ -DOMAIN_NAME=domain1 -ADMIN_PORT=7001 -ADMIN_HTTPS_PORT=7002 -ADMIN_NAME=admin-server -ADMIN_HOST=wlsadmin -MANAGED_SERVER_PORT=8001 -MANAGED_SERVER_NAME_BASE=managed-server -CONFIGURED_MANAGED_SERVER_COUNT=2 -CLUSTER_NAME=cluster-1 -DEBUG_PORT=8453 -DB_PORT=1527 -DEBUG_FLAG=true -PRODUCTION_MODE_ENABLED=true -CLUSTER_TYPE=DYNAMIC -JAVA_OPTIONS=-Dweblogic.StdoutDebugEnabled=false -T3_CHANNEL_PORT=30012 -T3_PUBLIC_ADDRESS=kubernetes -SERVER_TLS_KEYSTORE_PASS=test123 \ No newline at end of file diff --git a/smp-docker/images/weblogic-12.2-smp/properties/docker-build/domain_security.properties b/smp-docker/images/weblogic-12.2-smp/properties/docker-build/domain_security.properties deleted file mode 100644 index ee2eecf41..000000000 --- a/smp-docker/images/weblogic-12.2-smp/properties/docker-build/domain_security.properties +++ /dev/null @@ -1,2 +0,0 @@ -username=weblogic -password=Weblogic1 diff --git a/smp-docker/images/weblogic-12.2-smp/properties/docker-run/security.properties b/smp-docker/images/weblogic-12.2-smp/properties/docker-run/security.properties deleted file mode 100644 index 80e8e77e7..000000000 --- a/smp-docker/images/weblogic-12.2-smp/properties/docker-run/security.properties +++ /dev/null @@ -1,4 +0,0 @@ -username=weblogic -password=Weblogic1 -JAVA_OPTIONS=-Dweblogic.StdoutDebugEnabled=false - diff --git a/smp-docker/images/weblogic-12.2-smp/properties/init/datasource.properties b/smp-docker/images/weblogic-12.2-smp/properties/init/datasource.properties new file mode 100644 index 000000000..1f77d6d79 --- /dev/null +++ b/smp-docker/images/weblogic-12.2-smp/properties/init/datasource.properties @@ -0,0 +1,9 @@ +dsname=eDeliverySmpDs +dsdbname=default;create=true +dsjndiname=jdbc/eDeliverySmpDs +dsdriver=oracle.jdbc.OracleDriver +dsurl=jdbc:oracle:thin:@//smp-oracle-db:1521/xe +dsusername=smp +dspassword=test +dstestquery=SQL SELECT 1 FROM DUAL +dsmaxcapacity=1 diff --git a/smp-docker/images/weblogic-12.2-smp/properties/init/domain.properties b/smp-docker/images/weblogic-12.2-smp/properties/init/domain.properties new file mode 100644 index 000000000..d7ac9c8f6 --- /dev/null +++ b/smp-docker/images/weblogic-12.2-smp/properties/init/domain.properties @@ -0,0 +1,4 @@ +CLUSTER_TYPE=DYNAMIC +JAVA_OPTIONS=-Dweblogic.StdoutDebugEnabled=false +T3_CHANNEL_PORT=30012 +T3_PUBLIC_ADDRESS=kubernetes \ No newline at end of file diff --git a/smp-docker/images/weblogic-12.2-smp/properties/init/smp.config.properties b/smp-docker/images/weblogic-12.2-smp/properties/init/smp.config.properties new file mode 100644 index 000000000..d6cc55361 --- /dev/null +++ b/smp-docker/images/weblogic-12.2-smp/properties/init/smp.config.properties @@ -0,0 +1,8 @@ + +configuration.dir=/data/smp/security +hibernate.dialect=org.hibernate.dialect.Oracle10gDialect +datasource.jndi=jdbc/eDeliverySmpDs +authentication.blueCoat.enabled=true +smp.truststore.password={DEC}{test123} +smp.keystore.password={DEC}{test123} +log.folder=./logs/ -- GitLab