infrastructure/roles/keycloak/templates/docker-compose.yml

88 lines
2.9 KiB
YAML

{{ 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 <http://www.gnu.org/licenses/>.
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:
- "KC_PROXY=edge"
- "KC_FEATURES=scripts,upload-scripts"
- "KC_HOSTNAME={{ keycloak_domain }}"
- "KC_LOGLEVEL={{ keycloak_log_level }}"
- "KC_DB_URL_HOST=database"
- "KC_DB_USERNAME={{ keycloak_database_user }}"
- "KC_DB_PASSWORD={{ keycloak_database_password }}"
networks:
backend:
{% if proxy_network is defined %}
{{ proxy_network }}:
{% endif %}
command: ["start --auto-build --db=postgres"{% if keycloak_theme_welcome != omit %}, "--spi-theme-welcome-theme={{ keycloak_theme_welcome }}"{% endif %}]
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 %}