KEYCLOAK-5967 Move configuration of load-balancer from Dockerfile to maven

This commit is contained in:
Tomas Kyjovsky 2017-11-30 23:01:52 +01:00 committed by Hynek Mlnařík
parent 5d5a200413
commit b5c7be574b
12 changed files with 248 additions and 20 deletions

View file

@ -1,17 +0,0 @@
FROM jboss/wildfly
ADD configs/ ./
ADD *.sh /usr/local/bin/
USER root
RUN chmod -v +x /usr/local/bin/*.sh
RUN yum -y install iproute
USER jboss
RUN $JBOSS_HOME/bin/jboss-cli.sh --file=mod-cluster-balancer.cli
RUN $JBOSS_HOME/bin/jboss-cli.sh --file=undertow.cli
RUN $JBOSS_HOME/bin/jboss-cli.sh --file=io-worker-threads.cli; \
cd $JBOSS_HOME/standalone; rm -rf configuration/standalone_xml_history log data tmp
HEALTHCHECK --interval=5s --timeout=5s --retries=12 CMD ["wildfly-healthcheck.sh"]
ENTRYPOINT [ "docker-entrypoint.sh" ]

View file

@ -0,0 +1,60 @@
<project name="keycloak-server-configuration" basedir="." >
<target name="check-configuration-state">
<available property="configured" file="${project.build.directory}/configured"/>
<available property="management.configured" file="${project.build.directory}/management-configured"/>
<echo>configured: ${configured}</echo>
<echo>management.configured: ${management.configured}</echo>
</target>
<target name="configure-modcluster" unless="configured" depends="check-configuration-state">
<chmod perm="ug+x">
<fileset dir="${server.unpacked.home}/bin">
<include name="*.sh"/>
</fileset>
</chmod>
<copy todir="${server.unpacked.home}/bin" >
<fileset dir="${scripts.dir}/jboss-cli"/>
</copy>
<exec executable="./${jboss.cli.script}" dir="${server.unpacked.home}/bin" failonerror="true">
<arg value="--file=mod-cluster-balancer.cli"/>
</exec>
<exec executable="./${jboss.cli.script}" dir="${server.unpacked.home}/bin" failonerror="true">
<arg value="--file=undertow.cli"/>
</exec>
<exec executable="./${jboss.cli.script}" dir="${server.unpacked.home}/bin" failonerror="true">
<arg value="--file=io-worker-threads.cli"/>
</exec>
<delete dir="${server.unpacked.home}/standalone/configuration/standalone_xml_history"/>
<delete dir="${server.unpacked.home}/standalone/log"/>
<delete dir="${server.unpacked.home}/standalone/data"/>
<delete dir="${server.unpacked.home}/standalone/tmp"/>
<touch file="${project.build.directory}/configured"/>
</target>
<target name="add-management-user" unless="management.configured" depends="check-configuration-state">
<echo>Adding management user: `${management.user}`</echo>
<exec executable="./${add.user.script}" dir="${server.unpacked.home}/bin" failonerror="true">
<arg value="-u"/>
<arg value="${management.user}"/>
<arg value="-p"/>
<arg value="${management.user.password}"/>
</exec>
<touch file="${project.build.directory}/management-configured"/>
</target>
<target name="prepare-docker-config">
<copy todir="${project.build.directory}/docker" overwrite="false">
<fileset dir="${scripts.dir}">
<include name="Dockerfile"/>
<include name="*.sh"/>
</fileset>
</copy>
<copy todir="${project.build.directory}/docker/wildfly" overwrite="false">
<fileset dir="${server.unpacked.home}">
<exclude name="bin/*.cli"/>
</fileset>
</copy>
</target>
</project>

View file

@ -0,0 +1,155 @@
<?xml version="1.0"?>
<!--
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
~ and other contributors as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>performance</artifactId>
<version>3.4.2.Final-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>performance-keycloak-wildfly-modcluster</artifactId>
<name>Keycloak Performance TestSuite - Wildfly ModCluster Load Balancer</name>
<packaging>pom</packaging>
<properties>
<server.groupId>org.wildfly</server.groupId>
<server.artifactId>wildfly-server-dist</server.artifactId>
<server.unpacked.home>${project.build.directory}/wildfly-${wildfly.version}</server.unpacked.home>
<script.extension>sh</script.extension>
<jboss.cli.script>jboss-cli.${script.extension}</jboss.cli.script>
<add.user.script>add-user.${script.extension}</add.user.script>
<scripts.dir>${project.build.scriptSourceDirectory}</scripts.dir>
<resources.dir>${project.basedir}/src/main/resources</resources.dir>
<skip.add.management.user>true</skip.add.management.user>
<skip.docker.config>false</skip.docker.config>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-wildfly</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<overWriteIfNewer>true</overWriteIfNewer>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${wildfly.version}</version>
<type>zip</type>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>configure-modcluster</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant antfile="configure.xml" target="configure-modcluster" />
</target>
</configuration>
</execution>
<execution>
<id>add-management-user</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<skip>${skip.add.management.user}</skip>
<target>
<ant antfile="configure.xml" target="add-management-user" />
</target>
</configuration>
</execution>
<execution>
<id>prepare-docker-config</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<skip>${skip.docker.config}</skip>
<target>
<ant antfile="configure.xml" target="prepare-docker-config" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>add-management-user</id>
<activation>
<property>
<name>management.user</name>
</property>
</activation>
<properties>
<skip.add.management.user>false</skip.add.management.user>
<!--it seems to be necessary to explicitly re-set these properties here
otherwise the antrun plugin won't pick them up-->
<management.user>${management.user}</management.user>
<management.user.password>${management.user.password}</management.user.password>
</properties>
</profile>
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<script.extension>ps1</script.extension>
</properties>
</profile>
</profiles>
</project>

View file

@ -0,0 +1,27 @@
FROM jboss/base-jdk:8
ENV JBOSS_HOME /opt/jboss/wildfly
WORKDIR $JBOSS_HOME
ENV CONFIGURATION standalone.xml
# Ensure signals are forwarded to the JVM process correctly for graceful shutdown
ENV LAUNCH_JBOSS_IN_BACKGROUND 1
USER root
RUN yum -y install iproute
ADD wildfly ./
ADD *.sh /usr/local/bin/
RUN chown -R jboss . ;\
chgrp -R jboss . ;\
chmod -R -v ug+x bin/*.sh ;\
chmod -R -v ug+x /usr/local/bin/
USER jboss
EXPOSE 8080
EXPOSE 9990
HEALTHCHECK --interval=5s --timeout=5s --retries=12 CMD ["wildfly-healthcheck.sh"]
ENTRYPOINT ["docker-entrypoint.sh"]

View file

@ -4,7 +4,7 @@ cat $JBOSS_HOME/standalone/configuration/standalone.xml
. get-ips.sh
PARAMS="-b $PUBLIC_IP -bprivate $PRIVATE_IP $@"
PARAMS="-b $PUBLIC_IP -bmanagement $PUBLIC_IP -bprivate $PRIVATE_IP $@"
echo "Server startup params: $PARAMS"
# Note: External container connectivity is always provided by eth0 -- irrespective of which is considered public/private by KC.

View file

@ -38,7 +38,8 @@
<modules>
<module>keycloak</module>
<module>load-balancer/wildfly-modcluster</module>
<module>tests</module>
</modules>
</project>

View file

@ -338,10 +338,12 @@
<fileset dir="${project.basedir}/..">
<include name="db/**"/>
<include name="infinispan/**"/>
<include name="load-balancer/**"/>
<include name="monitoring/**"/>
</fileset>
</copy>
<copy todir="${project.build.directory}/docker-compose/load-balancer/wildfly-modcluster" overwrite="false" >
<fileset dir="${project.basedir}/../load-balancer/wildfly-modcluster/target/docker"/>
</copy>
<copy todir="${project.build.directory}/docker-compose/keycloak" overwrite="false" >
<fileset dir="${project.basedir}/../keycloak/target/docker"/>
</copy>