KEYCLOAK-5968 Move configuration of Infinispan server from Dockerfile to maven

This commit is contained in:
Tomas Kyjovsky 2017-12-19 12:42:26 +01:00 committed by Hynek Mlnařík
parent 9b63cd35f0
commit df68ca8dcf
12 changed files with 268 additions and 54 deletions

View file

@ -1,31 +0,0 @@
FROM jboss/infinispan-server:8.2.6.Final
#FROM jboss/infinispan-server:9.1.0.Final
ARG LOCAL_SITE
ARG REMOTE_SITE
ARG MANAGEMENT_USER
ARG MANAGEMENT_USER_PASS
USER root
RUN yum -y install iproute
USER jboss
ENV CONFIGURATION clustered.xml
ADD configs/ ./
ADD *.sh /usr/local/bin/
RUN sed -e s/%LOCAL_SITE%/$LOCAL_SITE/ -e s/%REMOTE_SITE%/$REMOTE_SITE/ add-keycloak-caches.cli.template > add-keycloak-caches.cli
USER root
RUN chmod -v +x /usr/local/bin/*.sh
USER jboss
RUN if [ ! -z "$MANAGEMENT_USER" ]; then $INFINISPAN_SERVER_HOME/bin/add-user.sh -u $MANAGEMENT_USER -p $MANAGEMENT_USER_PASS ; fi
RUN $INFINISPAN_SERVER_HOME/bin/ispn-cli.sh --file=add-private-network-interface.cli; \
$INFINISPAN_SERVER_HOME/bin/ispn-cli.sh --file=add-keycloak-caches.cli; \
cd $INFINISPAN_SERVER_HOME/standalone; rm -rf configuration/standalone_xml_history log data tmp
HEALTHCHECK --interval=5s --timeout=5s --retries=12 CMD ["infinispan-healthcheck.sh"]
ENTRYPOINT [ "docker-entrypoint-custom.sh" ]

View file

@ -0,0 +1,79 @@
<project name="keycloak-server-configuration" basedir="." >
<target name="check-configuration-state">
<available property="configured" file="${infinispan.unpacked.home}/../configured"/>
<available property="management.configured" file="${infinispan.unpacked.home}/../management-configured"/>
<echo>configured: ${configured}</echo>
<echo>management.configured: ${management.configured}</echo>
</target>
<target name="configure-infinispan" unless="configured" depends="check-configuration-state">
<!-- configuration common for both DC sites-->
<chmod perm="ug+x">
<fileset dir="${infinispan.unpacked.home}/bin">
<include name="*.sh"/>
</fileset>
</chmod>
<copy file="${scripts.dir}/jboss-cli/add-private-network-interface.cli" todir="${infinispan.unpacked.home}/bin" />
<exec executable="./${jboss.cli.script}" dir="${infinispan.unpacked.home}/bin" failonerror="true">
<arg value="--file=add-private-network-interface.cli"/>
</exec>
<!-- DC-specific configuration (dc1 and dc2) -->
<copy file="${infinispan.unpacked.home}/standalone/configuration/clustered.xml"
tofile="${infinispan.unpacked.home}/standalone/configuration/clustered-dc1.xml" />
<move file="${infinispan.unpacked.home}/standalone/configuration/clustered.xml"
tofile="${infinispan.unpacked.home}/standalone/configuration/clustered-dc2.xml" />
<copy file="${scripts.dir}/jboss-cli/add-keycloak-caches.cli" tofile="${infinispan.unpacked.home}/bin/add-keycloak-caches-dc1.cli" >
<filterset>
<filter token="LOCAL_SITE" value="dc1"/>
<filter token="REMOTE_SITE" value="dc2"/>
</filterset>
</copy>
<copy file="${scripts.dir}/jboss-cli/add-keycloak-caches.cli" tofile="${infinispan.unpacked.home}/bin/add-keycloak-caches-dc2.cli" >
<filterset>
<filter token="LOCAL_SITE" value="dc2"/>
<filter token="REMOTE_SITE" value="dc1"/>
</filterset>
</copy>
<exec executable="./${jboss.cli.script}" dir="${infinispan.unpacked.home}/bin" failonerror="true">
<arg value="--file=add-keycloak-caches-dc1.cli"/>
</exec>
<exec executable="./${jboss.cli.script}" dir="${infinispan.unpacked.home}/bin" failonerror="true">
<arg value="--file=add-keycloak-caches-dc2.cli"/>
</exec>
<!--cleanup-->
<delete dir="${infinispan.unpacked.home}/standalone/configuration/standalone_xml_history"/>
<delete dir="${infinispan.unpacked.home}/standalone/log"/>
<delete dir="${infinispan.unpacked.home}/standalone/data"/>
<delete dir="${infinispan.unpacked.home}/standalone/tmp"/>
<touch file="${infinispan.unpacked.home}/../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="${infinispan.unpacked.home}/bin" failonerror="true">
<arg value="-u"/>
<arg value="${management.user}"/>
<arg value="-p"/>
<arg value="${management.user.password}"/>
</exec>
<touch file="${infinispan.unpacked.home}/../management-configured"/>
</target>
<target name="prepare-docker-config">
<copy todir="${infinispan.unpacked.home}/../docker" overwrite="false">
<fileset dir="${scripts.dir}">
<include name="Dockerfile"/>
<include name="*.sh"/>
</fileset>
</copy>
<copy todir="${infinispan.unpacked.home}/../docker/infinispan-server" overwrite="false">
<fileset dir="${infinispan.unpacked.home}">
<exclude name="bin/*.cli"/>
</fileset>
</copy>
</target>
</project>

View file

@ -0,0 +1,157 @@
<?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>4.0.0.CR1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>performance-keycloak-infinispan-server</artifactId>
<name>Keycloak Performance TestSuite - Infinispan Server</name>
<packaging>pom</packaging>
<properties>
<infinispan.groupId>org.infinispan.server</infinispan.groupId>
<infinispan.artifactId>infinispan-server-build</infinispan.artifactId>
<!--infinispan.version is located in the root pom.xml-->
<infinispan.unpacked.folder.name>infinispan-server-${infinispan.version}</infinispan.unpacked.folder.name>
<infinispan.unpacked.home>${project.build.directory}/${infinispan.unpacked.folder.name}</infinispan.unpacked.home>
<script.extension>sh</script.extension>
<jboss.cli.script>ispn-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-infinispan-servers</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<overWriteIfNewer>true</overWriteIfNewer>
<artifactItems>
<artifactItem>
<groupId>${infinispan.groupId}</groupId>
<artifactId>${infinispan.artifactId}</artifactId>
<version>${infinispan.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-infinispan</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant antfile="configure.xml" target="configure-infinispan" />
</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,18 @@
FROM jboss/base-jdk:8
ENV LAUNCH_JBOSS_IN_BACKGROUND 1
ENV CONFIGURATION clustered.xml
ENV INFINISPAN_SERVER_HOME /opt/jboss/infinispan-server
WORKDIR $INFINISPAN_SERVER_HOME
USER root
RUN yum -y install iproute
ADD infinispan-server ./
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 7600 8080 8181 8888 9990 11211 11222 57600
HEALTHCHECK --interval=5s --timeout=5s --retries=12 CMD ["infinispan-healthcheck.sh"]
ENTRYPOINT [ "docker-entrypoint-custom.sh" ]

View file

@ -1,7 +1,5 @@
#!/bin/bash
#$JBOSS_HOME/bin/jboss-cli.sh -c ":read-attribute(name=server-state)" | grep -q "running"
. get-ips.sh
CODE=`curl -s -o /dev/null -w "%{http_code}" http://$PUBLIC_IP:9990/console/index.html`

View file

@ -1,4 +1,4 @@
embed-server --server-config=clustered.xml
embed-server --server-config=clustered-@LOCAL_SITE@.xml
# 2)
cd /subsystem=datagrid-jgroups
@ -7,8 +7,8 @@ cd /subsystem=datagrid-jgroups
./channel=xsite:add(stack=tcp-private)
# 2.b)
./stack=udp/relay=RELAY:add(site="%LOCAL_SITE%", properties={relay_multicasts=false})
./stack=udp/relay=RELAY/remote-site=%REMOTE_SITE%:add(channel=xsite)
./stack=udp/relay=RELAY:add(site="@LOCAL_SITE@", properties={relay_multicasts=false})
./stack=udp/relay=RELAY/remote-site=@REMOTE_SITE@:add(channel=xsite)
@ -19,7 +19,7 @@ cd /subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFI
cd replicated-cache-configuration=sessions-cfg
./transaction=TRANSACTION:add(mode=NON_DURABLE_XA, locking=PESSIMISTIC)
./locking=LOCKING:add(acquire-timeout=0)
./backup=%REMOTE_SITE%:add(failure-policy=FAIL, strategy=SYNC, enabled=true, min-wait=60000, after-failures=3)
./backup=@REMOTE_SITE@:add(failure-policy=FAIL, strategy=SYNC, enabled=true, min-wait=60000, after-failures=3)
cd /subsystem=datagrid-infinispan/cache-container=clustered
./replicated-cache=work:add(configuration=sessions-cfg)

View file

@ -39,6 +39,7 @@
<modules>
<module>keycloak</module>
<module>load-balancer/wildfly-modcluster</module>
<module>infinispan</module>
<module>tests</module>
</modules>

View file

@ -339,10 +339,12 @@
<copy todir="${project.build.directory}/docker-compose" overwrite="false" >
<fileset dir="${project.basedir}/..">
<include name="db/**"/>
<include name="infinispan/**"/>
<include name="monitoring/**"/>
</fileset>
</copy>
<copy todir="${project.build.directory}/docker-compose/infinispan" overwrite="false" >
<fileset dir="${project.basedir}/../infinispan/target/docker"/>
</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>

View file

@ -30,20 +30,15 @@ networks:
services:
infinispan_dc1:
build:
context: infinispan
args:
LOCAL_SITE: dc1
REMOTE_SITE: dc2
MANAGEMENT_USER: ${MANAGEMENT_USER}
MANAGEMENT_USER_PASS: ${MANAGEMENT_USER_PASS}
image: keycloak_test_infinispan_dc1:${KEYCLOAK_VERSION:-latest}
build: infinispan
image: keycloak_test_infinispan:${KEYCLOAK_VERSION:-latest}
cpuset: ${INFINISPAN_DC1_CPUSET:-1}
mem_limit: ${INFINISPAN_MEMLIMIT:-1500m}
networks:
- ispn_replication
- dc1_keycloak
environment:
CONFIGURATION: clustered-dc1.xml
PUBLIC_SUBNET: 10.1.1.0/24
PRIVATE_SUBNET: 10.0.4.0/24
MGMT_USER: admin
@ -54,14 +49,8 @@ services:
- "9990"
infinispan_dc2:
build:
context: infinispan
args:
LOCAL_SITE: dc2
REMOTE_SITE: dc1
MANAGEMENT_USER: ${MANAGEMENT_USER}
MANAGEMENT_USER_PASS: ${MANAGEMENT_USER_PASS}
image: keycloak_test_infinispan_dc2:${KEYCLOAK_VERSION:-latest}
build: infinispan
image: keycloak_test_infinispan:${KEYCLOAK_VERSION:-latest}
depends_on:
infinispan_dc1:
condition: service_healthy
@ -71,6 +60,7 @@ services:
- ispn_replication
- dc2_keycloak
environment:
CONFIGURATION: clustered-dc2.xml
PUBLIC_SUBNET: 10.2.1.0/24
PRIVATE_SUBNET: 10.0.4.0/24
MGMT_USER: admin