commit 774bf8cfccb1fd6b444e02b71614eebf595401cf Author: richard Date: Thu Nov 30 23:02:22 2017 +0800 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..89bcebf --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/apptest/target/ +.DS_Store diff --git a/README.md b/README.md new file mode 100755 index 0000000..6b398a3 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# wildfly-cluster-docker +Example on how to setup a Wildfly cluster using Docker diff --git a/apptest/nb-configuration.xml b/apptest/nb-configuration.xml new file mode 100755 index 0000000..7577ef7 --- /dev/null +++ b/apptest/nb-configuration.xml @@ -0,0 +1,19 @@ + + + + + + 1.7-web + WildFly + + diff --git a/apptest/pom.xml b/apptest/pom.xml new file mode 100755 index 0000000..e0220e9 --- /dev/null +++ b/apptest/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + + com.eldermoraes + apptest + 1.0 + war + + apptest + + + ${project.build.directory}/endorsed + UTF-8 + + + + + javax + javaee-web-api + 7.0 + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + ${endorsed.dir} + + + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + false + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.6 + + + validate + + copy + + + ${endorsed.dir} + true + + + javax + javaee-endorsed-api + 7.0 + jar + + + + + + + + + + diff --git a/apptest/src/main/webapp/WEB-INF/web.xml b/apptest/src/main/webapp/WEB-INF/web.xml new file mode 100755 index 0000000..c6cf467 --- /dev/null +++ b/apptest/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,12 @@ + + + + apptest + + index.jsp + + + diff --git a/apptest/src/main/webapp/index.jsp b/apptest/src/main/webapp/index.jsp new file mode 100755 index 0000000..9b21004 --- /dev/null +++ b/apptest/src/main/webapp/index.jsp @@ -0,0 +1,23 @@ +<%-- + Document : index + Created on : Jan 5, 2017, 10:48:32 PM + Author : eldermoraes +--%> + +<%@ page import="java.net.InetAddress"%> +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + +Cluster Test + + +
+

The request is being answered by:

+

IP: <%=InetAddress.getLocalHost().getHostAddress()%>

+

HostName: <%=InetAddress.getLocalHost().getCanonicalHostName() %>

+

Session ID: <%=request.getSession().getId() %>

+
+ + diff --git a/wild-docker-files/Dockerfile b/wild-docker-files/Dockerfile new file mode 100755 index 0000000..4998f6a --- /dev/null +++ b/wild-docker-files/Dockerfile @@ -0,0 +1,17 @@ +FROM jboss/wildfly + +# Environment variable with default value +ARG APP_FILE=appfile.war + +RUN echo ${APP_FILE} + +# Add your application to the deployment folder +ADD ${APP_FILE} /opt/jboss/wildfly/standalone/deployments/${APP_FILE} + +# Add standalone-ha.xml - set your own network settings +ADD standalone-ha-1.xml /opt/jboss/wildfly/standalone/configuration/standalone-ha-1.xml +ADD standalone-ha-2.xml /opt/jboss/wildfly/standalone/configuration/standalone-ha-2.xml +ADD standalone-ha-3.xml /opt/jboss/wildfly/standalone/configuration/standalone-ha-3.xml + +# Add user for adminstration purpose +RUN /opt/jboss/wildfly/bin/add-user.sh admin admin123 --silent diff --git a/wild-docker-files/apptest.war b/wild-docker-files/apptest.war new file mode 100755 index 0000000..f95f863 Binary files /dev/null and b/wild-docker-files/apptest.war differ diff --git a/wild-docker-files/build.sh b/wild-docker-files/build.sh new file mode 100755 index 0000000..917213e --- /dev/null +++ b/wild-docker-files/build.sh @@ -0,0 +1 @@ +docker build -t wildfly-cluster --build-arg APP_FILE=apptest.war . diff --git a/wild-docker-files/env.list b/wild-docker-files/env.list new file mode 100755 index 0000000..690f28a --- /dev/null +++ b/wild-docker-files/env.list @@ -0,0 +1,10 @@ +# automatically created environment variables (docker links) +TOMCAT_1_PORT_8080_TCP_ADDR=wild1 +TOMCAT_2_PORT_8080_TCP_ADDR=wild2 +TOMCAT_3_PORT_8080_TCP_ADDR=wild3 + +# special environment variables +TOMCAT_PATH=/apptest +TOMCAT_REMOTE_PORT=8080 +TOMCAT_REMOTE_PATH=/apptest +TOMCAT_HOSTNAME=wild-balancer diff --git a/wild-docker-files/network-create.sh b/wild-docker-files/network-create.sh new file mode 100755 index 0000000..10e7d97 --- /dev/null +++ b/wild-docker-files/network-create.sh @@ -0,0 +1,6 @@ +docker network create \ + --driver=bridge \ + --subnet=172.28.0.0/16 \ + --ip-range=172.28.5.0/24 \ + --gateway=172.28.5.254 \ + wildnetwork diff --git a/wild-docker-files/remove.sh b/wild-docker-files/remove.sh new file mode 100755 index 0000000..ca1350d --- /dev/null +++ b/wild-docker-files/remove.sh @@ -0,0 +1,4 @@ +docker rm -f wild1 +docker rm -f wild2 +docker rm -f wild3 +docker rm -f wild-balancer diff --git a/wild-docker-files/run.sh b/wild-docker-files/run.sh new file mode 100755 index 0000000..d393634 --- /dev/null +++ b/wild-docker-files/run.sh @@ -0,0 +1,5 @@ +docker run -d --name wild1 -h wild1 -p 8080:8080 -p 9990:9990 --network=wildnetwork --ip 172.28.5.1 wildfly-cluster /opt/jboss/wildfly/bin/standalone.sh -c standalone-ha-1.xml -u 230.0.0.4 +docker run -d --name wild2 -h wild2 -p 8081:8080 -p 9991:9990 --network=wildnetwork --ip 172.28.5.2 wildfly-cluster /opt/jboss/wildfly/bin/standalone.sh -c standalone-ha-2.xml -u 230.0.0.4 +docker run -d --name wild3 -h wild3 -p 8082:8080 -p 9992:9990 --network=wildnetwork --ip 172.28.5.3 wildfly-cluster /opt/jboss/wildfly/bin/standalone.sh -c standalone-ha-3.xml -u 230.0.0.4 + +docker run -d --name wild-balancer -p 80:80 --link wild1:wild1 --link wild2:wild2 --link wild3:wild3 --env-file ./env.list --network=wildnetwork --ip 172.28.5.4 jasonwyatt/nginx-loadbalancer diff --git a/wild-docker-files/standalone-ha-1.xml b/wild-docker-files/standalone-ha-1.xml new file mode 100755 index 0000000..2416ad5 --- /dev/null +++ b/wild-docker-files/standalone-ha-1.xml @@ -0,0 +1,468 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + h2 + + sa + sa + + + + + org.h2.jdbcx.JdbcDataSource + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${jboss.bind.address:127.0.0.1} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wild-docker-files/standalone-ha-2.xml b/wild-docker-files/standalone-ha-2.xml new file mode 100755 index 0000000..8d73c9b --- /dev/null +++ b/wild-docker-files/standalone-ha-2.xml @@ -0,0 +1,468 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + h2 + + sa + sa + + + + + org.h2.jdbcx.JdbcDataSource + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${jboss.bind.address:127.0.0.1} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wild-docker-files/standalone-ha-3.xml b/wild-docker-files/standalone-ha-3.xml new file mode 100755 index 0000000..31be5d0 --- /dev/null +++ b/wild-docker-files/standalone-ha-3.xml @@ -0,0 +1,468 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + h2 + + sa + sa + + + + + org.h2.jdbcx.JdbcDataSource + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${jboss.bind.address:127.0.0.1} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +