Skip to content

Commit

Permalink
Build and push docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 committed Aug 24, 2024
1 parent c6d5bd8 commit 79df3ea
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
40 changes: 39 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,45 @@ jobs:
version: 9
- run: pnpm install
- run: pnpm run build-keycloak-theme


docker_build:
name: Build Docker image
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
needs: test
env:
KEYCLOAK_VERSION: 25.0.4
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

# Build and push the container to the GitHub Container
# Repository. The container will be tagged as "latest"
# and with the short SHA of the commit.
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
cache-from: type=registry,ref=ghcr.io/owl-corp/keycloak:latest
cache-to: type=inline
tags: |
ghcr.io/owl-corp/keycloak:latest
ghcr.io/owl-corp/keycloak:${{ env.KEYCLOAK_VERSION }}
build-args: |
KEYCLOAK_VERSION=${{ env.KEYCLOAK_VERSION }}
check_if_version_upgraded:
name: Check if version upgrade
Expand All @@ -35,7 +74,6 @@ jobs:
with:
action_name: is_package_json_version_upgraded
branch: ${{ github.head_ref || github.ref }}

create_github_release:
runs-on: ubuntu-latest
needs: check_if_version_upgraded
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:20 as keycloakify_jar_builder
RUN apt-get update && \
apt-get install -y openjdk-17-jdk && \
apt-get install -y maven;
COPY ./keycloakify-starter/package.json ./keycloakify-starter/pnpm-lock.yaml /opt/app/
WORKDIR /opt/app
RUN pnpm install
COPY ./keycloakify-starter/ /opt/app/
RUN pnpm run build

ARG KEYCLOAK_VERSION=25.0.4
FROM quay.io/keycloak/keycloak:${KEYCLOAK_VERSION} as builder
WORKDIR /opt/keycloak
COPY --from=keycloakify_jar_builder /opt/app/dist_keycloak/keycloak-theme-for-kc-22-and-above.jar /opt/keycloak/providers/
RUN /opt/keycloak/bin/kc.sh build

FROM quay.io/keycloak/keycloak:${KEYCLOAK_VERSION}
COPY --from=builder /opt/keycloak/ /opt/keycloak/

ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start", "--optimized"]

0 comments on commit 79df3ea

Please sign in to comment.