Skip to content

Commit

Permalink
Specify Keycloak Config CLI version via env
Browse files Browse the repository at this point in the history
  • Loading branch information
alukach committed Jan 23, 2025
1 parent dce71ba commit d9c06c1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion config/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM adorsys/keycloak-config-cli:latest
ARG KEYCLOAK_CONFIG_CLI_VERSION
FROM adorsys/keycloak-config-cli:${KEYCLOAK_CONFIG_CLI_VERSION}

# Copy the config directory into the image
COPY src/ /config/
2 changes: 2 additions & 0 deletions deploy/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const {
HOSTNAME,
STAGE = "dev",
KEYCLOAK_VERSION = "26.0.5",
KEYCLOAK_CONFIG_CLI_VERSION = "6.2.1",
CONFIG_DIR = join(__dirname, "..", "config"),
} = process.env;

Expand Down Expand Up @@ -58,6 +59,7 @@ new KeycloakStack(app, `veda-keycloak-${STAGE}`, {
sslCertificateArn: SSL_CERTIFICATE_ARN,
hostname: HOSTNAME,
keycloakVersion: KEYCLOAK_VERSION,
keycloakConfigCliVersion: KEYCLOAK_CONFIG_CLI_VERSION,
configDir: CONFIG_DIR,
idpOauthClientSecrets,
privateOauthClients,
Expand Down
21 changes: 11 additions & 10 deletions deploy/lib/KeycloakConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface KeycloakConfigConstructProps {
configDir: string;
idpOauthClientSecrets: Record<string, string>;
privateOauthClients: Array<{ id: string; realm: string }>;
version: string;
}

type clientSecretTuple = Array<[string, secretsManager.ISecret]>;
Expand All @@ -26,15 +27,6 @@ export class KeycloakConfig extends Construct {
) {
super(scope, id);

const configTaskDef = new ecs.FargateTaskDefinition(this, "ConfigTaskDef", {
cpu: 256,
memoryLimitMiB: 512,
});

const assetImage = ecs.ContainerImage.fromAsset(props.configDir, {
platform: ecrAssets.Platform.LINUX_AMD64,
});

// Create a client secret for each private client
const createdClientSecrets: clientSecretTuple =
props.privateOauthClients.map(({ id: clientSlug, realm }) => [
Expand Down Expand Up @@ -81,8 +73,17 @@ export class KeycloakConfig extends Construct {
)
);

const configTaskDef = new ecs.FargateTaskDefinition(this, "ConfigTaskDef", {
cpu: 256,
memoryLimitMiB: 512,
});
configTaskDef.addContainer("ConfigContainer", {
image: assetImage,
image: ecs.ContainerImage.fromAsset(props.configDir, {
platform: ecrAssets.Platform.LINUX_AMD64,
buildArgs: {
KEYCLOAK_CONFIG_CLI_VERSION: props.version,
},
}),
environment: {
KEYCLOAK_URL: props.hostname,
KEYCLOAK_AVAILABILITYCHECK_ENABLED: "true",
Expand Down
2 changes: 2 additions & 0 deletions deploy/lib/KeycloakStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface StackInputProps {
hostname: string;
sslCertificateArn: string;
keycloakVersion: string;
keycloakConfigCliVersion: string;
configDir: string;
idpOauthClientSecrets: Record<string, string>;
privateOauthClients: Array<{ id: string; realm: string }>;
Expand Down Expand Up @@ -51,6 +52,7 @@ export class KeycloakStack extends cdk.Stack {
configDir: props.configDir,
idpOauthClientSecrets: props.idpOauthClientSecrets,
privateOauthClients: props.privateOauthClients,
version: props.keycloakConfigCliVersion,
});

new KeycloakUrl(this, "url", {
Expand Down

0 comments on commit d9c06c1

Please sign in to comment.