{{ ansible_managed | comment }} # Infrastructure # Ansible instructions to deploy the infrastructure # Copyright (C) 2019-2020 Christoph (Sheogorath) Kern # Copyright (C) 2020 Saibotk # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . version: '2' services: keycloak: image: {{ keycloak_baseimage }}:{{ keycloak_image_version }} mem_limit: 1gb memswap_limit: 1280mb security_opt: - no-new-privileges labels: - "traefik.http.routers.keycloak.rule=Host(`{{ keycloak_domain }}`) && PathPrefix(`/`)" - "traefik.http.routers.keycloak.entrypoints=websecure" - "traefik.http.routers.keycloak.tls=true" - "traefik.http.routers.keycloak.tls.certresolver={{ keycloak_traefik_certresolver }}" - "traefik.http.routers.keycloak.middlewares=keycloak,compress" - "traefik.http.middlewares.keycloak.headers.sslredirect=true" - "traefik.http.middlewares.keycloak.headers.stsSeconds=63072000" - "traefik.enable=true" {% if proxy_network is defined %} - "traefik.docker.network={{ proxy_network }}" {% endif %} environment: - "PROXY_ADDRESS_FORWARDING=true" - "KEYCLOAK_HOSTNAME={{ keycloak_domain }}" - "KEYCLOAK_LOGLEVEL={{ keycloak_log_level }}" - "ROOT_LOGLEVEL={{ keycloak_root_log_level }}" {% if keycloak_theme_welcome is defined %} - "KEYCLOAK_WELCOME_THEME={{ keycloak_theme_welcome }}" {% endif %} - "DB_VENDOR=postgres" - "DB_ADDR=database" - "DB_USER={{ keycloak_database_user }}" - "DB_PASSWORD={{ keycloak_database_password }}" networks: backend: {% if proxy_network is defined %} {{ proxy_network }}: {% endif %} command: ["-b", "0.0.0.0", "-Dkeycloak.profile.feature.scripts=enabled", "-Dkeycloak.profile.feature.upload_scripts=enabled"] restart: always database: image: docker.io/library/postgres:{{ keycloak_postgres_image_version }} mem_limit: 256mb memswap_limit: 512mb read_only: true {% if keycloak_postgres_selinux_level != omit %} security_opt: - label=level:{{ keycloak_postgres_selinux_level }} {% endif %} tmpfs: - /run/postgresql:size=512K - /tmp:size=128K stop_grace_period: 2m stop_signal: SIGINT environment: - POSTGRES_USER={{ keycloak_database_user }} - POSTGRES_PASSWORD={{ keycloak_database_password }} volumes: - ./database:/var/lib/postgresql/data networks: backend: restart: always networks: backend: internal: true {% if proxy_network is defined %} {{ proxy_network }}: external: true {% endif %}