version: "3"

services:
    keycloak:
        image : quay.io/keycloak/keycloak:26.1
        container_name: keycloak
        environment:
            KEYCLOAK_ADMIN: ${KC_ADMIN}
            KEYCLOAK_ADMIN_PASSWORD: ${KC_ADMIN_PASSWD}
            # Database
            KC_DB: mariadb
            KC_DB_SCHEMA: keycloak
            KC_DB_USERNAME: keycloak
            KC_DB_PASSWORD: ${MARIADB_PASS}
            KC_DB_URL_HOST: mariadb
        volumes:
            - './themes:/opt/keycloak/themes'
        depends_on:
            - mariadb
        restart: ${RESTART}

    mariadb:
        image: mariadb:latest
        container_name: mariadb
        volumes:
            - "./keycloak_db:/var/lib/mysql:rw"
        environment:
            MYSQL_ROOT_PASSWORD: ${MARIADB_PASS}
            MYSQL_DATABASE: keycloak
            MYSQL_USER: keycloak
            MYSQL_PASSWORD: ${MARIADB_PASS}
        restart: ${RESTART}

volumes:
    keycloak_db:
