Skip to content

Commit

Permalink
custom keycloak image to install JS engine
Browse files Browse the repository at this point in the history
(cherry picked from commit a2914f7)
  • Loading branch information
pedroigor authored and gsmet committed Apr 2, 2023
1 parent be56f0c commit 1b1024f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
35 changes: 35 additions & 0 deletions integration-tests/keycloak-authorization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<properties>
<keycloak.url>http://localhost:8180/auth</keycloak.url>
<nashorn-core.version>15.3</nashorn-core.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -110,20 +111,37 @@
<artifactId>htmlunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
<version>${nashorn-core.version}</version>
</dependency>
</dependencies>

<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
<systemPropertyVariables>
<keycloak.image.version>${keycloak.image.version}</keycloak.image.version>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>true</skip>
<systemPropertyVariables>
<keycloak.image.version>${keycloak.image.version}</keycloak.image.version>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
Expand All @@ -137,6 +155,23 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies-quarkus</id>
<phase>process-test-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
<includeArtifactIds>nashorn-core,asm,asm-util,asm-commons</includeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.keycloak.util.JsonSerialization;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.images.builder.ImageFromDockerfile;
import org.testcontainers.images.builder.Transferable;

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
Expand All @@ -44,16 +45,22 @@ public class KeycloakLifecycleManager implements QuarkusTestResourceLifecycleMan
protected static String KEYCLOAK_SERVER_URL;
private static final String KEYCLOAK_REALM = "quarkus";
private static final String KEYCLOAK_SERVICE_CLIENT = "quarkus-service-app";
private static final String KEYCLOAK_VERSION = System.getProperty("keycloak.version");
private static final String KEYCLOAK_IMAGE = System.getProperty("keycloak.docker.image");

@SuppressWarnings("resource")
@Override
public Map<String, String> start() {
keycloak = new GenericContainer<>("quay.io/keycloak/keycloak:" + KEYCLOAK_VERSION)
.withExposedPorts(8080)
.withEnv("KEYCLOAK_ADMIN", "admin")
.withEnv("KEYCLOAK_ADMIN_PASSWORD", "admin")
.waitingFor(Wait.forLogMessage(".*Keycloak.*started.*", 1));
try {
keycloak = new GenericContainer<>(
new ImageFromDockerfile().withDockerfile(Paths.get(getClass().getResource("/Dockerfile").toURI()))
.withBuildArg("KEYCLOAK_IMAGE", KEYCLOAK_IMAGE))
.withExposedPorts(8080)
.withEnv("KEYCLOAK_ADMIN", "admin")
.withEnv("KEYCLOAK_ADMIN_PASSWORD", "admin")
.waitingFor(Wait.forLogMessage(".*Keycloak.*started.*", 1));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}

keycloak = keycloak
.withCopyToContainer(Transferable.of(createPoliciesJar().toByteArray()), "/opt/keycloak/providers/policies.jar")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ${keycloak.docker.image} as builder

COPY ./*.jar /opt/keycloak/providers/

FROM ${keycloak.docker.image}
COPY --from=builder /opt/keycloak/ /opt/keycloak/

ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]

0 comments on commit 1b1024f

Please sign in to comment.