You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This document outlines an approach to fully automate configuration of a new EC2 Instance as an example of how to put an entire WebObjects/Wonder configuration into a container and mount the necessary files and folders to completely and independently run your WO instance on any platform.

This example is based on the TruAnon docker, found here

The process starts with a stub script where EC2 instances can update and install the minimal requirements for bootstrapping your container installation. There are also two scripts linked from your own app deployment, one configures the rest of your instance and the other simply runs the application. You must login to your newly Stubbed out EC2 Instance where your deployment has already been checked out. Your deployment WebserverResources can contain a simple sbin where you can keep scripts like these examples.




Explanation of Docker Mount Points

By linking to your deployment folder, you can mount scripts and configurations all so they are always pointing to whatever you have in deployment and the container will use those files. This includes handy items like your httpd.conf and JavaMonitor settings which you might update over time or configure specifically for your deployment.

You can add your own dependencies in much the same way.

Example Stub Initializes a new EC2 Instance

This stub can be pasted into a text area on the EC2 Launch Instance Wizard or you can link to a copy on your local computer. I find it easier to simply paste this into the text before launching. You can see this updates the server instance, installs GIT and Docker. It then starts up Docker and stuff some credentials and keys into the .netrc for the ec2-user. A short script to clone the GIT repo and make some links is generated and then run on the fly as the ec2-user and this finalizes the one-time setup/configuraiton.

# this stub will run as root
# you must set intended hostname

yum update -y
yum install git -y
yum install docker -y
service docker start
usermod -a -G docker ec2-user

mkdir -p ~ec2-user/wodocker/git
chown -R ec2-user:ec2-user ~ec2-user/wodocker

# stuff git credentials .netrc
touch ~ec2-user/.netrc
cat >~ec2-user/.netrc <<EOF
       login XXX
       password XXXXX

chown ec2-user:ec2-user ~ec2-user/.netrc
chmod go-rwx ~ec2-user/.netrc

# stuff awssecret
touch ~ec2-user/.awssecret
cat >~ec2-user/.awssecret <<EOF

chown ec2-user:ec2-user ~ec2-user/.awssecret
chmod go-rwx ~ec2-user/.awssecret

chown -R ec2-user:ec2-user ~ec2-user/wodocker/

# git clone deployment
# link scripts to ~ec2-user
# generate to later be run as ec2-user

touch ~ec2-user/
cat >~ec2-user/ <<EOF
cd ~/wodocker/git ; git clone
ln -s ~/wodocker/git/XXXXX/XXXXX/Contents/Resources/sbin/ ~/
ln -s ~/wodocker/git/XXXXX/XXXXX/Contents/Resources/sbin/ ~/
sh ./ ; sh ./

chown ec2-user:ec2-user ~ec2-user/
chmod go-rwx ~ec2-user/

# done

Example sets up JavaMonitor and preps the installation once

This script sets up JavaMonitor however you want, add instances and setup the host names and apps and password all using CURL. 

# new EC2 Instance configure script
# /home/ec2-user/wodocker/git/XXX_Deploy/XXX.woa/Contents/Resources/sbin/

echo "Add to JavaMonitor"
curl -X POST -d "{id: '',type: 'MHost', osType: 'UNIX',address: '', name: ''}"

echo "Configure WOAdaptorURL"
curl -X PUT -d “{woAdaptor:''}"

echo "Add JavaMonitor"
curl -X POST -d "{id: 'JavaMonitor',type: 'MApplication', name: 'JavaMonitor',unixOutputPath: '/var/log/WebObjects', unixPath: '/woapps/JavaMonitor.woa/JavaMonitor'}"
curl -X GET

echo "Add XXX”
curl -X POST -d "{id: ‘XXX',type: 'MApplication', name: ‘XXX', additionalArgs: '-Xms64m -Xmx300m -DWOAllowsConcurrentRequestHandling=true -WOStatisticsPassword wonderpass',unixOutputPath: '/var/log/WebObjects', unixPath: ‘/mywoapps/XXX.woa/XXX’}"
curl -X GET

echo "Configure JavaMonitor Password"
curl -X PUT -d "{password:'XXXXXXX'}"

echo "Initialization Complete"

Example simply starts up the app because the mount points and launch args are a bit cumbersome

This script is meant to simply contain the launch stuff because the container and mount points are complicated. There are ways to reduce that clutter, but this is where I left off.

# new EC2 Instance preparation script
# sh ./

display_usage() { 
  echo "Include a host name" 
  echo -e "\nUsage:\n sh ./ []\n\n" 

if [ $# == 0 ]; then 
  exit 1

echo "Spark XXX at host name " $1
# visibly mark this EC2 with the machine/host name
touch ~/$1

# start docker by passing in that host name
docker run -d -ti --rm -p 80:80 -p 56789:56789 --hostname $1 .....more args here....

The End Result

The result of all this setup and configuration is you can spark up a new EC2 instance using the stub. This starts and kicks off a configuration that sets up the entire server and application from end-to-end. You do need to log into your EC2 instance after the stub runs and run the configure yourself but otherwise the entire application launches into the container fully configured and operational.

  • No labels