#!/bin/sh
# get private ip address of container
local_ip=$(ifconfig eth0 | awk '/inet addr:/ {print $2}'|sed 's/addr://')
# set local cluster port (port used in the container to communicate with the eventbus)
local_cluster_port=4000
# launch the module
cd /opt/app
vertx runmod com.example~main~1.0-SNAPSHOT -cp . -cluster -cluster-host $local_ip -cluster-port $local_cluster_port
FROM ubuntu:14.04
MAINTAINER Santo s_a_n_t_o_._p_r_i_v_e_(at)_g_m_a_i_l_._c_o_m
###
### Install Oracle java
###
# Enable PPA's
RUN sudo apt-get -y install software-properties-common
# Add PPA for Oracle Java (v8)
RUN sudo add-apt-repository ppa:webupd8team/java
# Update package index
RUN sudo apt-get update
# Automatically accept license for installations of java
RUN sudo echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
# Install Oracle Java (v8)
RUN sudo apt-get -y install oracle-java8-installer
# Optional: Check java version
RUN java -version
###
### Install Vert.x
###
# Download Vert.x package (currently v2.1.2)
RUN sudo wget http://dl.bintray.com/vertx/downloads/vert.x-2.1.2.tar.gz -P /tmp
# Extract Vert.x package
RUN cd /opt
RUN sudo tar -zxvf /tmp/vert.x-2*.tar.gz -C /opt
# Create symlink to this vert.x version
RUN cd /opt
RUN sudo ln -s /opt/vert.x-2.1.2 /opt/vertx
# Add vert.x to system classpath
ENV PATH $PATH:/opt/vert.x-2.1.2/bin
# Increase log level of hazelcast, so we can see some useful information
RUN sudo sed -i "s/\(com\.hazelcast\.level=\).*\$/\1INFO/" /opt/vertx/conf/logging.properties
# Optional: Check vert.x version
RUN vertx version
###
### Install our vert.x module
###
# Add the application
ADD target/mods/com.example~main~1.0-SNAPSHOT/. /opt/app
# Add the application launcher
ADD launch.sh /opt/app/
RUN chmod +x /opt/app/launch.sh
# Expose application ports (only required for the web module)
EXPOSE 8888
# Run the application
CMD ["/opt/app/launch.sh"]
cd <path-to-main-module-repository>
sudo docker build -t main-module --rm .
cd <path-to-web-module-repository>
sudo docker build -t web-module --rm .
sudo docker run -t -i --rm --name main -h main -P -p 5701:5701 -p 4001:4000 web-module /bin/bash
## The public host is the public ip address of the host where the container is running
## The public port is the "host port" that maps to the container port as specified via the docker run command (-p <hostport>:<containerport>, e.g. -p 4001:4000)
VERTX_OPTS="-Dvertx.cluster.public.host=192.168.1.205 -Dvertx.cluster.public.port=4001"
<properties>
<property name="hazelcast.mancenter.enabled">false</property>
<property name="hazelcast.memcache.enabled">false</property>
<property name="hazelcast.rest.enabled">false</property>
<property name="hazelcast.wait.seconds.before.join">0</property>
<property name="hazelcast.logging.type">jdk</property>
<!-- CHANGE: add next 3 lines, first line is the PRIVATE ip address of the container -->
<property name="hazelcast.local.localAddress">172.17.0.3</property>
<property name="hazelcast.socket.server.bind.any">false</property>
<property name="hazelcast.socket.client.bind">false</property>
</properties>
<!-- CHANGE: This is the public ip address of the host: -->
<public-address>192.168.1.205</public-address>
<!-- CHANGE: This port should be mapped on the docker level, e.g. -p 5701:5701: -->
<port auto-increment="false" port-count="100">5701</port>
<outbound-ports>
<!--
Allowed port range when connecting to other nodes.
0 or * means use system provided port.
-->
<ports>0</ports>
</outbound-ports>
<join>
<!-- CHANGE: disable multicast -->
<multicast enabled="false">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<!-- CHANGE: enable tcp-ip and specify the public ip addresses of all the hosts that should communicate -->
<tcp-ip enabled="true">
<interface>192.168.1.49</interface>
<interface>192.168.1.205</interface>
</tcp-ip>
[...snip...]
/opt/app/launch.sh
sudo docker save -o ./web-module.tar web-module
scp web-module.tar administrator@192.168.1.49:/home/administrator/tmp
ssh administrator@192.168.1.49
cd /home/administrator/tmp
sudo docker -i web-module.tar
sudo docker run -t -i --rm --name web -h web -P -p 5701:5701 -p 4002:4000 web-module /bin/bash
## The public host is the public ip address of the host where the container is running
## The public port is the "host port" that maps to the container port as specified via the docker run command (-p <hostport>:<containerport>, e.g. -p 4002:4000)
VERTX_OPTS="-Dvertx.cluster.public.host=192.168.1.49 -Dvertx.cluster.public.port=4002"
<properties>
<property name="hazelcast.mancenter.enabled">false</property>
<property name="hazelcast.memcache.enabled">false</property>
<property name="hazelcast.rest.enabled">false</property>
<property name="hazelcast.wait.seconds.before.join">0</property>
<property name="hazelcast.logging.type">jdk</property>
<!-- CHANGE: add next 3 lines, first line is the PRIVATE ip address of the container -->
<property name="hazelcast.local.localAddress">172.17.0.23</property>
<property name="hazelcast.socket.server.bind.any">false</property>
<property name="hazelcast.socket.client.bind">false</property>
</properties>
<!-- CHANGE: This is the public ip address of the host: -->
<public-address>192.168.1.49</public-address>
<!-- CHANGE: This port should be mapped on the docker level, e.g. -p 5701:5701: -->
<port auto-increment="false" port-count="100">5701</port>
<outbound-ports>
<!--
Allowed port range when connecting to other nodes.
0 or * means use system provided port.
-->
<ports>0</ports>
</outbound-ports>
<join>
<!-- CHANGE: disable multicast -->
<multicast enabled="false">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<!-- CHANGE: enable tcp-ip and specify the public ip addresses of all the hosts that should communicate -->
<tcp-ip enabled="true">
<interface>192.168.1.205</interface>
<interface>192.168.1.49</interface>
</tcp-ip>
[...snip...]
/opt/app/launch.sh
Members [4] {
Member [172.30.1.21]:5701
Member [172.30.1.21]:5702 this
Member [172.30.1.188]:5701
Member [172.30.1.188]:5702
}
<properties>
<property name="hazelcast.mancenter.enabled">false</property>
<property name="hazelcast.memcache.enabled">false</property>
<property name="hazelcast.rest.enabled">false</property>
<property name="hazelcast.wait.seconds.before.join">0</property>
<property name="hazelcast.shutdownhook.enabled">false</property>
<property name="hazelcast.socket.connect.timeout.seconds">10</property>
<property name="hazelcast.socket.bind.any">false</property>
</properties>
<network>
<port auto-increment="true" port-count="50">5701</port>
<outbound-ports>
<ports>0</ports>
</outbound-ports>
...
<tcp-ip enabled="true">
<member>172.30.1.188</member>
<member>172.30.1.21</member>
</tcp-ip>
</join>
<tcp-ip enabled="true">
<interface>172.30.2.188:5701</interface>
<interface>172.30.2.21:5701</interface>
</tcp-ip>