Skip to content

Commit

Permalink
#43: M1 Mac support
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Apr 6, 2022
1 parent 79aa5ac commit 20383d6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
11 changes: 8 additions & 3 deletions README.md
Expand Up @@ -30,9 +30,9 @@
<img src="https://user-images.githubusercontent.com/6702424/110260457-a1c3d380-7fac-11eb-853a-80459b65626b.png">
</p>

> New in v4.7:
> Register with user profile enabled: Out of the box `options` validator support.
> [Example](https://user-images.githubusercontent.com/6702424/158911163-81e6bbe8-feb0-4dc8-abff-de199d7a678e.mov)
> New with v4.7.2: **M1 Mac** support (for testing locally with a dockerized Keycloak).
> Thanks goes to [@eduardosanzb](https://github.com/InseeFrLab/keycloakify/issues/43#issuecomment-975699658).
> Be aware: When running M1s you are testing with Keycloak v15 else the local container spun will be a Keycloak v16.1.0.
# Motivations

Expand Down Expand Up @@ -478,6 +478,11 @@ and `kcRegisterContext["authorizedMailDomains"]` to validate on.

# Changelog highlights

# v4.7.2

Testing with local Keycloak container working with M1 Mac. Thanks to [@eduardosanzb](https://github.com/InseeFrLab/keycloakify/issues/43#issuecomment-975699658).
Be aware: When running M1s you are testing with Keycloak v15 else the local container spun will be a Keycloak v16.1.0.

# v4.7.0

Register with user profile enabled: Out of the box `options` validator support.
Expand Down
5 changes: 4 additions & 1 deletion src/bin/build-keycloak-theme/build-keycloak-theme.ts
Expand Up @@ -5,6 +5,7 @@ import * as child_process from "child_process";
import { generateDebugFiles, containerLaunchScriptBasename } from "./generateDebugFiles";
import { URL } from "url";
import * as fs from "fs";
import { getIsM1 } from "../tools/isM1";

type ParsedPackageJson = {
name: string;
Expand Down Expand Up @@ -92,7 +93,9 @@ export function main() {
keycloakThemeBuildingDirPath,
themeName,
//We want, however to test in a container running the latest Keycloak version
"keycloakVersion": "16.1.0",
//Except on M1 where we can't use the default image and we only have
//https://github.com/InseeFrLab/keycloakify/issues/43#issuecomment-975699658
"keycloakVersion": getIsM1() ? "15.0.2" : "16.1.0",
});

console.log(
Expand Down
@@ -1,6 +1,7 @@
import * as fs from "fs";
import { join as pathJoin, dirname as pathDirname } from "path";
import type { KeycloakVersion } from "../../KeycloakVersion";
import { getIsM1 } from "../../tools/isM1";

export const containerLaunchScriptBasename = "start_keycloak_testing_container.sh";

Expand All @@ -12,7 +13,11 @@ export function generateDebugFiles(params: { keycloakVersion: KeycloakVersion; t
pathJoin(keycloakThemeBuildingDirPath, "Dockerfile"),
Buffer.from(
[
`FROM jboss/keycloak:${keycloakVersion}`,
`FROM ${
getIsM1()
? "eduardosanzb/keycloak@sha256:b1f5bc674eaff6f4e7b37808b9863440310ff93c282fc9bff812377be48bf519"
: `jboss/keycloak:${keycloakVersion}`
}`,
"",
"USER root",
"",
Expand Down
5 changes: 5 additions & 0 deletions src/bin/tools/isM1.ts
@@ -0,0 +1,5 @@
import * as os from "os";

export function getIsM1() {
return os.cpus()[0].model.includes("Apple M1");
}

0 comments on commit 20383d6

Please sign in to comment.