Skip to content

Commit

Permalink
Update default distribution to Quarkus (keycloak#9839)
Browse files Browse the repository at this point in the history
  • Loading branch information
stianst authored Feb 1, 2022
1 parent 99213ab commit cc88fb2
Show file tree
Hide file tree
Showing 22 changed files with 62 additions and 57 deletions.
4 changes: 2 additions & 2 deletions distribution/downloads/src/main/resources/files
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
./
keycloak-server-dist:keycloak
keycloak-server-x-dist:keycloak.x-preview
keycloak-server-dist:keycloak-legacy
keycloak-quarkus-dist:keycloak
keycloak-api-docs-dist:keycloak-api-docs

keycloak-jetty92-adapter-dist:keycloak-oidc-jetty92-adapter
Expand Down
12 changes: 0 additions & 12 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@
<module>server-legacy-dist</module>
</modules>
</profile>
<profile>
<id>quarkus</id>
<activation>
<jdk>[11,)</jdk>
<property>
<name>!product</name>
</property>
</activation>
<modules>
<module>server-x-dist</module>
</modules>
</profile>
<profile>
<id>distribution-downloads</id>
<modules>
Expand Down
4 changes: 2 additions & 2 deletions distribution/server-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<artifactId>keycloak-server-dist</artifactId>

<name>Keycloak Server Galleon Based Distribution</name>
<name>Keycloak Server Legacy WildFly Distribution</name>
<description/>

<packaging>pom</packaging>
Expand Down Expand Up @@ -301,7 +301,7 @@
</dependency>
</dependencies>
<build>
<finalName>keycloak-${project.version}</finalName>
<finalName>keycloak-legacy-${project.version}</finalName>
</build>
</profile>
<profile>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-x-dist</artifactId>
<artifactId>keycloak-quarkus-dist</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
Expand Down
1 change: 1 addition & 0 deletions quarkus/container/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.tar.gz
34 changes: 34 additions & 0 deletions quarkus/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM registry.access.redhat.com/ubi8-minimal AS build-env

ENV KEYCLOAK_VERSION 17.0.0-SNAPSHOT
ARG KEYCLOAK_DIST=https://github.com/keycloak/keycloak/releases/download/$KEYCLOAK_VERSION/keycloak-$KEYCLOAK_VERSION.tar.gz

RUN microdnf install -y tar gzip

ADD $KEYCLOAK_DIST /tmp/keycloak/

# The next step makes it uniform for local development and upstream built.
# If it is a local tar archive then it is unpacked, if from remote is just downloaded.
RUN (cd /tmp/keycloak && \
tar -xvf /tmp/keycloak/keycloak-*.tar.gz && \
rm /tmp/keycloak/keycloak-*.tar.gz) || true

RUN mv /tmp/keycloak/keycloak-* /opt/keycloak

FROM registry.access.redhat.com/ubi8-minimal

COPY --from=build-env /opt/keycloak /opt/keycloak

RUN microdnf update -y && \
microdnf install -y java-11-openjdk-headless && microdnf clean all && rm -rf /var/cache/yum/* && \
echo "keycloak:x:0:root" >> /etc/group && \
echo "keycloak:x:1000:0:keycloak user:/opt/keycloak:/sbin/nologin" >> /etc/passwd && \
chown -R keycloak:root /opt/keycloak && \
chmod -R g+rwX /opt/keycloak

USER 1000

EXPOSE 8080
EXPOSE 8443

ENTRYPOINT [ "/opt/keycloak/bin/kc.sh" ]
File renamed without changes.
8 changes: 4 additions & 4 deletions distribution/server-x-dist/pom.xml → quarkus/dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>keycloak-distribution-parent</artifactId>
<artifactId>keycloak-quarkus-parent</artifactId>
<groupId>org.keycloak</groupId>
<version>17.0.0-SNAPSHOT</version>
</parent>

<artifactId>keycloak-server-x-dist</artifactId>
<artifactId>keycloak-quarkus-dist</artifactId>
<packaging>pom</packaging>
<name>Keycloak.X Server Distribution</name>
<name>Keycloak Quarkus Server Distribution</name>
<description/>

<dependencies>
Expand All @@ -49,7 +49,7 @@
</dependencies>

<build>
<finalName>keycloak.x-${project.version}</finalName>
<finalName>keycloak-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions quarkus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
<module>runtime</module>
<module>deployment</module>
<module>server</module>
<module>dist</module>
<module>tests</module>
</modules>

Expand Down
5 changes: 5 additions & 0 deletions quarkus/tests/integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-quarkus-dist</artifactId>
<type>zip</type>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.keycloak.it.utils;

import org.apache.commons.io.FileUtils;
import org.jboss.logging.Logger;
import org.keycloak.common.Version;
import org.testcontainers.containers.GenericContainer;
Expand All @@ -11,8 +10,6 @@
import org.testcontainers.utility.ResourceReaper;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.Executor;
Expand All @@ -30,9 +27,8 @@ public final class DockerKeycloakDistribution implements KeycloakDistribution {
private String stderr = "";
private ToStringConsumer backupConsumer = new ToStringConsumer();

private File distributionFile = new File("../../../distribution/server-x-dist/target/keycloak.x-" + Version.VERSION_KEYCLOAK + ".tar.gz");
private File cachedDockerfile = createDockerCacheFile();
private boolean dockerfileFetched = false;
private File distributionFile = new File("../../dist/target/keycloak-" + Version.VERSION_KEYCLOAK + ".tar.gz");
private File dockerFile = new File("../../container/Dockerfile");

private GenericContainer<?> keycloakContainer = null;
private String containerId = null;
Expand All @@ -44,37 +40,15 @@ public DockerKeycloakDistribution(boolean debug, boolean manualStop, boolean reC
this.manualStop = manualStop;
}

private File createDockerCacheFile() {
try {
File tmp = File.createTempFile("Dockerfile", "keycloak.x");
tmp.deleteOnExit();
return tmp;
} catch (IOException e) {
throw new RuntimeException(e);
}
}

private void fetchDockerfile() {
if (!dockerfileFetched) {
try {
FileUtils.copyURLToFile(new URL("https://raw.githubusercontent.com/keycloak/keycloak-containers/main/server-x/Dockerfile"), cachedDockerfile);
dockerfileFetched = true;
} catch (Exception cause) {
throw new RuntimeException("Cannot download upstream Dockerfile", cause);
}
}
}

private GenericContainer getKeycloakContainer() {
if (!distributionFile.exists()) {
throw new RuntimeException("Distribution archive " + distributionFile.getAbsolutePath() +" doesn't exists");
}
fetchDockerfile();
return new GenericContainer(
new ImageFromDockerfile("keycloak.x-under-test", false)
.withFileFromFile("keycloakx.tar.gz", distributionFile)
.withFileFromFile("Dockerfile", cachedDockerfile)
.withBuildArg("KEYCLOAK_DIST", "keycloakx.tar.gz")
new ImageFromDockerfile("keycloak-under-test", false)
.withFileFromFile("keycloak.tar.gz", distributionFile)
.withFileFromFile("Dockerfile", dockerFile)
.withBuildArg("KEYCLOAK_DIST", "keycloak.tar.gz")
)
.withExposedPorts(8080)
.withStartupAttempts(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ private Path prepareDistribution() {
try {
Path distRootPath = Paths.get(System.getProperty("java.io.tmpdir")).resolve("kc-tests");
distRootPath.toFile().mkdirs();
File distFile = new File("../../../distribution/server-x-dist/target/keycloak.x-" + Version.VERSION_KEYCLOAK + ".zip");
File distFile = new File("../../dist/target/keycloak-" + Version.VERSION_KEYCLOAK + ".zip");
if (!distFile.exists()) {
throw new RuntimeException("Distribution archive " + distFile.getAbsolutePath() +" doesn't exists");
}
Expand Down
2 changes: 2 additions & 0 deletions set-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ NEW_VERSION=$1

mvn versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=false -DgroupId=org.keycloak* -DartifactId=*
mvn versions:use-dep-version -Dincludes=org.keycloak:keycloak-admin-ui -DdepVersion=$NEW_VERSION -DforceVersion=true -pl org.keycloak:keycloak-parent

sed -i "s/ENV KEYCLOAK_VERSION .*/ENV KEYCLOAK_VERSION $NEW_VERSION/" quarkus/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<artifactId>integration-arquillian-servers-auth-server-quarkus</artifactId>

<properties>
<auth.server.home>${project.build.directory}/unpacked/keycloak.x-${project.version}</auth.server.home>
<auth.server.home>${project.build.directory}/unpacked/keycloak-${project.version}</auth.server.home>
<common.resources>${basedir}/../jboss/common</common.resources>
<session.cache.owners>2</session.cache.owners>
<offline.session.cache.owners>2</offline.session.cache.owners>
Expand All @@ -26,7 +26,7 @@
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-x-dist</artifactId>
<artifactId>keycloak-quarkus-dist</artifactId>
<type>zip</type>
</dependency>
</dependencies>
Expand Down Expand Up @@ -177,7 +177,7 @@
<artifactItems>
<artifactItem>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-x-dist</artifactId>
<artifactId>keycloak-quarkus-dist</artifactId>
<version>${project.version}</version>
<type>zip</type>
<outputDirectory>${project.build.directory}/unpacked</outputDirectory>
Expand Down

0 comments on commit cc88fb2

Please sign in to comment.