---
version: "2"
services:
  keycloakstack:
    image: jboss/keycloak
    container_name: keycloak
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - DB_VENDOR=POSTGRES
      - DB_ADDR=keycloak_db
      - DB_DATABASE=keycloak
      - DB_USER=keycloak
      - DB_SCHEMA=public
      - DB_PASSWORD=${POSTGRES_PASSWORD}
      - KEYCLOAK_USER=admin
      - KEYCLOAK_PASSWORD=${KEYCLOAK_PASSWORD}
      - PROXY_ADDRESS_FORWARDING=true
    ports:
      - ${PORT}:8080
    restart: unless-stopped
    depends_on:
      - keycloak_db
  keycloak_db:
    image: postgres:13
    container_name: keycloak_db
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - POSTGRES_DB=keycloak
      - POSTGRES_USER=keycloak
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    volumes:
      - /portainer/Files/AppData/keycloakstack/DB:/var/lib/postgresql/data:Z
    restart: unless-stopped
