From fd9d633e9cbfea7bb5e5aeb59a9a02c33c022ef6 Mon Sep 17 00:00:00 2001 From: David Klingenberg Date: Thu, 15 Jun 2017 15:44:33 +0200 Subject: [PATCH 1/6] Windup web dockerization --- windup-web-docker-compose/Dockerfile | 17 + windup-web-docker-compose/build.sh | 73 +++ .../config/standalone-full.xml | 528 ++++++++++++++++++ .../config/standalone.conf | 73 +++ .../customization/commands.cli | 42 ++ .../customization/execute.sh | 33 ++ windup-web-docker-compose/docker-compose.yml | 23 + 7 files changed, 789 insertions(+) create mode 100644 windup-web-docker-compose/Dockerfile create mode 100755 windup-web-docker-compose/build.sh create mode 100644 windup-web-docker-compose/config/standalone-full.xml create mode 100644 windup-web-docker-compose/config/standalone.conf create mode 100644 windup-web-docker-compose/customization/commands.cli create mode 100755 windup-web-docker-compose/customization/execute.sh create mode 100644 windup-web-docker-compose/docker-compose.yml diff --git a/windup-web-docker-compose/Dockerfile b/windup-web-docker-compose/Dockerfile new file mode 100644 index 0000000..7118ee9 --- /dev/null +++ b/windup-web-docker-compose/Dockerfile @@ -0,0 +1,17 @@ +# FROM jboss/wildfly:10.1.0.Final +FROM jboss/keycloak-adapter-wildfly:3.1.0.Final + +ADD customization /opt/jboss/wildfly/customization/ + +COPY config/standalone.conf /opt/jboss/wildfly/bin/ +# COPY config/standalone-full.xml /opt/jboss/wildfly/standalone/configuration/ +# COPY config/keycloak.h2.db /opt/jboss/wildfly/standalone/data/ + +RUN /opt/jboss/wildfly/customization/execute.sh + +# Copy the apps +COPY wars/api.war /opt/jboss/wildfly/standalone/deployments/api.war +# COPY wars/api.war.dodeploy /opt/jboss/wildfly/standalone/deployments/ +COPY wars/rhamt-web.war /opt/jboss/wildfly/standalone/deployments/ + +CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "--server-config=standalone-full.xml"] diff --git a/windup-web-docker-compose/build.sh b/windup-web-docker-compose/build.sh new file mode 100755 index 0000000..040e14b --- /dev/null +++ b/windup-web-docker-compose/build.sh @@ -0,0 +1,73 @@ +#!/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 +rm -rf windup-keycloak-tool +rm -rf windup-web-distribution + +git clone https://github.com/windup/windup-web.git +if [ $? != 0 ]; then + echo "Git clone (windup-web) failed" + exit 1 +fi + +git clone https://github.com/windup/windup-keycloak-tool.git +if [ $? != 0 ]; then + echo "Git clone (windup-web-keycloak-tool) failed" + exit 1 +fi + + +git clone https://github.com/windup/windup-web-distribution.git +if [ $? != 0 ]; then + echo "Git clone (windup-web-distribution) failed" + exit 1 +fi + +cd windup-web +mvn clean install -DskipTests -Dwebpack.environment=production +if [ $? != 0 ]; then + echo "Maven build failed for windup-web" + exit 1 +fi +cd .. + + +cd windup-keycloak-tool +mvn clean install +if [ $? != 0 ]; then + echo "Maven build failed for windup-web-keycloak-tool" + exit 1 +fi +cd .. + + +cd windup-web-distribution +mvn clean install +if [ $? != 0 ]; then + echo "Maven build failed for windup-web-distribution" + exit 1 +fi + +unzip -d target/ target/rhamt-web-distribution-*.zip +if [ $? != 0 ]; then + echo "Distribution unzip failed" + exit 1 +fi + +rm target/rhamt-web-distribution-*.zip +mv target/rhamt-web-distribution-* target/rhamt-web-distribution +if [ $? != 0 ]; then + echo "RHAMT copy failed" + exit 1 +fi + + +cd target/rhamt-web-distribution diff --git a/windup-web-docker-compose/config/standalone-full.xml b/windup-web-docker-compose/config/standalone-full.xml new file mode 100644 index 0000000..c913b1c --- /dev/null +++ b/windup-web-docker-compose/config/standalone-full.xml @@ -0,0 +1,528 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + h2 + + sa + sa + + + + jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE + h2 + + sa + sa + + + + jdbc:h2:${jboss.server.data.dir}/h2/windup-web + h2 + + 30 + + + sa + sa + + + + + org.h2.jdbcx.JdbcDataSource + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${jboss.bind.address:127.0.0.1} + + + + + + + + + + + auth + + + + rhamt + ${keycloak.realm.public.key} + ${keycloak.server.url} + true + EXTERNAL + rhamt-web + + + rhamt + ${keycloak.realm.public.key} + ${keycloak.server.url} + true + EXTERNAL + rhamt-web + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/windup-web-docker-compose/config/standalone.conf b/windup-web-docker-compose/config/standalone.conf new file mode 100644 index 0000000..664af98 --- /dev/null +++ b/windup-web-docker-compose/config/standalone.conf @@ -0,0 +1,73 @@ +## -*- 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" diff --git a/windup-web-docker-compose/customization/commands.cli b/windup-web-docker-compose/customization/commands.cli new file mode 100644 index 0000000..6bb3123 --- /dev/null +++ b/windup-web-docker-compose/customization/commands.cli @@ -0,0 +1,42 @@ +# Mark the commands below to be run as a batch +batch + +# Add the datasource +data-source add --name=WindupServicesDS --driver-name=postgresql --jndi-name=java:jboss/datasources/WindupServicesDS --connection-url=jdbc:$DB_URI/windup?useUnicode=true&characterEncoding=UTF-8 --user-name=$DB_USER --password=$DB_PASSWORD--use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true + +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 + +# keycloak +/subsystem=keycloak/secure-deployment=new:add(realm=rhamt, realm-public-key=KEYCLOAK_REALM_PUBLIC_KEY, auth-server-url=KEYCLOAK_AUTH_URL, public-client=true, ssl-required=EXTERNAL, resource=rhamt-web) +/subsystem=keycloak/secure-deployment=new:add(realm=rhamt, realm-public-key=KEYCLOAK_REALM_PUBLIC_KEY, auth-server-url=KEYCLOAK_AUTH_URL, public-client=true, ssl-required=EXTERNAL, resource=rhamt-web) + +# other +# Properties +/system-property=windup.data.dir:add(value="DATA_DIR/windup-web") + +# 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) + +# Other +/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-post-size, value=943718400) + + +# Execute the batch +run-batch diff --git a/windup-web-docker-compose/customization/execute.sh b/windup-web-docker-compose/customization/execute.sh new file mode 100755 index 0000000..4b0ed63 --- /dev/null +++ b/windup-web-docker-compose/customization/execute.sh @@ -0,0 +1,33 @@ +#!/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 'domain.xml'. + +JBOSS_HOME=/opt/jboss/wildfly +JBOSS_CLI=$JBOSS_HOME/bin/jboss-cli.sh +JBOSS_MODE=${1:-"standalone"} +JBOSS_CONFIG=${2:-"$JBOSS_MODE-full.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 "=> Executing the commands" +$JBOSS_CLI -c --file=`dirname "$0"`/commands.cli + +echo "=> Shutting down WildFly" +if [ "$JBOSS_MODE" = "standalone" ]; then + $JBOSS_CLI -c ":shutdown" +else + $JBOSS_CLI -c "/host=*:shutdown" +fi diff --git a/windup-web-docker-compose/docker-compose.yml b/windup-web-docker-compose/docker-compose.yml new file mode 100644 index 0000000..e279b43 --- /dev/null +++ b/windup-web-docker-compose/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3' +services: + db: + image: postgres:9.6-alpine + environment: + POSTGRES_USER: windup + POSTGRES_PASSWORD: password12345 + + windup-web: + build: . + depends_on: + - db + ports: + - "8080:8080" + - "9090:9090" + environment: + DB_HOST: db + DB_USER: windup + DB_PASSWORD: password12345 + DB_URI: db:5433 + DATA_DIR: "/data/windup" + KEYCLOAK_REALM_PUBLIC_KEY: "" + KEYCLOAK_AUTH_URL: "" From d066d2dcf3d2e8d2b02328305aabd9d4181893fb Mon Sep 17 00:00:00 2001 From: David Klingenberg Date: Fri, 16 Jun 2017 15:20:17 +0200 Subject: [PATCH 2/6] Docker configuration --- windup-web-docker-compose/Dockerfile | 30 ++++++++- .../config/standalone.conf | 3 + .../customization/commands.cli | 16 +++-- .../customization/execute.sh | 62 ++++++++++++++++++- windup-web-docker-compose/docker-compose.yml | 38 ++++++++++-- 5 files changed, 135 insertions(+), 14 deletions(-) diff --git a/windup-web-docker-compose/Dockerfile b/windup-web-docker-compose/Dockerfile index 7118ee9..83c4e9a 100644 --- a/windup-web-docker-compose/Dockerfile +++ b/windup-web-docker-compose/Dockerfile @@ -1,5 +1,26 @@ -# FROM jboss/wildfly:10.1.0.Final -FROM jboss/keycloak-adapter-wildfly:3.1.0.Final +FROM jboss/wildfly:10.1.0.Final +# FROM jboss/keycloak-adapter-wildfly:3.1.0.Final + +ENV KEYCLOAK_VERSION 3.1.0.Final + +ARG DB_HOST +ARG DB_USER +ARG DB_PASSWORD +ARG DB_URI +ARG DATA_DIR +ARG KEYCLOAK_REALM_PUBLIC_KEY +ARG KEYCLOAK_AUTH_URL + +WORKDIR /opt/jboss/wildfly + +RUN curl -L https://downloads.jboss.org/keycloak/$KEYCLOAK_VERSION/adapters/keycloak-oidc/keycloak-wildfly-adapter-dist-$KEYCLOAK_VERSION.tar.gz | tar zx + +WORKDIR /opt/jboss + +# Standalone.xml modifications. +RUN sed -i -e 's//&\n /' $JBOSS_HOME/standalone/configuration/standalone-full.xml && \ + sed -i -e 's//&\n /' $JBOSS_HOME/standalone/configuration/standalone-full.xml && \ + sed -i -e 's//&\n \n \n \n <\/authentication>\n <\/security-domain>/' $JBOSS_HOME/standalone/configuration/standalone-full.xml ADD customization /opt/jboss/wildfly/customization/ @@ -7,6 +28,8 @@ COPY config/standalone.conf /opt/jboss/wildfly/bin/ # COPY config/standalone-full.xml /opt/jboss/wildfly/standalone/configuration/ # COPY config/keycloak.h2.db /opt/jboss/wildfly/standalone/data/ +RUN curl -L https://jdbc.postgresql.org/download/postgresql-42.1.1.jar > /opt/jboss/wildfly/postgresql-connector.jar + RUN /opt/jboss/wildfly/customization/execute.sh # Copy the apps @@ -14,4 +37,5 @@ COPY wars/api.war /opt/jboss/wildfly/standalone/deployments/api.war # COPY wars/api.war.dodeploy /opt/jboss/wildfly/standalone/deployments/ COPY wars/rhamt-web.war /opt/jboss/wildfly/standalone/deployments/ -CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "--server-config=standalone-full.xml"] +# CMD ["sh", "-c", "tail -f /dev/null"] +CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "--server-config=standalone-full.xml", "--debug"] diff --git a/windup-web-docker-compose/config/standalone.conf b/windup-web-docker-compose/config/standalone.conf index 664af98..d047772 100644 --- a/windup-web-docker-compose/config/standalone.conf +++ b/windup-web-docker-compose/config/standalone.conf @@ -71,3 +71,6 @@ fi # 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" diff --git a/windup-web-docker-compose/customization/commands.cli b/windup-web-docker-compose/customization/commands.cli index 6bb3123..38a6d01 100644 --- a/windup-web-docker-compose/customization/commands.cli +++ b/windup-web-docker-compose/customization/commands.cli @@ -1,8 +1,13 @@ +## TODO: Find out how to pass env. variables here and remove this duplicated file from execute.sh # Mark the commands below to be run as a batch batch # Add the datasource -data-source add --name=WindupServicesDS --driver-name=postgresql --jndi-name=java:jboss/datasources/WindupServicesDS --connection-url=jdbc:$DB_URI/windup?useUnicode=true&characterEncoding=UTF-8 --user-name=$DB_USER --password=$DB_PASSWORD--use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true +# 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&characterEncoding=UTF-8 --user-name=$DB_USER --password="$DB_PASSWORD" --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true jms-queue add --queue-address=executorQueue --entries=queues/executorQueue jms-queue add --queue-address=statusUpdateQueue --entries=queues/statusUpdateQueue @@ -10,12 +15,15 @@ jms-queue add --queue-address=packageDiscoveryQueue --entries=queues/packageDisc jms-topic add --topic-address=executorCancellation --entries=topics/executorCancellation # keycloak -/subsystem=keycloak/secure-deployment=new:add(realm=rhamt, realm-public-key=KEYCLOAK_REALM_PUBLIC_KEY, auth-server-url=KEYCLOAK_AUTH_URL, public-client=true, ssl-required=EXTERNAL, resource=rhamt-web) -/subsystem=keycloak/secure-deployment=new:add(realm=rhamt, realm-public-key=KEYCLOAK_REALM_PUBLIC_KEY, auth-server-url=KEYCLOAK_AUTH_URL, public-client=true, ssl-required=EXTERNAL, resource=rhamt-web) +/subsystem=keycloak/secure-deployment=api.war:add(realm=rhamt, auth-server-url=$KEYCLOAK_AUTH_URL, public-client=true, ssl-required=EXTERNAL, resource=rhamt-web) +/subsystem=keycloak/secure-deployment=rhamt-web.war:add(realm=rhamt, auth-server-url=$KEYCLOAK_AUTH_URL, public-client=true, ssl-required=EXTERNAL, resource=rhamt-web) # other # Properties -/system-property=windup.data.dir:add(value="DATA_DIR/windup-web") +/system-property=windup.data.dir:add(value="$DATA_DIR/windup-web") +/system-property=keycloak.realm.public.key:add(value="$KEYCLOAK_REALM_PUBLIC_KEY") +/system-property=keycloak.server.url:add(value="$KEYCLOAK_AUTH_URL") + # Logging /subsystem=logging/logger=org.jboss.windup:add(level=INFO, use-parent-handlers=false, handlers=[]) diff --git a/windup-web-docker-compose/customization/execute.sh b/windup-web-docker-compose/customization/execute.sh index 4b0ed63..43dbfa5 100755 --- a/windup-web-docker-compose/customization/execute.sh +++ b/windup-web-docker-compose/customization/execute.sh @@ -22,8 +22,68 @@ $JBOSS_HOME/bin/$JBOSS_MODE.sh -c $JBOSS_CONFIG > /dev/null & echo "=> Waiting for the server to boot" wait_for_server +echo "=> Validate configuration" +echo "=> DB_URI (docker with networking): " $DB_URI +echo "=> DB_HOST: " $DB_HOST +echo "=> DB_USER: " $DB_USER +echo "=> DATA_DIR: " $DATA_DIR +echo "=> KEYCLOAK_REALM_PUBLIC_KEY: " $KEYCLOAK_REALM_PUBLIC_KEY +echo "=> KEYLOCAK_AUTH_URL: " $KEYLOAK_AUTH_URL + +CONNECTION_URL=jdbc:postgresql://$DB_URI/windup + echo "=> Executing the commands" -$JBOSS_CLI -c --file=`dirname "$0"`/commands.cli +$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&characterEncoding=UTF-8 --user-name=$DB_USER --password="$DB_PASSWORD" --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true + +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 + +# keycloak +/subsystem=keycloak/secure-deployment=api.war:add(realm=rhamt, auth-server-url=$KEYCLOAK_AUTH_URL, public-client=true, ssl-required=EXTERNAL, resource=rhamt-web) +/subsystem=keycloak/secure-deployment=rhamt-web.war:add(realm=rhamt, auth-server-url=$KEYCLOAK_AUTH_URL, public-client=true, ssl-required=EXTERNAL, resource=rhamt-web) + +# other +# Properties +/system-property=windup.data.dir:add(value="$DATA_DIR/windup-web") +/system-property=keycloak.realm.public.key:add(value="$KEYCLOAK_REALM_PUBLIC_KEY") +/system-property=keycloak.server.url:add(value="$KEYCLOAK_AUTH_URL") + + +# 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) + +# Other +/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-post-size, value=943718400) + + +# Execute the batch +run-batch +EOF echo "=> Shutting down WildFly" if [ "$JBOSS_MODE" = "standalone" ]; then diff --git a/windup-web-docker-compose/docker-compose.yml b/windup-web-docker-compose/docker-compose.yml index e279b43..de1c761 100644 --- a/windup-web-docker-compose/docker-compose.yml +++ b/windup-web-docker-compose/docker-compose.yml @@ -5,19 +5,45 @@ services: 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: . + build: + context: . + args: + DB_HOST: db + DB_USER: windup + DB_PASSWORD: password12345 + DB_URI: db + DATA_DIR: "/var/windup" + KEYCLOAK_REALM_PUBLIC_KEY: "" + KEYCLOAK_AUTH_URL: http://localhost:7070/auth depends_on: - db + - keycloak ports: - - "8080:8080" + - "8180:8080" + - "8787:8787" - "9090:9090" + volumes: + - ./docker-volume:/var/windup environment: DB_HOST: db DB_USER: windup DB_PASSWORD: password12345 - DB_URI: db:5433 - DATA_DIR: "/data/windup" + DB_URI: db + DATA_DIR: "/var/windup" KEYCLOAK_REALM_PUBLIC_KEY: "" - KEYCLOAK_AUTH_URL: "" + KEYCLOAK_AUTH_URL: http://localhost:7070/auth + #http://keycloak/auth From 41221a4659fefe748fa19d0749992fea0a7244b8 Mon Sep 17 00:00:00 2001 From: David Klingenberg Date: Fri, 16 Jun 2017 17:36:56 +0200 Subject: [PATCH 3/6] Docker configuration --- .gitignore | 1 + windup-web-docker-compose/customization/execute.sh | 9 ++++----- windup-web-docker-compose/docker-compose.yml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 8f51d71..2cd4ff4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ run-all/target/ run-windup-on-example-app/download *.iml *.~ +.idea diff --git a/windup-web-docker-compose/customization/execute.sh b/windup-web-docker-compose/customization/execute.sh index 43dbfa5..26cde13 100755 --- a/windup-web-docker-compose/customization/execute.sh +++ b/windup-web-docker-compose/customization/execute.sh @@ -49,16 +49,15 @@ jms-queue add --queue-address=statusUpdateQueue --entries=queues/statusUpdateQue jms-queue add --queue-address=packageDiscoveryQueue --entries=queues/packageDiscoveryQueue jms-topic add --topic-address=executorCancellation --entries=topics/executorCancellation -# keycloak -/subsystem=keycloak/secure-deployment=api.war:add(realm=rhamt, auth-server-url=$KEYCLOAK_AUTH_URL, public-client=true, ssl-required=EXTERNAL, resource=rhamt-web) -/subsystem=keycloak/secure-deployment=rhamt-web.war:add(realm=rhamt, auth-server-url=$KEYCLOAK_AUTH_URL, public-client=true, ssl-required=EXTERNAL, resource=rhamt-web) - # other # Properties -/system-property=windup.data.dir:add(value="$DATA_DIR/windup-web") +/system-property=windup.data.dir:add(value="$DATA_DIR") /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) # Logging /subsystem=logging/logger=org.jboss.windup:add(level=INFO, use-parent-handlers=false, handlers=[]) diff --git a/windup-web-docker-compose/docker-compose.yml b/windup-web-docker-compose/docker-compose.yml index de1c761..b42e812 100644 --- a/windup-web-docker-compose/docker-compose.yml +++ b/windup-web-docker-compose/docker-compose.yml @@ -27,7 +27,7 @@ services: DB_PASSWORD: password12345 DB_URI: db DATA_DIR: "/var/windup" - KEYCLOAK_REALM_PUBLIC_KEY: "" + 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 @@ -44,6 +44,6 @@ services: DB_PASSWORD: password12345 DB_URI: db DATA_DIR: "/var/windup" - KEYCLOAK_REALM_PUBLIC_KEY: "" + 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 From ee452d110c37128fb6a36304ad8920964d769c49 Mon Sep 17 00:00:00 2001 From: David Klingenberg Date: Fri, 16 Jun 2017 18:15:17 +0200 Subject: [PATCH 4/6] More complete docker config --- windup-web-docker-compose/Dockerfile | 38 +++++++-------- windup-web-docker-compose/build.sh | 48 +------------------ .../customization/execute.sh | 2 +- windup-web-docker-compose/docker-compose.yml | 1 + .../startup-scripts/00-init-keycloak.sh | 21 ++++++++ .../startup-scripts/01-init-datasource.sh | 27 +++++++++++ .../startup-scripts/02-init-logging.sh | 27 +++++++++++ .../startup-scripts/03-other.sh | 24 ++++++++++ windup-web-docker-compose/startup.sh | 43 +++++++++++++++++ 9 files changed, 165 insertions(+), 66 deletions(-) create mode 100644 windup-web-docker-compose/startup-scripts/00-init-keycloak.sh create mode 100644 windup-web-docker-compose/startup-scripts/01-init-datasource.sh create mode 100644 windup-web-docker-compose/startup-scripts/02-init-logging.sh create mode 100644 windup-web-docker-compose/startup-scripts/03-other.sh create mode 100644 windup-web-docker-compose/startup.sh diff --git a/windup-web-docker-compose/Dockerfile b/windup-web-docker-compose/Dockerfile index 83c4e9a..096eab2 100644 --- a/windup-web-docker-compose/Dockerfile +++ b/windup-web-docker-compose/Dockerfile @@ -2,14 +2,7 @@ FROM jboss/wildfly:10.1.0.Final # FROM jboss/keycloak-adapter-wildfly:3.1.0.Final ENV KEYCLOAK_VERSION 3.1.0.Final - -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 CONFIG_FILE standalone-full.xml WORKDIR /opt/jboss/wildfly @@ -18,24 +11,31 @@ RUN curl -L https://downloads.jboss.org/keycloak/$KEYCLOAK_VERSION/adapters/keyc WORKDIR /opt/jboss # Standalone.xml modifications. -RUN sed -i -e 's//&\n /' $JBOSS_HOME/standalone/configuration/standalone-full.xml && \ - sed -i -e 's//&\n /' $JBOSS_HOME/standalone/configuration/standalone-full.xml && \ - sed -i -e 's//&\n \n \n \n <\/authentication>\n <\/security-domain>/' $JBOSS_HOME/standalone/configuration/standalone-full.xml +RUN sed -i -e 's//&\n /' $JBOSS_HOME/standalone/configuration/$CONFIG_FILE && \ + sed -i -e 's//&\n /' $JBOSS_HOME/standalone/configuration/$CONFIG_FILE && \ + sed -i -e 's//&\n \n \n \n <\/authentication>\n <\/security-domain>/' $JBOSS_HOME/standalone/configuration/$CONFIG_FILE -ADD customization /opt/jboss/wildfly/customization/ +### END OF keycloak customization part -COPY config/standalone.conf /opt/jboss/wildfly/bin/ -# COPY config/standalone-full.xml /opt/jboss/wildfly/standalone/configuration/ -# COPY config/keycloak.h2.db /opt/jboss/wildfly/standalone/data/ +ARG DB_HOST +ARG DB_USER +ARG DB_PASSWORD +ARG DB_URI +ARG DATA_DIR +ARG KEYCLOAK_REALM_PUBLIC_KEY +ARG KEYCLOAK_AUTH_URL -RUN curl -L https://jdbc.postgresql.org/download/postgresql-42.1.1.jar > /opt/jboss/wildfly/postgresql-connector.jar +ADD customization /opt/jboss/wildfly/customization/ +COPY config/standalone.conf /opt/jboss/wildfly/bin/ +ADD build.sh /opt/jboss/wildfly/customization/build.sh -RUN /opt/jboss/wildfly/customization/execute.sh +ENV POSTGRESQL_DRIVER_VERSION 42.1.1 +RUN /opt/jboss/wildfly/customization/startup.sh standalone standalone-full.xml # Copy the apps COPY wars/api.war /opt/jboss/wildfly/standalone/deployments/api.war -# COPY wars/api.war.dodeploy /opt/jboss/wildfly/standalone/deployments/ COPY wars/rhamt-web.war /opt/jboss/wildfly/standalone/deployments/ +# Use line below for debugging purposes # CMD ["sh", "-c", "tail -f /dev/null"] -CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "--server-config=standalone-full.xml", "--debug"] +CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "--server-config=standalone-full.xml"] diff --git a/windup-web-docker-compose/build.sh b/windup-web-docker-compose/build.sh index 040e14b..0bc8059 100755 --- a/windup-web-docker-compose/build.sh +++ b/windup-web-docker-compose/build.sh @@ -18,56 +18,12 @@ if [ $? != 0 ]; then exit 1 fi -git clone https://github.com/windup/windup-keycloak-tool.git -if [ $? != 0 ]; then - echo "Git clone (windup-web-keycloak-tool) failed" - exit 1 -fi - - -git clone https://github.com/windup/windup-web-distribution.git -if [ $? != 0 ]; then - echo "Git clone (windup-web-distribution) failed" - exit 1 -fi - cd windup-web mvn clean install -DskipTests -Dwebpack.environment=production if [ $? != 0 ]; then echo "Maven build failed for windup-web" exit 1 fi -cd .. - - -cd windup-keycloak-tool -mvn clean install -if [ $? != 0 ]; then - echo "Maven build failed for windup-web-keycloak-tool" - exit 1 -fi -cd .. - - -cd windup-web-distribution -mvn clean install -if [ $? != 0 ]; then - echo "Maven build failed for windup-web-distribution" - exit 1 -fi - -unzip -d target/ target/rhamt-web-distribution-*.zip -if [ $? != 0 ]; then - echo "Distribution unzip failed" - exit 1 -fi - -rm target/rhamt-web-distribution-*.zip -mv target/rhamt-web-distribution-* target/rhamt-web-distribution -if [ $? != 0 ]; then - echo "RHAMT copy failed" - exit 1 -fi - -cd target/rhamt-web-distribution +cp services/target/rhamt-web/api.war ../wars/ +cp ui/target/rhamt-web.war ../wars/ diff --git a/windup-web-docker-compose/customization/execute.sh b/windup-web-docker-compose/customization/execute.sh index 26cde13..102b61b 100755 --- a/windup-web-docker-compose/customization/execute.sh +++ b/windup-web-docker-compose/customization/execute.sh @@ -8,7 +8,7 @@ JBOSS_HOME=/opt/jboss/wildfly JBOSS_CLI=$JBOSS_HOME/bin/jboss-cli.sh JBOSS_MODE=${1:-"standalone"} -JBOSS_CONFIG=${2:-"$JBOSS_MODE-full.xml"} +JBOSS_CONFIG=${2:-"$JBOSS_MODE.xml"} function wait_for_server() { until `$JBOSS_CLI -c "ls /deployment" &> /dev/null`; do diff --git a/windup-web-docker-compose/docker-compose.yml b/windup-web-docker-compose/docker-compose.yml index b42e812..436b28d 100644 --- a/windup-web-docker-compose/docker-compose.yml +++ b/windup-web-docker-compose/docker-compose.yml @@ -38,6 +38,7 @@ services: - "9090:9090" volumes: - ./docker-volume:/var/windup + - ./startup-scripts:/docker-entrypoint-init.d:ro environment: DB_HOST: db DB_USER: windup diff --git a/windup-web-docker-compose/startup-scripts/00-init-keycloak.sh b/windup-web-docker-compose/startup-scripts/00-init-keycloak.sh new file mode 100644 index 0000000..5e48f35 --- /dev/null +++ b/windup-web-docker-compose/startup-scripts/00-init-keycloak.sh @@ -0,0 +1,21 @@ +#!/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=windup.data.dir:add(value="$DATA_DIR") +/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 diff --git a/windup-web-docker-compose/startup-scripts/01-init-datasource.sh b/windup-web-docker-compose/startup-scripts/01-init-datasource.sh new file mode 100644 index 0000000..d1f81d7 --- /dev/null +++ b/windup-web-docker-compose/startup-scripts/01-init-datasource.sh @@ -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&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 diff --git a/windup-web-docker-compose/startup-scripts/02-init-logging.sh b/windup-web-docker-compose/startup-scripts/02-init-logging.sh new file mode 100644 index 0000000..9df5f0a --- /dev/null +++ b/windup-web-docker-compose/startup-scripts/02-init-logging.sh @@ -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 diff --git a/windup-web-docker-compose/startup-scripts/03-other.sh b/windup-web-docker-compose/startup-scripts/03-other.sh new file mode 100644 index 0000000..19e263d --- /dev/null +++ b/windup-web-docker-compose/startup-scripts/03-other.sh @@ -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 diff --git a/windup-web-docker-compose/startup.sh b/windup-web-docker-compose/startup.sh new file mode 100644 index 0000000..cde001f --- /dev/null +++ b/windup-web-docker-compose/startup.sh @@ -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 From 1cf19456dc1b2a93cec0cab14f48ab258095c7af Mon Sep 17 00:00:00 2001 From: David Klingenberg Date: Fri, 16 Jun 2017 18:42:11 +0200 Subject: [PATCH 5/6] Build script and Dockerfile startup --- windup-web-docker-compose/Dockerfile | 27 ++---- windup-web-docker-compose/build.sh | 14 ++- .../customization/commands.cli | 50 ---------- .../customization/execute.sh | 92 ------------------- .../startup-scripts/00-init-keycloak.sh | 1 - 5 files changed, 20 insertions(+), 164 deletions(-) delete mode 100644 windup-web-docker-compose/customization/commands.cli delete mode 100755 windup-web-docker-compose/customization/execute.sh diff --git a/windup-web-docker-compose/Dockerfile b/windup-web-docker-compose/Dockerfile index 096eab2..dc6a009 100644 --- a/windup-web-docker-compose/Dockerfile +++ b/windup-web-docker-compose/Dockerfile @@ -1,15 +1,6 @@ -FROM jboss/wildfly:10.1.0.Final -# FROM jboss/keycloak-adapter-wildfly:3.1.0.Final - -ENV KEYCLOAK_VERSION 3.1.0.Final +FROM jboss/keycloak-adapter-wildfly:3.1.0.Final ENV CONFIG_FILE standalone-full.xml -WORKDIR /opt/jboss/wildfly - -RUN curl -L https://downloads.jboss.org/keycloak/$KEYCLOAK_VERSION/adapters/keycloak-oidc/keycloak-wildfly-adapter-dist-$KEYCLOAK_VERSION.tar.gz | tar zx - -WORKDIR /opt/jboss - # Standalone.xml modifications. RUN sed -i -e 's//&\n /' $JBOSS_HOME/standalone/configuration/$CONFIG_FILE && \ sed -i -e 's//&\n /' $JBOSS_HOME/standalone/configuration/$CONFIG_FILE && \ @@ -17,6 +8,14 @@ RUN sed -i -e 's//&\n /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 "=> Validate configuration" -echo "=> DB_URI (docker with networking): " $DB_URI -echo "=> DB_HOST: " $DB_HOST -echo "=> DB_USER: " $DB_USER -echo "=> DATA_DIR: " $DATA_DIR -echo "=> KEYCLOAK_REALM_PUBLIC_KEY: " $KEYCLOAK_REALM_PUBLIC_KEY -echo "=> KEYLOCAK_AUTH_URL: " $KEYLOAK_AUTH_URL - -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&characterEncoding=UTF-8 --user-name=$DB_USER --password="$DB_PASSWORD" --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true - -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 - -# other -# Properties -/system-property=windup.data.dir:add(value="$DATA_DIR") -/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) - -# 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) - -# Other -/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-post-size, value=943718400) - - -# Execute the batch -run-batch -EOF - -echo "=> Shutting down WildFly" -if [ "$JBOSS_MODE" = "standalone" ]; then - $JBOSS_CLI -c ":shutdown" -else - $JBOSS_CLI -c "/host=*:shutdown" -fi diff --git a/windup-web-docker-compose/startup-scripts/00-init-keycloak.sh b/windup-web-docker-compose/startup-scripts/00-init-keycloak.sh index 5e48f35..888711f 100644 --- a/windup-web-docker-compose/startup-scripts/00-init-keycloak.sh +++ b/windup-web-docker-compose/startup-scripts/00-init-keycloak.sh @@ -9,7 +9,6 @@ $JBOSS_CLI -c << EOF batch # Properties -/system-property=windup.data.dir:add(value="$DATA_DIR") /system-property=keycloak.realm.public.key:add(value="$KEYCLOAK_REALM_PUBLIC_KEY") /system-property=keycloak.server.url:add(value="$KEYCLOAK_AUTH_URL") From efd18d46512fe9de2abbb1a257ed55a9bfd0812e Mon Sep 17 00:00:00 2001 From: David Klingenberg Date: Fri, 16 Jun 2017 19:05:24 +0200 Subject: [PATCH 6/6] Add comment to Dockerfile - investigate way how to improve it even more. --- windup-web-docker-compose/Dockerfile | 18 +++++++++++++++--- windup-web-docker-compose/build.sh | 1 - 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/windup-web-docker-compose/Dockerfile b/windup-web-docker-compose/Dockerfile index dc6a009..f21e3ad 100644 --- a/windup-web-docker-compose/Dockerfile +++ b/windup-web-docker-compose/Dockerfile @@ -8,11 +8,26 @@ RUN sed -i -e 's//&\n