`I'm composing docker image for keycloak v12.0.4 using command 'sudo docker-compose -f src/main/docker/keycloak.yml up', but at the time of composing image, I'm getting an error"FATAL [org.keycloak.services] (ServerService Thread Pool -- 70) Error during startup: java.lang.RuntimeException: Failed to connect to database" I'm using postgresql 11.2 docker image. Database name : rsm_dev_db and I have created a schema keycloak inside it.
Keycloak.yml file :
version: '3.3'
services:
keycloak:
image: jboss/keycloak:12.0.4
command:
[
'-b',
'0.0.0.0',
'-Dkeycloak.migration.action=import',
'-Dkeycloak.migration.provider=dir',
'-Dkeycloak.migration.dir=/opt/jboss/keycloak/realm-config',
'-Dkeycloak.migration.strategy=IGNORE_EXISTING',
'-Djboss.socket.binding.port-offset=1000',
'-Dkeycloak.profile.feature.upload_scripts=enabled',
]
volumes:
- ./realm-config:/opt/jboss/keycloak/realm-config
environment:
- KEYCLOAK_USER=admin
- KEYCLOAK_PASSWORD=admin
- DB_VENDOR=postgres
- DB_ADDR=172.17.0.1
- DB_PORT=5432
- DB_DATABASE=rms_dev_db
- DB_USER=kpit
- DB_PASSWORD=kpit1234
- DB_SCHEMA=keycloak
# - JDBC_PARAMS="currentSchema=keycloak"
ports:
- 9080:9080
- 9443:9443
- 10990:10990
application.yml file :
zuul: # those values must be configured depending on the application specific needs
sensitive-headers: Cookie,Set-Cookie #see https://github.com/spring-cloud/spring-cloud-netflix/issues/3126
ignored-headers: Access-Control-Allow-Credentials, Access-Control-Allow-Origin
host:
max-total-connections: 1000
max-per-route-connections: 100
connect-timeout-millis: 10000
socket-timeout-millis: 10000
prefix: /services
semaphore:
max-semaphores: 500
ignoredServices: 'consul,fmpGateway' # Prevent Consul and the "fmpGateway" app itself from having a Zuul route automatically created for them
ribbon:
ReadTimeout: 30000
ConnectTimeout: 30000
# See https://github.com/Netflix/Hystrix/wiki/Configuration
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 125000
management:
endpoints:
web:
base-path: /management
exposure:
include: ['configprops', 'env', 'health', 'info', 'jhimetrics', 'logfile', 'loggers', 'prometheus', 'threaddump']
endpoint:
health:
show-details: when-authorized
roles: 'ROLE_ADMIN'
jhimetrics:
enabled: true
info:
git:
mode: full
health:
mail:
enabled: false # When using the MailService, configure an SMTP server and set this to true
metrics:
export:
# Prometheus is the default metrics backend
prometheus:
enabled: true
step: 60
enable:
http: true
jvm: true
logback: true
process: true
system: true
distribution:
percentiles-histogram:
all: true
percentiles:
all: 0, 0.5, 0.75, 0.95, 0.99, 1.0
tags:
application: ${spring.application.name}
web:
server:
auto-time-requests: true
spring:
application:
name: fmpGateway
cloud:
consul:
discovery:
healthCheckPath: /management/health
instanceId: fmpgateway:${spring.application.instance-id:${random.value}}
service-name: fmpgateway
config:
watch:
enabled: false
jmx:
enabled: false
data:
jpa:
repositories:
bootstrap-mode: deferred
jpa:
open-in-view: false
properties:
hibernate.jdbc.time_zone: UTC
hibernate:
ddl-auto: none
naming:
physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
messages:
basename: i18n/messages
main:
allow-bean-definition-overriding: true
mvc:
favicon:
enabled: false
task:
execution:
thread-name-prefix: fmp-gateway-task-
pool:
core-size: 2
max-size: 50
queue-capacity: 10000
scheduling:
thread-name-prefix: fmp-gateway-scheduling-
pool:
size: 2
thymeleaf:
mode: HTML
output:
ansi:
console-available: true
security:
oauth2:
client:
provider:
oidc:
issuer-uri: http://localhost:9080/auth/realms/jhipster
registration:
oidc:
client-id: web_app
client-secret: web_app
datasource:
hikari:
maximum-pool-size: 5
liquibase:
enabled: true
server:
servlet:
session:
cookie:
http-only: true
# Properties to be exposed on the /info management endpoint
info:
# Comma separated list of profiles that will trigger the ribbon to show
display-ribbon-on-profiles: 'dev'
# ===================================================================
# JHipster specific properties
#
# Full reference is available at: https://www.jhipster.tech/common-application-properties/
# ===================================================================
jhipster:
clientApp:
name: 'fmpGatewayApp'
# By default CORS is disabled. Uncomment to enable.
cors:
allowed-origins: "*"
allowed-methods: "*"
allowed-headers: "*"
exposed-headers: "Authorization,Link,X-Total-Count"
allow-credentials: true
max-age: 1800
mail:
from: fmpGateway@localhost
swagger:
default-include-pattern: /api/.*
title: fmpGateway API
description: fmpGateway API documentation
version: 0.0.1
terms-of-service-url:
contact-name:
contact-url:
contact-email:
license:
license-url:
security:
oauth2:
audience:
- account
- api://default
application-dev.yml file :
logging:
level:
ROOT: ERROR
io.github.jhipster: DEBUG
com.kpit.fmp.gateway: DEBUG
spring:
profiles:
active: dev
include:
- swagger
# Uncomment to activate TLS for the dev profile
#- tls
devtools:
restart:
enabled: true
additional-exclude: static/**
livereload:
enabled: false # we use Webpack dev server + BrowserSync for livereload
jackson:
serialization:
indent-output: true
cloud:
consul:
discovery:
prefer-ip-address: true
host: localhost
port: 8500
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:postgresql://localhost:5432/rms_dev_db?currentSchema=gateway
username: kpit
password: kpit1234
hikari:
poolName: Hikari
auto-commit: false
jpa:
database-platform: io.github.jhipster.domain.util.FixedPostgreSQL10Dialect
show-sql: true
properties:
hibernate.id.new_generator_mappings: true
hibernate.connection.provider_disables_autocommit: true
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: false
hibernate.cache.region.factory_class: com.hazelcast.hibernate.HazelcastCacheRegionFactory
hibernate.cache.hazelcast.instance_name: fmpGateway
hibernate.cache.use_minimal_puts: true
hibernate.cache.hazelcast.use_lite_member: true
liquibase:
# Remove 'faker' if you do not want the sample data to be loaded automatically
contexts: dev #, faker
mail:
host: localhost
port: 25
username:
password:
messages:
cache-duration: PT1S # 1 second, see the ISO 8601 standard
thymeleaf:
cache: false
sleuth:
sampler:
probability: 1 # report 100% of traces
zipkin: # Use the "zipkin" Maven profile to have the Spring Cloud Zipkin dependencies
base-url: http://localhost:9411
enabled: false
locator:
discovery:
enabled: false
server:
port: 8080
# ===================================================================
# JHipster specific properties
#
# Full reference is available at: https://www.jhipster.tech/common-application-properties/
# ===================================================================
jhipster:
gateway:
rate-limiting:
enabled: false
limit: 100000
duration-in-seconds: 3600
authorized-microservices-endpoints: # Access Control Policy, if left empty for a route, all endpoints will be accessible
app1: /api,/v2/api-docs # recommended dev configuration
cache: # Cache configuration
hazelcast: # Hazelcast distributed cache
time-to-live-seconds: 3600
backup-count: 1
management-center: # Full reference is available at: http://docs.hazelcast.org/docs/management-center/3.9/manual/html/Deploying_and_Starting.html
enabled: false
update-interval: 3
url: http://localhost:8180/hazelcast-mancenter
# CORS is only enabled by default with the "dev" profile, so BrowserSync can access the API
cors:
allowed-origins: "*"
allowed-methods: "*"
allowed-headers: "*"
exposed-headers: "Authorization,Link,X-Total-Count"
allow-credentials: true
max-age: 1800
mail: # specific JHipster mail property, for standard properties see MailProperties
base-url: http://127.0.0.1:8080
metrics:
logs: # Reports metrics in the logs
enabled: false
report-frequency: 60 # in seconds
logging:
use-json-format: false # By default, logs are not in Json format
logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
enabled: false
host: localhost
port: 5000
queue-size: 512
audit-events:
retention-period: 30 # Number of days before audit events are deleted.
I started postgres container before composing keycloak image but still getting an error.`