Update default distribution to Quarkus (#9839)

Closes #9837
This commit is contained in:
Stian Thorgersen 2022-02-01 09:42:09 +01:00 committed by GitHub
parent 99213ab042
commit cc88fb2daa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 62 additions and 57 deletions

View file

@ -1,6 +1,6 @@
./ ./
keycloak-server-dist:keycloak keycloak-server-dist:keycloak-legacy
keycloak-server-x-dist:keycloak.x-preview keycloak-quarkus-dist:keycloak
keycloak-api-docs-dist:keycloak-api-docs keycloak-api-docs-dist:keycloak-api-docs
keycloak-jetty92-adapter-dist:keycloak-oidc-jetty92-adapter keycloak-jetty92-adapter-dist:keycloak-oidc-jetty92-adapter

View file

@ -77,18 +77,6 @@
<module>server-legacy-dist</module> <module>server-legacy-dist</module>
</modules> </modules>
</profile> </profile>
<profile>
<id>quarkus</id>
<activation>
<jdk>[11,)</jdk>
<property>
<name>!product</name>
</property>
</activation>
<modules>
<module>server-x-dist</module>
</modules>
</profile>
<profile> <profile>
<id>distribution-downloads</id> <id>distribution-downloads</id>
<modules> <modules>

View file

@ -35,7 +35,7 @@
<artifactId>keycloak-server-dist</artifactId> <artifactId>keycloak-server-dist</artifactId>
<name>Keycloak Server Galleon Based Distribution</name> <name>Keycloak Server Legacy WildFly Distribution</name>
<description/> <description/>
<packaging>pom</packaging> <packaging>pom</packaging>
@ -301,7 +301,7 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>keycloak-${project.version}</finalName> <finalName>keycloak-legacy-${project.version}</finalName>
</build> </build>
</profile> </profile>
<profile> <profile>

View file

@ -1468,7 +1468,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.keycloak</groupId> <groupId>org.keycloak</groupId>
<artifactId>keycloak-server-x-dist</artifactId> <artifactId>keycloak-quarkus-dist</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<type>zip</type> <type>zip</type>
</dependency> </dependency>

1
quarkus/container/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.tar.gz

View file

@ -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" ]

View file

@ -19,14 +19,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>keycloak-distribution-parent</artifactId> <artifactId>keycloak-quarkus-parent</artifactId>
<groupId>org.keycloak</groupId> <groupId>org.keycloak</groupId>
<version>17.0.0-SNAPSHOT</version> <version>17.0.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>keycloak-server-x-dist</artifactId> <artifactId>keycloak-quarkus-dist</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Keycloak.X Server Distribution</name> <name>Keycloak Quarkus Server Distribution</name>
<description/> <description/>
<dependencies> <dependencies>
@ -49,7 +49,7 @@
</dependencies> </dependencies>
<build> <build>
<finalName>keycloak.x-${project.version}</finalName> <finalName>keycloak-${project.version}</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

View file

@ -154,6 +154,7 @@
<module>runtime</module> <module>runtime</module>
<module>deployment</module> <module>deployment</module>
<module>server</module> <module>server</module>
<module>dist</module>
<module>tests</module> <module>tests</module>
</modules> </modules>

View file

@ -57,6 +57,11 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-quarkus-dist</artifactId>
<type>zip</type>
</dependency>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId> <artifactId>quarkus-junit5</artifactId>

View file

@ -1,6 +1,5 @@
package org.keycloak.it.utils; package org.keycloak.it.utils;
import org.apache.commons.io.FileUtils;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.keycloak.common.Version; import org.keycloak.common.Version;
import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.GenericContainer;
@ -11,8 +10,6 @@ import org.testcontainers.images.builder.ImageFromDockerfile;
import org.testcontainers.utility.ResourceReaper; import org.testcontainers.utility.ResourceReaper;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.time.Duration; import java.time.Duration;
import java.util.List; import java.util.List;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
@ -30,9 +27,8 @@ public final class DockerKeycloakDistribution implements KeycloakDistribution {
private String stderr = ""; private String stderr = "";
private ToStringConsumer backupConsumer = new ToStringConsumer(); private ToStringConsumer backupConsumer = new ToStringConsumer();
private File distributionFile = new File("../../../distribution/server-x-dist/target/keycloak.x-" + Version.VERSION_KEYCLOAK + ".tar.gz"); private File distributionFile = new File("../../dist/target/keycloak-" + Version.VERSION_KEYCLOAK + ".tar.gz");
private File cachedDockerfile = createDockerCacheFile(); private File dockerFile = new File("../../container/Dockerfile");
private boolean dockerfileFetched = false;
private GenericContainer<?> keycloakContainer = null; private GenericContainer<?> keycloakContainer = null;
private String containerId = null; private String containerId = null;
@ -44,37 +40,15 @@ public final class DockerKeycloakDistribution implements KeycloakDistribution {
this.manualStop = manualStop; 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() { private GenericContainer getKeycloakContainer() {
if (!distributionFile.exists()) { if (!distributionFile.exists()) {
throw new RuntimeException("Distribution archive " + distributionFile.getAbsolutePath() +" doesn't exists"); throw new RuntimeException("Distribution archive " + distributionFile.getAbsolutePath() +" doesn't exists");
} }
fetchDockerfile();
return new GenericContainer( return new GenericContainer(
new ImageFromDockerfile("keycloak.x-under-test", false) new ImageFromDockerfile("keycloak-under-test", false)
.withFileFromFile("keycloakx.tar.gz", distributionFile) .withFileFromFile("keycloak.tar.gz", distributionFile)
.withFileFromFile("Dockerfile", cachedDockerfile) .withFileFromFile("Dockerfile", dockerFile)
.withBuildArg("KEYCLOAK_DIST", "keycloakx.tar.gz") .withBuildArg("KEYCLOAK_DIST", "keycloak.tar.gz")
) )
.withExposedPorts(8080) .withExposedPorts(8080)
.withStartupAttempts(1) .withStartupAttempts(1)

View file

@ -251,7 +251,7 @@ public final class RawKeycloakDistribution implements KeycloakDistribution {
try { try {
Path distRootPath = Paths.get(System.getProperty("java.io.tmpdir")).resolve("kc-tests"); Path distRootPath = Paths.get(System.getProperty("java.io.tmpdir")).resolve("kc-tests");
distRootPath.toFile().mkdirs(); 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()) { if (!distFile.exists()) {
throw new RuntimeException("Distribution archive " + distFile.getAbsolutePath() +" doesn't exists"); throw new RuntimeException("Distribution archive " + distFile.getAbsolutePath() +" doesn't exists");
} }

View file

@ -4,3 +4,5 @@ NEW_VERSION=$1
mvn versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=false -DgroupId=org.keycloak* -DartifactId=* 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 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

View file

@ -13,7 +13,7 @@
<artifactId>integration-arquillian-servers-auth-server-quarkus</artifactId> <artifactId>integration-arquillian-servers-auth-server-quarkus</artifactId>
<properties> <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> <common.resources>${basedir}/../jboss/common</common.resources>
<session.cache.owners>2</session.cache.owners> <session.cache.owners>2</session.cache.owners>
<offline.session.cache.owners>2</offline.session.cache.owners> <offline.session.cache.owners>2</offline.session.cache.owners>
@ -26,7 +26,7 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.keycloak</groupId> <groupId>org.keycloak</groupId>
<artifactId>keycloak-server-x-dist</artifactId> <artifactId>keycloak-quarkus-dist</artifactId>
<type>zip</type> <type>zip</type>
</dependency> </dependency>
</dependencies> </dependencies>
@ -177,7 +177,7 @@
<artifactItems> <artifactItems>
<artifactItem> <artifactItem>
<groupId>org.keycloak</groupId> <groupId>org.keycloak</groupId>
<artifactId>keycloak-server-x-dist</artifactId> <artifactId>keycloak-quarkus-dist</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<type>zip</type> <type>zip</type>
<outputDirectory>${project.build.directory}/unpacked</outputDirectory> <outputDirectory>${project.build.directory}/unpacked</outputDirectory>