Skip to content
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

Pipeline for releasing Docker init container #116

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
54 changes: 54 additions & 0 deletions .github/workflows/release-github-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish package as Github release & Docker init container

on:
release:
types: [created]

jobs:
release-github-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'

- name: Build a project & run unit tests
run: ./gradlew test

- name: Get the tag name
run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV

- name: Set version from git tag
run: ./gradlew jar -P version=${{ env.TAG }}

- name: Add jar to Github release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/libs/keycloak-metrics-spi-${{ env.TAG }}.jar
asset_name: keycloak-metrics-spi-${{ env.TAG }}.jar
tag: ${{ github.ref }}

- name: Build Docker init container
run: |
docker build \
--build-arg VERSION=${{ env.TAG }} \
-f src/main/docker/initContainer.Dockerfile \
-t aerogear/keycloak-metrics-spi:${{ env.TAG }} \
-t aerogear/keycloak-metrics-spi:latest \
.

- name: Log into Docker Hub
uses: docker/login-action@v2
with:
username: aerogear
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Push tagged Docker image
run: docker push aerogear/keycloak-metrics-spi:${{ env.TAG }}

- name: Push latest Docker image
run: docker push aerogear/keycloak-metrics-spi:latest
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,35 @@ touch keycloak-metrics-spi-2.0.2.jar.dodeploy
```
- Restart the keycloak service.

#### Using Docker init container
If you are running Keycloak using Helm charts, here is a ready init container build on busybox. Provider jar file is placed in `/keycloak-metrics-spi` directory, so
according to official Keycloak [example](https://github.com/codecentric/helm-charts/blob/master/charts/keycloak/README.md#providing-a-custom-theme),
your Helm chart could look like following:
```yaml
extraInitContainers: |
- name: keycloak-metrics-spi
image: aerogear/keycloak-metrics-spi:latest
imagePullPolicy: IfNotPresent
command:
- sh
args:
- -c
- |
echo "Copying keycloak-metrics-spi..."
cp -R /keycloak-metrics-spi/*.jar /keycloak-metrics-spi
volumeMounts:
- name: keycloak-metrics-spi
mountPath: /keycloak-metrics-spi

extraVolumeMounts: |
- name: keycloak-metrics-spi
mountPath: /opt/jboss/keycloak/standalone/deployments

extraVolumes: |
- name: keycloak-metrics-spi
emptyDir: {}
```

### On Keycloak Quarkus Distribution

> We assume the home of keycloak is on the default `/opt/keycloak`
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ configurations {
}

group 'org.jboss.aerogear'
version '4.0.1-SNAPSHOT'

apply plugin: 'java'

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
version=4.0.1-SNAPSHOT
keycloakVersion=22.0.0
prometheusVersion=0.16.0
5 changes: 5 additions & 0 deletions src/main/docker/initContainer.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM busybox

ARG VERSION

COPY build/libs/keycloak-metrics-spi-${VERSION}.jar /keycloak-metrics-spi/