Created
December 16, 2019 16:32
-
-
Save ERRECabrera/a4fb1ebdba300521b46587881b66aaf4 to your computer and use it in GitHub Desktop.
Template creates a volume for PostgreSQL and boots up Keycloak connected to it. Traefik is used like load balancer to redirect all request to diferent container instances. The most important change is the JGroups Discovery protocol that is used in this configuration, which is `JDBC_PING`. `JDBC_PING` reuses the same database instance as all Keyc…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
volumes: | |
postgres_data: | |
driver: local | |
services: | |
postgres: | |
image: 'postgres:alpine' | |
volumes: | |
- ./postgres:/var/lib/postgresql/data | |
restart: 'always' | |
# ports: | |
# - 5432:5432 | |
environment: | |
POSTGRES_USER: keycloak | |
POSTGRES_PASSWORD: password | |
POSTGRES_DB: keycloak | |
POSTGRES_HOST: postgres | |
traefik: | |
image: library/traefik:alpine | |
container_name: traefik | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
command: > | |
--logLevel=ERROR | |
--api.dashboard | |
--docker | |
--entrypoints="Name:http Address::80" | |
--defaultentrypoints="http" | |
ports: | |
- 80:80 | |
- 3000:8080 | |
keycloak: | |
image: jboss/keycloak | |
environment: | |
DB_VENDOR: postgres | |
DB_ADDR: postgres | |
DB_PORT: 5432 | |
DB_DATABASE: keycloak | |
DB_USER: keycloak | |
DB_PASSWORD: password | |
KEYCLOAK_USER: admin | |
KEYCLOAK_PASSWORD: Pa55w0rd | |
# KEYCLOAK_LOGLEVEL: DEBUG | |
JGROUPS_DISCOVERY_PROTOCOL: JDBC_PING | |
JGROUPS_DISCOVERY_PROPERTIES: datasource_jndi_name=java:jboss/datasources/KeycloakDS,info_writer_sleep_time=500,initialize_sql="CREATE TABLE IF NOT EXISTS JGROUPSPING ( own_addr varchar(200) NOT NULL, cluster_name varchar(200) NOT NULL, created timestamp default current_timestamp, ping_data BYTEA, constraint PK_JGROUPSPING PRIMARY KEY (own_addr, cluster_name))" | |
depends_on: | |
- postgres | |
labels: | |
traefik.enable: true | |
traefik.port: 8080 | |
traefik.protocol: http | |
traefik.frontend.rule: Host:localhost | |
traefik.frontend.passHostHeader: true | |
# traefik.backend.loadbalancer.stickiness: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment