Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ run-all/target/
run-windup-on-example-app/download
*.iml
*.~
.idea
46 changes: 46 additions & 0 deletions windup-web-docker-compose/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM jboss/keycloak-adapter-wildfly:3.1.0.Final
ENV CONFIG_FILE standalone-full.xml

# Standalone.xml modifications.
RUN sed -i -e 's/<extensions>/&\n <extension module="org.keycloak.keycloak-adapter-subsystem"\/>/' $JBOSS_HOME/standalone/configuration/$CONFIG_FILE && \
sed -i -e 's/<profile>/&\n <subsystem xmlns="urn:jboss:domain:keycloak:1.1"\/>/' $JBOSS_HOME/standalone/configuration/$CONFIG_FILE && \
sed -i -e 's/<security-domains>/&\n <security-domain name="keycloak">\n <authentication>\n <login-module code="org.keycloak.adapters.jboss.KeycloakLoginModule" flag="required"\/>\n <\/authentication>\n <\/security-domain>/' $JBOSS_HOME/standalone/configuration/$CONFIG_FILE

### END OF keycloak customization part

COPY config/standalone.conf /opt/jboss/wildfly/bin/
COPY startup.sh /opt/jboss/wildfly/customization/startup.sh

## Copy application - ANOTHER LAYER
# Copy the war files
COPY wars/api.war /opt/jboss/wildfly/standalone/deployments/api.war
COPY wars/rhamt-web.war /opt/jboss/wildfly/standalone/deployments/

# TODO:
# Use some similar approach as MySQL example does:
# https://github.com/docker-library/mysql/blob/master/8.0/Dockerfile
#
# Basically set startup.sh script as ENTRYPOINT and do initialization logic inside
# (make sure it is executed just once)
#
# It will also solve problem with need of duplicated env variables and build ARGS
#
# And also simplify docker image and make it more reusable
#

CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "--server-config=standalone-full.xml"]

# CUSTOMIZED SECTION - COULD BE SEPARATE DOCKER FILE ON TOP OF PREVIOUS ONE
ARG DB_HOST
ARG DB_USER
ARG DB_PASSWORD
ARG DB_URI
ARG DATA_DIR
ARG KEYCLOAK_REALM_PUBLIC_KEY
ARG KEYCLOAK_AUTH_URL

ENV POSTGRESQL_DRIVER_VERSION 42.1.1
RUN /opt/jboss/wildfly/customization/startup.sh standalone standalone-full.xml

# Use line below for debugging purposes
# CMD ["sh", "-c", "tail -f /dev/null"]
34 changes: 34 additions & 0 deletions windup-web-docker-compose/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

MAVEN_HOME=/var/lib/jenkins/tools/apache-maven-3.3.9
export PATH=$PATH:$MAVEN_HOME/bin

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BUILD_DATE=`date +%Y%m%d`

cd $DIR

rm -rf windup-web

git clone https://github.com/windup/windup-web.git
if [ $? != 0 ]; then
echo "Git clone (windup-web) failed"
exit 1
fi

cd windup-web
mvn clean install -DskipTests -Dwebpack.environment=production

if [ $? != 0 ]; then
echo "First attempt to build failed, repeating"
mvn install -DskipTests -Dwebpack.environment=production
fi

if [ $? != 0 ]; then
echo "Maven build failed for windup-web"
exit 1
fi

mkdir ../wars
cp services/target/rhamt-web/api.war ../wars
cp ui/target/rhamt-web.war ../wars
528 changes: 528 additions & 0 deletions windup-web-docker-compose/config/standalone-full.xml

Large diffs are not rendered by default.

76 changes: 76 additions & 0 deletions windup-web-docker-compose/config/standalone.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
## -*- shell-script -*- ######################################################
## ##
## JBoss Bootstrap Script Configuration ##
## ##
##############################################################################

#
# This file is optional; it may be removed if not needed.
#

#
# Specify the maximum file descriptor limit, use "max" or "maximum" to use
# the default, as queried by the system.
#
# Defaults to "maximum"
#
#MAX_FD="maximum"

#
# Specify the profiler configuration file to load.
#
# Default is to not load profiler configuration file.
#
#PROFILER=""

#
# Specify the location of the Java home directory. If set then $JAVA will
# be defined to $JAVA_HOME/bin/java, else $JAVA will be "java".
#
#JAVA_HOME="/opt/java/jdk"

#
# Specify the exact Java VM executable to use.
#
#JAVA=""

if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
JBOSS_MODULES_SYSTEM_PKGS="org.jboss.byteman"
fi

# Uncomment the following line to prevent manipulation of JVM options
# by shell scripts.
#
#PRESERVE_JAVA_OPTS=true

#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms64m -Xmx7000m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=512m -Djava.net.preferIPv4Stack=true -XX:ReservedCodeCacheSize=512m"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi

# Sample JPDA settings for remote socket debugging
#JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"

# Sample JPDA settings for shared memory debugging
#JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_shmem,server=y,suspend=n,address=jboss"

# Uncomment to not use JBoss Modules lockless mode
#JAVA_OPTS="$JAVA_OPTS -Djboss.modules.lockless=false"

# Uncomment to gather JBoss Modules metrics
#JAVA_OPTS="$JAVA_OPTS -Djboss.modules.metrics=true"

# Uncomment this to run with a security manager enabled
# SECMGR="true"

# Uncomment this in order to be able to run WildFly on FreeBSD
# when you get "epoll_create function not implemented" message in dmesg output
#JAVA_OPTS="$JAVA_OPTS -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider"

# hibernate
# JAVA_OPTS="$JAVA_OPTS -Dhibernate.dialect=org.hibernate.dialect.PostgreSQLDialect"
50 changes: 50 additions & 0 deletions windup-web-docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: '3'
services:
db:
image: postgres:9.6-alpine
environment:
POSTGRES_USER: windup
POSTGRES_PASSWORD: password12345
adminer:
image: adminer:4.3.1
depends_on:
- db
ports:
- "4040:8080"
keycloak:
image: jboss/keycloak:3.1.0.Final
ports:
- "7070:8080"
environment:
KEYCLOAK_USER: admin
KEYCLOAK_PASSWORD: password
windup-web:
build:
context: .
args:
DB_HOST: db
DB_USER: windup
DB_PASSWORD: password12345
DB_URI: db
DATA_DIR: "/var/windup"
KEYCLOAK_REALM_PUBLIC_KEY: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgmMfkT3fsuqRTnt17kPNGXm98Y//KxL+AeogTT5gS2mQkGWyLusP2WMbshc984Scyu/b7VoL7g/2Pq2Cm2TWi0+ffOryCJOz1NrLBqDqx/aGH9p337ZPWf5DiNxrhfxNxwF1002a+bp+3Lev1S+jZOjBI7emDBLR8iNu/xRbwbeCPiEwf4vM1vTJmgXBzA/efBzjfbTe7cjt8VSEPlOLZD29smmcpq8FayJSbPiqSIC1EfhA204nh3r/VzaBEcVQqsU1s51TT8724W3Z9DdSdFk3KNU/wc4nC8AXkZ6nFVT4RITwL5QsEuA2GIMDYtGaPk2OvxkcC4voCD9NBhUZSwIDAQAB"
KEYCLOAK_AUTH_URL: http://localhost:7070/auth
depends_on:
- db
- keycloak
ports:
- "8180:8080"
- "8787:8787"
- "9090:9090"
volumes:
- ./docker-volume:/var/windup
- ./startup-scripts:/docker-entrypoint-init.d:ro
environment:
DB_HOST: db
DB_USER: windup
DB_PASSWORD: password12345
DB_URI: db
DATA_DIR: "/var/windup"
KEYCLOAK_REALM_PUBLIC_KEY: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgmMfkT3fsuqRTnt17kPNGXm98Y//KxL+AeogTT5gS2mQkGWyLusP2WMbshc984Scyu/b7VoL7g/2Pq2Cm2TWi0+ffOryCJOz1NrLBqDqx/aGH9p337ZPWf5DiNxrhfxNxwF1002a+bp+3Lev1S+jZOjBI7emDBLR8iNu/xRbwbeCPiEwf4vM1vTJmgXBzA/efBzjfbTe7cjt8VSEPlOLZD29smmcpq8FayJSbPiqSIC1EfhA204nh3r/VzaBEcVQqsU1s51TT8724W3Z9DdSdFk3KNU/wc4nC8AXkZ6nFVT4RITwL5QsEuA2GIMDYtGaPk2OvxkcC4voCD9NBhUZSwIDAQAB"
KEYCLOAK_AUTH_URL: http://localhost:7070/auth
#http://keycloak/auth
20 changes: 20 additions & 0 deletions windup-web-docker-compose/startup-scripts/00-init-keycloak.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
echo "=> Validate keycloak configuration"
echo "=> KEYCLOAK_REALM_PUBLIC_KEY: " $KEYCLOAK_REALM_PUBLIC_KEY
echo "=> KEYLOCAK_AUTH_URL: " $KEYLOAK_AUTH_URL

echo "=> Executing the commands"
$JBOSS_CLI -c << EOF
# Mark the commands below to be run as a batch
batch

# Properties
/system-property=keycloak.realm.public.key:add(value="$KEYCLOAK_REALM_PUBLIC_KEY")
/system-property=keycloak.server.url:add(value="$KEYCLOAK_AUTH_URL")

# keycloak
/subsystem=keycloak/secure-deployment=api.war:add(realm=rhamt, realm-public-key="\${keycloak.realm.public.key}", auth-server-url="\${keycloak.server.url}", public-client=true, ssl-required=EXTERNAL, resource=rhamt-web)
/subsystem=keycloak/secure-deployment=rhamt-web.war:add(realm=rhamt, realm-public-key="\${keycloak.realm.public.key}", auth-server-url="\${keycloak.server.url}", public-client=true, ssl-required=EXTERNAL, resource=rhamt-web)
# Execute the batch
run-batch
EOF
27 changes: 27 additions & 0 deletions windup-web-docker-compose/startup-scripts/01-init-datasource.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

echo "=> Downloading driver...."
curl -L https://jdbc.postgresql.org/download/postgresql-$POSTGRESQL_DRIVER_VERSION.jar > /opt/jboss/wildfly/postgresql-connector.jar

echo "=> Validate configuration"
echo "=> DB_URI (docker with networking): " $DB_URI
echo "=> DB_HOST: " $DB_HOST
echo "=> DB_USER: " $DB_USER

CONNECTION_URL=jdbc:postgresql://$DB_URI/windup

echo "=> Executing the commands"
$JBOSS_CLI -c << EOF
# Mark the commands below to be run as a batch
batch

# Add the datasource
# Install postgres
module add --name=org.postgresql --resources=/opt/jboss/wildfly/postgresql-connector.jar --dependencies=javax.api,javax.transaction.api
/subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-class-name=org.postgresql.Driver)

data-source add --name=WindupServicesDS --driver-name=postgresql --jndi-name=java:jboss/datasources/WindupServicesDS --connection-url=$CONNECTION_URL?useUnicode=true&amp;characterEncoding=UTF-8 --user-name=$DB_USER --password="$DB_PASSWORD" --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true

# Execute the batch
run-batch
EOF
27 changes: 27 additions & 0 deletions windup-web-docker-compose/startup-scripts/02-init-logging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

echo "=> Executing the commands"
$JBOSS_CLI -c << EOF
# Mark the commands below to be run as a batch
batch

# Logging
/subsystem=logging/logger=org.jboss.windup:add(level=INFO, use-parent-handlers=false, handlers=[])
/subsystem=logging/logger=org.jboss.windup.web:add(level=INFO, use-parent-handlers=false, handlers=[FILE, CONSOLE])
/subsystem=logging/logger=org.jboss.windup.web.services.WindupWebProgressMonitor:add(level=INFO, use-parent-handlers=false, handlers=[])

## Reduce the Furnace loading warnings.
/subsystem=logging/logger=org.jboss.forge.furnace.container.simple.impl.SimpleServiceRegistry/:add(level=SEVERE)
## Validator complains about "ClassX declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. ..."
/subsystem=logging/logger=org.jboss.weld.Validator/:add(level=ERROR)
## DEBUG Configuring component class: ...
/subsystem=logging/logger=org.jboss.as.ee/:add(level=INFO)
## MSC000004: Failure during stop of service jboss.deployment.unit."api.war".WeldStartService: org.jboss.forge.furnace.exception.ContainerException:
## Could not get services of type [interface org.jboss.windup.web.addons.websupport.WindupWebServiceFactory] from addon [org.jboss.windup.web.addons:windup-web-support,4.0.0-SNAPSHOT +STARTED]
/subsystem=logging/logger=org.jboss.msc.service.fail/:add(level=ERROR)
## HHH000431: Unable to determine H2 database version, certain features may not work
/subsystem=logging/logger=org.hibernate.dialect.H2Dialect/:add(level=ERROR)

# Execute the batch
run-batch
EOF
24 changes: 24 additions & 0 deletions windup-web-docker-compose/startup-scripts/03-other.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

echo "=> DATA_DIR: " $DATA_DIR

echo "=> Executing the commands"
$JBOSS_CLI -c << EOF
# Mark the commands below to be run as a batch
batch

# JMS queues
jms-queue add --queue-address=executorQueue --entries=queues/executorQueue
jms-queue add --queue-address=statusUpdateQueue --entries=queues/statusUpdateQueue
jms-queue add --queue-address=packageDiscoveryQueue --entries=queues/packageDiscoveryQueue
jms-topic add --topic-address=executorCancellation --entries=topics/executorCancellation

# Properties
/system-property=windup.data.dir:add(value="$DATA_DIR")

# Other
/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-post-size, value=943718400)

# Execute the batch
run-batch
EOF
43 changes: 43 additions & 0 deletions windup-web-docker-compose/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
# Usage: execute.sh [WildFly mode] [configuration file]
#
# The default mode is 'standalone' and default configuration is based on the mode.
# It can be 'standalone.xml' or 'standalone-full.xml or 'domain.xml'.

JBOSS_HOME=/opt/jboss/wildfly
JBOSS_CLI=$JBOSS_HOME/bin/jboss-cli.sh
JBOSS_MODE=${1:-"standalone"}
JBOSS_CONFIG=${2:-"$JBOSS_MODE.xml"}

function wait_for_server() {
until `$JBOSS_CLI -c "ls /deployment" &> /dev/null`; do
sleep 1
done
}

echo "=> Starting WildFly server"
$JBOSS_HOME/bin/$JBOSS_MODE.sh -c $JBOSS_CONFIG > /dev/null &

echo "=> Waiting for the server to boot"
wait_for_server



echo "=> Processing startup scripts..."

echo
for f in /docker-entrypoint-init.d/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*) echo "$0: ignoring $f" ;;
esac
echo
done


echo "=> Shutting down WildFly"
if [ "$JBOSS_MODE" = "standalone" ]; then
$JBOSS_CLI -c ":shutdown"
else
$JBOSS_CLI -c "/host=*:shutdown"
fi