Skip to content

Add 12213 Docker image sample for Apache with WebLogic 12.2.1.3.0 Proxy Plugin #849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions OracleWebLogic/samples/12213-webtier-apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Example of Apache Web Server with WebLogic plugin for load balancing WebLogic on Docker Containers
#
# Copyright (c) 2016-2018 Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# fmw_12.2.1.3.0_wlsplugins_Disk1_1of1.zip
# Download the generic installer from http://www.oracle.com/technetwork/middleware/webtier/downloads/index-jsp-156711.html and save it in this same folder.
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# RUN:
# $ sh buildDockerImage.sh
#
# PULL BASE IMAGE
# -----------------------------------
FROM oraclelinux:7-slim

# Environment variables required for this build (do NOT change)
# ----------------------------------------------
ENV FMW_PKG="fmw_12.2.1.3.0_wlsplugins_Disk1_1of1.zip" \
PLUGINS_PKG="WLSPlugins12c-12.2.1.3.0.zip" \
PLUGIN_PKG="WLSPlugin12.2.1.3.0-Apache2.2-Apache2.4-Linux_x86_64-12.2.1.3.0.zip" \
PLUGIN_HOME="/root" \
MOD_WLS_PLUGIN="mod_wl_24.so" \
LD_LIBRARY_PATH="/root/lib" \
WEBLOGIC_CLUSTER="server0:7002,server1:7002" \
LOCATION="/weblogic" \
WEBLOGIC_HOST="wlsadmin" \
WEBLOGIC_PORT="7001"

# Copy required files to build this image
# ------------------------------------------------------
COPY $FMW_PKG /tmp/
COPY weblogic.conf /etc/httpd/conf.d/
COPY custom_mod_wl_apache.conf.sample /config/custom_mod_wl_apache.conf
COPY container-scripts/* /u01/oracle/container-scripts/

# Use unzip because the base image does not contain a JDK
# Note that adding unzip does not noticeably increase the size of the image
RUN yum install -y unzip && \
yum install -y httpd && \
unzip /tmp/$FMW_PKG -d /tmp && \
unzip /tmp/$PLUGINS_PKG -d /tmp && \
unzip /tmp/$PLUGIN_PKG -d $PLUGIN_HOME && \
sed -i -e "s;logs/error_log;/proc/self/fd/2;" /etc/httpd/conf/httpd.conf && \
sed -i -e "s;logs/access_log;/proc/self/fd/1;" /etc/httpd/conf/httpd.conf && \
rm /tmp/$PLUGINS_PKG /tmp/WLSPlugin12.2.1.3.0-*.zip /tmp/$FMW_PKG /tmp/fmw_12213_readme*

#Expose ports
EXPOSE 80

# Provision Apache instance
CMD ["/u01/oracle/container-scripts/run-httpd.sh"]
95 changes: 95 additions & 0 deletions OracleWebLogic/samples/12213-webtier-apache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
Apache Web Server with Oracle WebLogic Server Proxy Plugin on Docker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mriccell doesn't it make more sense to call this the "WebLogic Server Proxy Plugin for Apache" image, i.e. make the WebLogic plugin the primary focus, not Apache?

You're the PM, so whatever you say goes, but it just seems weird to me to have all this Apache stuff when really it's about the WebLogic plugin bits. :)

===============
This project includes a quick start Dockerfile and samples for standalone Apache Web Server with 12.2.1.3.0 Oracle WebLogic Server Proxy Plugin based on Oracle Linux. The certification of Apache on Docker does not require the use of any file presented in this repository. Customers and users are welcome to use them as starters, and customize/tweak, or create from scratch new scripts and Dockerfiles.

## How to Build Apache With Plugin Docker Image

This project offers a Dockerfile for Apache Web Server with Oracle WebLogic Server Proxy Plugin in standalone mode. To assist in building the images, you can use `buildDockerImage.sh` script. See below for instructions and usage.

The `buildDockerImage.sh` script is just a utility shell script that performs MD5 checks and is an easy way for beginners to get started. Expert users are welcome to directly call docker build with their preferred set of parameters.

IMPORTANT: You have to download the **Oracle WebLogic Server Proxy Plugin 12.2.1.3.0** package (see .download file) and drop them in this directory.

Run `buildDockerImage.sh` script.

$ sh buildDockerImage.sh

## How to run container

Run an Apache container to access an admin server, or a managed server in a non-clustered environment, that is running on `<host>` and listening to `<port>`.

$ docker run -d -e WEBLOGIC_HOST=<host> WEBLOGIC_PORT=<port> -p 80:80 12213-apache

Run an Apache image to proxy and load balance to a list of managed servers in a cluster

Use a list of hosts and ports.

$ docker run -d -e WEBLOGIC_CLUSTER=host1:port,host2:port,host3:port -p 80:80 12213-apache

Or use a cluster URL if it is available

$ docker run -d -e WEBLOGIC_CLUSTER=<cluster-url> -p 80:80 12213-apache

The values of **WEBLOGIC_CLUSTER** must be valid, and correspond to existing containers running WebLogic servers.

### Admin Server Only Example

First make sure you have the WebLogic Server 12.2.1.3 install image, pull the WebLogic install image from the DockerStore `store/oracle/weblogic:12.2.1.3`, or build your own image `oracle/weblogic:12.2.1.3-developer` at [https://github.com/oracle/docker-images/tree/master/OracleWebLogic/dockerfiles/12.2.1.3].

Start a container from the WebLogic install image. You can override the default values of the following parameters during runtime with the -e option:

ADMIN_NAME (default: AdminServer)
ADMIN_PORT (default: 7001)
ADMIN_USERNAME (default: weblogic)
ADMIN_PASSWORD (default: Auto Generated)
DOMAIN_NAME (default: base_domain)
DOMAIN_HOME (default: /u01/oracle/user_projects/domains/base_domain)

NOTE: To set the DOMAIN_NAME, you must set both DOMAIN_NAME and DOMAIN_HOME.

$ docker run -d -e ADMIN_USERNAME=weblogic -e ADMIN_PASSWORD=welcome1 -e DOMAIN_HOME=/u01/oracle/user_projects/domains/abc_domain -e DOMAIN_NAME=abc_domain -p 7001:7001 store/oracle/weblogic:12.2.1.3

Start an Apache container by calling:

$ docker run -d --name apache -e WEBLOGIC_HOST=<admin-host> -e WEBLOGIC_PORT=7001 -p 80:80 12213-apache

Now you can access the WebLogic Admin Console under **http://localhost/console** (default to port 80) instead of using port 7001. You can access the console from a remote machine using the weblgoic admin server's `<admin-host>` instead of `localhost`.

## Provide Your Own Apache Plugin Configuration
If you want to start the Apache container with some pre-specified `mod_weblogic` configuration:

* Create a `custom_mod_wl_apache.conf` file by referring to `custom_mod_wl_apache.conf.sample` and Chapter 3 @ Fusion Middleware Using Oracle WebLogic Server Proxy Plug-Ins documentation. [https://docs.oracle.com/middleware/12213/webtier/develop-plugin/apache.htm#GUID-231FB5FD-8D0A-492A-BBFD-DC12A31BF2DE]

* Place the `custom_mod_wl_apache.conf` file in a directory `<host-config-dir>` on the host machine and then mount this directory into the container at the location `/config`. By doing so, the contents of host directory `<host-config-dir>` (and hence `custom_mod_wl_apache.conf`) will become available in the container at the mount point.

This mounting can be done by using the -v option with the `docker run` command as shown below.

$ docker run -v <host-config-dir>:/config -w /config -d -e WEBLOGIC_HOST=<admin-host> -e WEBLOGIC_PORT=7001 -p 80:80 12213-apache

Note: you can also mount the file directly as follows.

$ docker run -v <host-config-dir>/custom_mod_wl_apache.conf:/config/custom_mod_wl_apache.conf -w /config -d -e WEBLOGIC_HOST=<admin-host> -e WEBLOGIC_PORT=7001 -p 80:80 12213-apache

Once the mounting is done, the custom_mod_wl_apache.conf will replace the built-in version of the file.

## Stopping the Apache instance

To stop the Apache instance, execute the following command:

$ docker stop apache (Assuming the name of container is 'apache')

To look at the Docker Container logs run:

$ docker logs --details <Container-id>

## License
To download and run Oracle WebLogic Server Proxy Plugins 12.2.1.3.0 Distribution regardless of inside or outside a Docker container, and regardless of the distribution, you must download the binaries from Oracle website and accept the license indicated at that page.

To download and run Oracle JDK regardless of inside or outside a Docker container, you must download the binary from Oracle website and accept the license indicated at that page.

All scripts and files hosted in this project required to build the Docker images are, unless otherwise noted, released under the Universal Permissive License v1.0.

## Copyright
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.


128 changes: 128 additions & 0 deletions OracleWebLogic/samples/12213-webtier-apache/buildDockerImage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/bin/bash
#
# Since: May, 2018
# Author: dongbo.xiao@oracle.com
# Description: script to build a Docker image for Oracle HTTP Server. The install mode is "standalone" i.e. Apache is not managed by or registered to an Oracle WebLogic Server domain
#
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (c) 2016-2018 Oracle and/or its affiliates. All rights reserved.
#
#
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
usage() {
cat << EOF

Usage: buildDockerImage.sh -v [version] [-s]
Builds a Docker Image for Oracle HTTP Server (standalone) .

Parameters:
-v: Release version to build. Required. E.g 12.2.1.3.0
-s: skips the MD5 check of packages

LICENSE Universal Permissive License v1.0

Copyright (c) 2016-2018: Oracle and/or its affiliates. All rights reserved.


EOF
exit 0
}


# Validate packages
checksumPackages() {
echo "Checking if required packages are present and valid..."
md5sum -c *.download
if [ "$?" -ne 0 ]; then
echo "MD5 for required packages to build this image did not match!"
echo "Make sure to download missing files in folder dockerfiles. See *.download files for more information"
exit $?
fi
}


#Parameters
VERSION="12.2.1.3.0"
SKIPMD5=0
while getopts "hsdgiv:" optname; do
case "$optname" in
"h")
usage
;;
"s")
SKIPMD5=1
;;
"v")
VERSION="$OPTARG"
;;
*)
# Should not occur
echo "Unknown error while processing options inside buildDockerImage.sh"
;;
esac
done

# Apache Image Name
IMAGE_NAME="12213-apache"

# cd $VERSION

if [ ! "$SKIPMD5" -eq 1 ]; then
checksumPackages
else
echo "Skipped MD5 checksum."
fi

# Proxy settings
PROXY_SETTINGS=""
if [ "${http_proxy}" != "" ]; then
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg http_proxy=${http_proxy}"
fi

if [ "${https_proxy}" != "" ]; then
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg https_proxy=${https_proxy}"
fi

if [ "${ftp_proxy}" != "" ]; then
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg ftp_proxy=${ftp_proxy}"
fi

if [ "${no_proxy}" != "" ]; then
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg no_proxy=${no_proxy}"
fi

if [ "$PROXY_SETTINGS" != "" ]; then
echo "Proxy settings were found and will be used during build."
fi

# ################## #
# BUILDING THE IMAGE #
# ################## #
echo "Building image '$IMAGE_NAME' ..."
echo "Proxy Settings '$PROXY_SETTINGS'"
# BUILD THE IMAGE (replace all environment variables)
BUILD_START=$(date '+%s')
docker build --force-rm=true --no-cache=true $PROXY_SETTINGS -t $IMAGE_NAME -f Dockerfile . || {
echo "There was an error building the image."
exit 1
}
BUILD_END=$(date '+%s')
BUILD_ELAPSED=`expr $BUILD_END - $BUILD_START`

echo ""

if [ $? -eq 0 ]; then
cat << EOF
Apache Standalone Docker Image for version: $VERSION is ready to be used.

--> $IMAGE_NAME

Build completed in $BUILD_ELAPSED seconds.

EOF
else
echo "Apache Docker Image was NOT successfully created. Check the output and correct any reported problems with the docker build operation."
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -e

# Apache gets grumpy about PID files pre-existing
rm -f /run/httpd/httpd.pid

exec httpd -DFOREGROUND
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
# LoadModule weblogic_module /root/lib/${MOD_WLS_PLUGIN}

<IfModule mod_weblogic.c>
WebLogicHost ${WEBLOGIC_HOST}
WebLogicPort ${WEBLOGIC_PORT}
</IfModule>

# Directive for weblogic admin Console deployed on Weblogic Admin Server
<Location /console>
SetHandler weblogic-handler
WebLogicHost ${WEBLOGIC_HOST}
WeblogicPort ${WEBLOGIC_PORT}
</Location>

# Directive for all application deployed on weblogic cluster with a prepath defined by LOCATION variable
# For example, if the LOCAITON is set to '/weblogic', all applications deployed on the cluster can be accessed via
# http://myhost:myport/weblogic/application_end_url
# where 'myhost' is the IP of the machine that runs the Apache web tier, and
# 'myport' is the port that the Apache web tier is publicly exposed to.
# Note that LOCATION cannot be set to '/' unless this is the only Location module configured.
<Location ${LOCATION}>
WLSRequest On
WebLogicCluster ${WEBLOGIC_CLUSTER}
PathTrim ${LOCATION}
</Location>

# Directive for all application deployed on weblogic cluster with a prepath defined by LOCATION2 variable
# For example, if the LOCAITON2 is set to '/weblogic2', all applications deployed on the cluster can be accessed via
# http://myhost:myport/weblogic2/application_end_url
# where 'myhost' is the IP of the machine that runs the Apache web tier, and
# 'myport' is the port that the Apache webt ier is publicly exposed to.
# <Location ${LOCATION2}>
# WLSRequest On
# WebLogicCluster ${WEBLOGIC_CLUSTER2}
# PathTrim ${LOCATION2}
# </Location>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Download file fmw_12.2.1.3.0_wlsplugins_Disk1_1of1.zip from the following address:
# - http://www.oracle.com/technetwork/middleware/webtier/downloads/index-jsp-156711.html
6ca6041f926e72245f88f4fb152668d1 fmw_12.2.1.3.0_wlsplugins_Disk1_1of1.zip
9 changes: 9 additions & 0 deletions OracleWebLogic/samples/12213-webtier-apache/weblogic.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
LoadModule weblogic_module /root/lib/${MOD_WLS_PLUGIN}

<IfModule mod_weblogic.c>
# Config file for WebLogic Server that defines the parameters
Include /config/custom_mod_wl_apache.conf
</IfModule>