feat(keycloak): allow importing providers and providing build flags to kc.sh build

This commit is contained in:
Johanna Dorothea Reichmann 2023-03-25 18:18:40 +01:00
parent 8c280b08ec
commit bd771d7edd
Signed by: transcaffeine
GPG key ID: 03624C433676E465
3 changed files with 25 additions and 2 deletions

View file

@ -8,6 +8,9 @@ keycloak_container_image_name: "keycloak:{{ keycloak_version }}-custom"
keycloak_container_database_vendor: postgres
keycloak_container_build_directory: /opt/keycloak/build
keycloak_container_build_jar_directory: providers
keycloak_container_build_flags: {}
keycloak_provider_jars_directory: "{{ keycloak_container_build_directory }}/{{ keycloak_container_build_jar_directory }}"
keycloak_database_hostname: localhost
keycloak_database_port: 5432

View file

@ -7,11 +7,18 @@
recurse: yes
mode: 0700
- name: Ensure provider jars directory exists
file:
name: "{{ keycloak_provider_jars_directory }}"
state: directory
mode: 0775
- name: Ensure Dockerfile is templated
template:
src: Dockerfile.j2
dest: "{{ keycloak_container_build_directory }}/Dockerfile"
mode: 0640
mode: 0700
register: keycloak_buildfile_info
- name: Ensure Keycloak container image is present
docker_image:
@ -46,3 +53,5 @@
--db-password {{ keycloak_database_password }}
--db-url jdbc:postgresql://{{ keycloak_database_hostname }}:{{ keycloak_database_port }}/{{ keycloak_database_database }}
--optimized
tags:
- keycloak-container

View file

@ -9,7 +9,18 @@ ARG DB_VENDOR
ENV KC_DB=$DB_VENDOR
WORKDIR {{ keycloak_container_working_directory }}
RUN {{ keycloak_container_working_directory }}/bin/kc.sh build
ADD ./providers/* providers/
# Workaround to set correct mode on jar files
USER root
RUN chmod -R 0770 providers/*
USER keycloak
RUN {{ keycloak_container_working_directory }}/bin/kc.sh --verbose \
{% for argument in keycloak_container_build_flags | dict2items(key_name='flag', value_name='value') %}
--{{- argument['flag'] -}}{{- argument['value'] | default(false, true) | ternary('=' + argument['value'], '') }} \
{% endfor%}
build
FROM {{ keycloak_container_upstream_image_name }}:{{ keycloak_version }}