-
Notifications
You must be signed in to change notification settings - Fork 377
feat: add keycloak service #1806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Looks already quite good, I will try to figure out a working configuration. Some more options like ports would be great and maybe even some env config to add more env variables. |
@tboerger: Port is already there. Jeah Env config seems good! |
Yeah but there are ports for http, https and internal. |
467ab89
to
8399ecd
Compare
I think I cannot make it work. Keycloak tries to write (I assume) (it builds itself?) to the Nix store when launched, or to another write only directory. I am not so familiar what the I always get: some dumb JAVA build failures. [keycloak ] ERROR: Failed to run 'build' command.
[keycloak ] ERROR: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[keycloak ] [error]: Build step io.quarkus.deployment.pkg.steps.JarResultBuildStep#buildRunnerJar threw an exception: java.nio.file.ReadOnlyFileSystemException
[keycloak ] at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.checkWritable(ZipFileSystem.java:370)
[keycloak ] at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.createDirectory(ZipFileSystem.java:708)
[keycloak ] at jdk.zipfs/jdk.nio.zipfs.ZipPath.createDirectory(ZipPath.java:742)
[keycloak ] at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.createDirectory(ZipFileSystemProvider.java:186)
[keycloak ] at java.base/java.nio.file.Files.createDirectory(Files.java:699)
[keycloak ] at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
[keycloak ] at java.base/java.nio.file.Files.createDirectories(Files.java:752)
[keycloak ] at io.quarkus.deployment.pkg.steps.JarResultBuildStep.buildThinJar(JarResultBuildStep.java:664)
[keycloak ] at io.quarkus.deployment.pkg.steps.JarResultBuildStep.buildRunnerJar(JarResultBuildStep.java:228)
[keycloak ] at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
[keycloak ] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
[keycloak ] at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
[keycloak ] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[keycloak ] at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
[keycloak ] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
[keycloak ] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
[keycloak ] at java.base/java.lang.Thread.run(Thread.java:1583)
[keycloak ] at org.jboss.threads.JBossThread.run(JBossThread.java:483)
[keycloak ]
[keycloak ] ERROR: Build failure: Build failed due to errors
[keycloak ] [error]: Build step io.quarkus.deployment.pkg.steps.JarResultBuildStep#buildRunnerJar threw an exception: java.nio.file.ReadOnlyFileSystemException
[keycloak ] at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.checkWritable(ZipFileSystem.java:370)
[keycloak ] at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.createDirectory(ZipFileSystem.java:708)
[keycloak ] at jdk.zipfs/jdk.nio.zipfs.ZipPath.createDirectory(ZipPath.java:742)
[keycloak ] at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.createDirectory(ZipFileSystemProvider.java:186)
[keycloak ] at java.base/java.nio.file.Files.createDirectory(Files.java:699)
[keycloak ] at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
[keycloak ] at java.base/java.nio.file.Files.createDirectories(Files.java:752)
[keycloak ] at io.quarkus.deployment.pkg.steps.JarResultBuildStep.buildThinJar(JarResultBuildStep.java:664)
[keycloak ] at io.quarkus.deployment.pkg.steps.JarResultBuildStep.buildRunnerJar(JarResultBuildStep.java:228)
[keycloak ] at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
[keycloak ] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
[keycloak ] at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
[keycloak ] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[keycloak ] at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
[keycloak ] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
[keycloak ] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
[keycloak ] at java.base/java.lang.Thread.run(Thread.java:1583)
[keycloak ] at org.jboss.threads.JBossThread.run(JBossThread.java:483)
[keycloak ]
[keycloak ] For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command. @talyz: Do you might know what the problem is here since you have hopefully some insight. Does the NixOS modules do something different? https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/web-apps/keycloak.nix#L766 I just try to launch it in |
Have you tried start instead if start-dev? |
@tboerger : yes, I think I need to run another build by overriding the configFile like here https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/web-apps/keycloak.nix#L503 so we need to make a @tboerger : If you could figure out how that would look like, I could test it tomorrow. |
Yes, you do indeed need to provide the config as is done in the NixOS module, since quarkus will try to rebuild its image if the config doesn't match its cached one. |
@sandydoo: Is is actually possible to reuse (not sure how?) NixOS Modules and is the module system of devenv the same as NixOS's one? @tboerger: I will first try to make |
@talyz: Kudos for your module, its great! |
Since this is for dev environments I would prefer to keep it simple without postgres and just use the builtin file-based database. Was it sqlite or h2 by default? |
not sure I think its dev-mem or dev-file you can choose from |
If you simply skip the env variable for the database driver it should be fine. |
968aaa8
to
f62c0e1
Compare
@tboerger: I dont have time next week to test if it starts up. So far the thing should build, maybe you can give it a test, direnv allow # or nix develop
./result/bin/devenv-run-tests --only keycloak if it starts up or not. Maybe propose changes I can integrate after 14. April. |
@talyz: Do you mind maybe helping out with some questions: I was hoping to get |
6185969
to
d84bfe3
Compare
2106f5e
to
2659a57
Compare
It works now: I forgot to symlink some folders which are apparently used for the build, that was quite a hassle. I try to make the export/import of the realms also work... |
- `dev-mem` does not work, as it runs in memory and `kc.sh export` is a single shot command needing `dev-file`.
@tboerger: The PR is finished and supports now everything I want.
Example: services.keycloak = {
enable = true;
settings.http-port = 8089;
database.type = "dev-file";
realms = {
master = {
path = "./realms/master.json"; # Relative to `DEVENV_ROOT`
export = true;
import = false;
};
test = {
path = "./realms/test.json";
export = true;
};
};
}; @domenkozar : Thanks for a review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked the args of the export command, but does this also include secrets? That would help to have some reproducible setup for the development of apps against keycloak.
|
||
database = { | ||
type = mkOption { | ||
type = types.enum [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it would also work with postgres or mariadb does this enum really make sense? By default it's anyway using a file-based database which should be stored in the devenv state path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so far we only support dev-mem
and dev-file
thats why I only added those, the otherones need more complex setup etc etc. Does that make sense?
Yes that includes secrets and everything. Thats exactly what we want as well, so everything is deterministic if you reimport it. |
keycloak
service.@andrzejressel, @tboerger : I try to continue your effort to make it work.
Notes:
I have a docker-compose file which works so far:
https://gitlab.com/data-custodian/custodian/-/blob/beea86076aef53ea00d7bf2aca7832d237022ac4/deploy/docker/docker-compose.yaml#L352