Public Repository

Last pushed: 3 days ago
Short Description
Opensource Appliacion Server Wildfly based on Java 1.8.0_151
Full Description

Wildfly Docker container

This container contents the Wildfly community version of Wildfly. The Structure of the Wildfly installation is

Wildfly_HOME=/opt/Wildfly
Wildfly_BASE_DIR=${Wildfly_HOME}/standalone
Wildfly_CONFIG_DIR=${Wildfly_BASE_DIR}/configuration

WORKING_DIR=${Wildfly_BASE_DIR}

The Wildfly Docker image runs on base on Docker image mkoellges/ubuntu_java8:16.04 - means, that the Wildfly is running on top of Java 8_151.

In this Wildfly instances, the following Database drivers are already installed:

  • Oracle RDBMS
  • Postgres
  • MS SQL Server
  • MySQL

To start the Wildfly container you have two different choices.

After the wildfly instance is up and running, you can access the admin URL it using

Username: admin
Password: default is "change_me1", but you can use your own by changing the ENV Parameter "JBOSS_PWD"

To store static files use the directory

/opt/data

Standard start

This way starts the container in a method, that all JVM parameters can be passed on command line call for the docker run.

docker run -d \
       --env JVM_PARAM=" -Xms2048m -Xmx2048m" \
       --env CONFIG_TYPE="standalone" \
       --env JBOSS_PWD="change_me1" \
       --name test-mk-1 \
       -p 9990:9990 \
       -p 8080:8080 \
       Wildfly-eap:6.4.7 \
       start_Wildfly.sh

The environment parameter can include all JVM parameters and options needed.

The CONFIG_TYPE can be all possible standalone profiles like standalone, standalone-ha, standalone-full and standalone-full-ha.

Centralized configuration and classified start

To simplify the configuration of Wildfly instances, you can use the mkoellges/etcd:2.3.1 container to store the Wildfly configuration and classification (stored here in our git repository too).

The values needed to configure your JVMs can be stored in the file jboss-config.yml. Read the description of the mkoellges/etcd:2.3.1 docker container how to load these data.

After the data is loaded and the etcd is running in background, you can simply start your Wildfly containers by using a classification.
This is much more simplyfied and more comprehensive rather to configure the JVM Parameters in JVM_PARAM as mentioned above.

Simply start the the ectd docker container (named here etcd-1). Then start the Wildfly container and loading the config data from there by

docker run -d \
       --link etcd-1 \
       --env ETCD_NODES=etcd-1:4001  \
       -p 9990:9990 \
       -p 8080:8080 \
       --env CONFIG_TYPE="standalone-ha" \
       --env JBOSS_PWD="change_me_1" \
       --name test-mk-1 \
       Wildfly-eap:6.4.7 \
       start_Wildfly.sh \
       medium

You can store different values for each JVM Parameter for the classes small, medium and large to decide at containerstart, what kind of stored config yoiu want to use.

Example for a jboss-config.yml config file:

default:
  java_start_parameter:
    JAVA_ARG001: -Djava.net.preferIPv4Stack=true
    JAVA_ARG002: -Djava.awt.headless=true
    JAVA_ARG003: -Xmx512M
    JAVA_ARG004: -Xmx512M
    JAVA_ARG005: -XX:MaxMetaspaceSize=256m
    JAVA_ARG006: -Xss256k
    JAVA_ARG007: -XX:NewSize=330M
    JAVA_ARG010: -XX:+UseParNewGC
    JAVA_ARG011: -XX:+UseConcMarkSweepGC
    JAVA_ARG012: -XX:+CMSClassUnloadingEnabled
    JAVA_ARG013: -XX:+DisableExplicitGC
    JAVA_ARG014: -XX:+PrintGCDetails
    JAVA_ARG015: -XX:+PrintGCDateStamps
    JAVA_ARG016: -Xloggc:/opt/Wildfly/standalone/log/gc.log
    JAVA_ARG017: -XX:+UseGCLogFileRotation
    JAVA_ARG018: -XX:NumberOfGCLogFiles=10
    JAVA_ARG019: -XX:GCLogFileSize=10M
    JAVA_ARG020: -Duser.timezone=Europe/Berlin
    JAVA_ARG026: -Djava.io.tmpdir=/was/tmp

small:
  java_start_parameter:
    JAVA_ARG003: -Xmx1024m
    JAVA_ARG004: -Xms1024m
    JAVA_ARG005: -XX:MaxMetaspaceSize=256m

medium:
  java_start_parameter:
    JAVA_ARG003: -Xmx2048m
    JAVA_ARG004: -Xms2048m
    JAVA_ARG005: -XX:MaxMetaspaceSize=512m

large:
  java_start_parameter:
    JAVA_ARG003: -Xmx4096m
    JAVA_ARG004: -Xms4096m
    JAVA_ARG005: -XX:MaxMetaspaceSize=1024m

Deployment of an application in a Wildfly container

use the sample Dockerfile and create a new application container, where the application and it's used resources will be deployed. For this, the warfile/earfile and a jboss-cli script (cli-file) must be copied into a working directory on build time.

Example of a jboss-cli file:

batch

/system-property=jboss.tx.node.id:add(value=___HOSTNAME___)
/subsystem=transactions:write-attribute(name=node-identifier,value="${jboss.tx.node.id}")

# -------------------------------------------------------
# Datasource 
# -------------------------------------------------------

# Creation of datasourde
# Sample:
# data-source add --name=DATASOURCENAME --driver-name=DBDRIVER --connection-url=jdbc:oracle:thin:@HOSTNAME:PORT:SID --jndi-name=java:jboss/datasources/DATASOURCENAME --user-name=DB-USERNAME --password=DB-PASSWORD --min-pool-size=MINCONNECTIONS --max-pool-size=MAXCONNECTIONS 

reload

# Enable defined datasources
# must be done for every datasource defined above
# Sample:
# /subsystem=datasources/data-source=DATASOURCENAME:enable()

# Test enabled datasource for correct connection
# must be done for every datasource defined above
# Sample:
# /subsystem=datasources/data-source="MMSOD_DS":test-connection-in-pool


# -------------------------------------------------------
# Resource Adaptor
# -------------------------------------------------------
# Create a resource adapter using the following topics:
# Placeholder             Description
# [CHANNEL_NAME]          name of the MQ channel to set up, e.g. "SYSTEM.DEF.SVRCONN"
# [FACTORY_JNDI_NAME]     JNDI name to use for the MQ connection factory, e.g. "java:jboss/eis/MQCF"
# [FACTORY_NAME]          name of the connection factory, e.g. "WMQConnectionFactoryPool"
# [POOL_MAX_SIZE]          maximum pool size, e.g. "10"
# [POOL_MIN_SIZE]          minimum pool size, e.g. "1"
# [TRANSPORT_TYPE]          e.g. "CLIENT" or "BINDINGS"
# [CONNECTION_LIST]          list of connection end-points, comma-separated, e.g. "h249serv.metro-dus.de(14100),h250serv.metro-dus.de(14100)"
# [MANAGER_HOST]          FQDN or IP address the queue manager is listening on, e.g. "h251serv.metro-dus"
# [MANAGER_PORT]          port number the queue manager is listening on, e.g. 14100
# [MANAGER_NAME]          name of the queue manager, e.g. "MQSD.H251E01"
# [ADAPTER_NAME]          name of the adapter, e.g. "MQ.DEMO.ADAPTER"
# [TRANSACTION_SUPPORT]      transaction support level e.g. "LocalTransaction"
# 
# create a resource adaptor:
#
# /subsystem=resource-adapters/resource-adapter=[ADAPTER_NAME]/:add(archive=wmq.jmsra.rar,transaction-support="[TRANSACTION_SUPPORT]")
# /subsystem=resource-adapters/resource-adapter=[ADAPTER_NAME]/connection-definitions=[FACTORY_NAME]:add(class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl",jndi-name="[FACTORY_JNDI_NAME]",use-ccm=true,enabled=true,use-java-context=true,max-pool-size=[POOL_MAX_SIZE],min-pool-size=[POOL_MIN_SIZE])
# /subsystem=resource-adapters/resource-adapter=[ADAPTER_NAME]/connection-definitions=[FACTORY_NAME]/config-properties=connectionNameList:add(value="[CONNECTION_LIST]")
# /subsystem=resource-adapters/resource-adapter=[ADAPTER_NAME]/connection-definitions=[FACTORY_NAME]/config-properties=channel:add(value="[CHANNEL_NAME]")
# /subsystem=resource-adapters/resource-adapter=[ADAPTER_NAME]/connection-definitions=[FACTORY_NAME]/config-properties=transportType:add(value="[TRANSPORT_TYPE]")
# /subsystem=resource-adapters/resource-adapter=[ADAPTER_NAME]/connection-definitions=[FACTORY_NAME]/config-properties=queueManager:add(value="[MANAGER_NAME]")
#
# do this for every resource adaptor 

# -------------------------------------------------------
# Deploy application
# -------------------------------------------------------

# Deploy of an appliction archive (earfile or warfile)
# Sample:
# deploy /tmp/APPLICATION.ear

run-batch

Example Dockerfile:

FROM mkoellges/wildfly:10.1

MAINTAINER manfred.koellges@metrosystems.net

ARG earfile=sample.war
ARG clifile=application.cli

ADD $earfile /tmp
ADD $clifile /tmp

RUN standalone.sh -c standalone-ha.xml -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0 & \
    sleep 5 && \
    sed -i s/___HOSTNAME___/$HOSTNAME/ /tmp/$clifile && \
    sed -i s/___EARFILE___/$earfile/ /tmp/$clifile && \
    /opt/jboss/bin/jboss-cli.sh --connect --file=/tmp/$clifile && \
    echo "Shutting down JBoss Instance........." && \
    /opt/jboss/bin/jboss-cli.sh --connect ":shutdown" && \
    echo "Deleting current subdirectory ..... " && \
    rm -rf /opt/jboss/standalone/configuration/standalone_xml_history/current

Now build the application docker image like

docker build -t sampleapp --build-arg earfile=APPLICATION_ARCHIVE.ear --build-arg clifile=application.cli .
Docker Pull Command
Owner
mkoellges