Skip to content

Commit

Permalink
✨ Package Keylock custom data (AOT-Technologies#2104)
Browse files Browse the repository at this point in the history
* FWF:3372 [feature] Added base code

* FWF:3372 [feature] Modified start-sh file
  • Loading branch information
shuhaib-aot authored Jun 13, 2024
1 parent dbe18b4 commit a0c29f7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 29 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/forms-flow-idm.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push Forms flow idm package to registry
name: Push keycloak-customizations to registry

on:
workflow_dispatch:
Expand All @@ -20,37 +20,41 @@ jobs:
strategy:
matrix:
include:
- image: formsflow/forms-flow-idm-package
- image: formsflow/keycloak-customizations
context: forms-flow-idm/keycloak
dockerfile: Dockerfile
name: forms-flow-idm-package
name: keycloak-customizations
permissions:
contents: read
packages: write
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
- name: Set version

- name: Set version for non-master branches
if: ${{ github.ref != 'refs/heads/master' }}
working-directory: .
run: |
VER=$(cat VERSION)
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Set version
- name: Set version for master branch
if: ${{ github.ref == 'refs/heads/master' }}
working-directory: .
run: |
VER=$(cat VERSION)
VER=${VER/-alpha/''}
echo "VERSION=$VER" >> $GITHUB_ENV
- run: echo ${{ env.VERSION }}
- name: Output version
run: echo ${{ env.VERSION }}

- name: Docker meta
id: meta
Expand All @@ -62,7 +66,6 @@ jobs:
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
# registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

Expand All @@ -73,7 +76,8 @@ jobs:
key: ${{ runner.os }}-buildx-${{ matrix.name }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.name }}
- name: Build and push Docker image
- name: Build and push Docker image for non-master branches
if: ${{ github.ref != 'refs/heads/master' }}
uses: docker/build-push-action@v4
with:
Expand All @@ -83,14 +87,14 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push Docker image
- name: Build and push Docker image for master branch
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v4
with:
context: forms-flow-idm/keycloak
platforms: linux/amd64,linux/arm64/v8
push: true
tags: ${{ steps.meta.outputs.tags }}, formsflow/forms-flow-idm-package:latest
tags: ${{ steps.meta.outputs.tags }}, formsflow/keycloak-customizations:latest
labels: ${{ steps.meta.outputs.labels }}

- name: Scan Docker image 🐳
Expand All @@ -102,8 +106,7 @@ jobs:
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

- name: Upload Snyk report as sarif 📦
- name: Upload Snyk report as SARIF 📦
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: snyk.sarif

26 changes: 17 additions & 9 deletions forms-flow-idm/keycloak/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
FROM formsflow/forms-flow-idm-theme:v7.0

RUN mkdir -p /opt/bitnami/keycloak/themes/formsflow
# Remove any existing theme files
RUN rm -rf /opt/bitnami/keycloak/themes/formsflow/*
# Copy the new theme files
COPY themes/formsflow /opt/bitnami/keycloak/themes/formsflow
# Copy the import files
COPY imports /opt/bitnami/keycloak/data/import
# FROM maven:3.8.6-jdk-11 AS builder

# WORKDIR /build

# COPY idp-selector/pom.xml idp-selector/
# COPY idp-selector/src idp-selector/src/

# RUN mvn -f idp-selector/pom.xml clean package

FROM alpine:latest

WORKDIR /custom

# COPY --from=builder /build/idp-selector/target/*.jar /custom/providers/
COPY ./themes /custom/themes
COPY ./imports /custom/imports
COPY ./start-keycloak.sh /custom/start-keycloak.sh
26 changes: 18 additions & 8 deletions forms-flow-idm/keycloak/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: "3.7"

volumes:
postgres:
keycloak_custom_data:

networks:
keycloak-server-network:
Expand All @@ -29,26 +30,35 @@ services:
restart: unless-stopped
container_name: keycloak
volumes:
- ./imports:/opt/keycloak/data/import
- ./themes/formsflow:/opt/keycloak/themes/formsflow
- ./start-keycloak.sh:/opt/keycloak/bin/start-keycloak.sh
entrypoint: ["/bin/bash", "/opt/keycloak/bin/start-keycloak.sh"]
- keycloak_custom_data:/keycloak_custom_data
entrypoint: ["/bin/bash", "-c", "/keycloak_custom_data/start-keycloak.sh"]
environment:
- DB_VENDOR=POSTGRES
- DB_ADDR=keycloak-db
- DB_PORT=5432
- DB_DATABASE=${KEYCLOAK_JDBC_DB:-keycloak}
- DB_USER=${KEYCLOAK_JDBC_USER-admin}
- DB_USER=${KEYCLOAK_JDBC_USER:-admin}
- DB_PASSWORD=${KEYCLOAK_JDBC_PASSWORD:-changeme}
- KEYCLOAK_ADMIN=${KEYCLOAK_ADMIN_USER:-admin}
- KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD:-changeme}
- KEYCLOAK_START_MODE=${KEYCLOAK_START_MODE:-start-dev}
- KEYCLOAK_HTTP_PATH=${KEYCLOAK_HTTP_PATH:-/auth}

ports:
- "8080:8080"
links:
depends_on:
- keycloak-db
- keycloak-customizations
networks:
- keycloak-server-network


keycloak-customizations:
build:
context: .
dockerfile: Dockerfile
volumes:
- keycloak_custom_data:/custom
command: /bin/sh
tty: true
stdin_open: true
networks:
- keycloak-server-network
8 changes: 8 additions & 0 deletions forms-flow-idm/keycloak/start-keycloak.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#!/bin/bash
# Ensure the directories exist
mkdir -p /opt/keycloak/themes
mkdir -p /opt/keycloak/data/import

# Copy custom themes and imports

cp -rf /keycloak_custom_data/themes/* /opt/keycloak/themes/
cp -rf /keycloak_custom_data/imports/* /opt/keycloak/data/import/

# Default values if the variables are not set
START_MODE=${KEYCLOAK_START_MODE:-"start"}
Expand Down

0 comments on commit a0c29f7

Please sign in to comment.