#43: M1 Mac support

This commit is contained in:
garronej 2022-04-07 01:35:19 +02:00
parent 79aa5ac5f2
commit 20383d60a9
4 changed files with 23 additions and 5 deletions

View File

@ -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
@ -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.

View File

@ -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;
@ -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(

View File

@ -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";
@ -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",
"",

5
src/bin/tools/isM1.ts Normal file
View File

@ -0,0 +1,5 @@
import * as os from "os";
export function getIsM1() {
return os.cpus()[0].model.includes("Apple M1");
}