Skip to content

Commit

Permalink
add docker compose for keycloak
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamv108 committed Dec 4, 2023
1 parent bc33383 commit d5efcae
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 18 deletions.
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ SHELL := /bin/bash
OS := $(shell uname)

define start-services
@docker-compose -f compose.yaml up --force-recreate -d --remove-orphans sonar fluentbit mysql kafka kafdrop elasticsearch prometheus grafana telegraf influxdb
@docker compose -f compose.yaml up --force-recreate -d --remove-orphans sonar fluentbit db kafka kafdrop elasticsearch prometheus grafana telegraf influxdb keycloak
endef

define check
@docker-compose -f sonar-compose.yaml up --force-recreate -d --remove-orphans sonar-db sonar
@docker compose -f sonar-compose.yaml up --force-recreate -d --remove-orphans sonar-db sonar
endef

define start-app
@docker-compose -f compose.yaml up -d app
@docker compose -f compose.yaml up -d app
endef

define teardown
@docker-compose -f compose.yaml rm -f -v -s
@docker compose -f compose.yaml rm -f -v -s
@docker system prune -f --volumes
endef

define check-teardown
@docker-compose -f sonar-compose.yaml rm -f -v -s
@docker compose -f sonar-compose.yaml rm -f -v -s
@docker system prune -f --volumes
endef

Expand All @@ -32,7 +32,7 @@ define local-app
endef

define setup
@docker-compose -f compose.yaml up -d --build --force-recreate --remove-orphans
@docker compose -f compose.yaml up -d --build --force-recreate --remove-orphans
endef

define k8s-apply
Expand Down Expand Up @@ -153,3 +153,6 @@ coverage:

tests:
sudo ./gradlew test

# condb:
# mysql -h 127.0.0.1 -P 3306 -u test template-service-java-springboot -p
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
mavenCentral()
// maven {
// url "http://127.0.0.1:8081/artifactory/libs-release"
// allowInsecureProtocol = true
// allowInsecureProtocol true
// }
}
dependencies {
Expand Down Expand Up @@ -42,7 +42,7 @@ repositories {
mavenCentral()
// maven {
// url "http://127.0.0.1:8081/artifactory/libs-release"
// allowInsecureProtocol = true
// allowInsecureProtocol true
// }
}

Expand Down
108 changes: 98 additions & 10 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.3"
version: "3.8"

services:
app:
Expand All @@ -22,7 +22,7 @@ services:

depends_on:
- fluentbit
- mysql
- db
- kafka
- elasticsearch
- prometheus
Expand All @@ -36,18 +36,19 @@ services:

environment:
- SLEEP_LENGTH=5
- spring.datasource.url=jdbc:mysql://mysql:3306/template-service-java-springboot?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false&autoReconnect=true&allowPublicKeyRetrieval=true&createDatabaseIfNotExist=true
- spring.datasource.url=jdbc:mysql://db:3306/template-service-java-springboot?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false&autoReconnect=true&allowPublicKeyRetrieval=true&createDatabaseIfNotExist=true
- spring.datasource.username=test
- spring.datasource.password=root1234
- spring.kafka.bootstrap-servers=kafka:9092

sonar:
image: sonarqube:7.9.5-community
container_name: sonar
depends_on:
- sonar-db
- init
environment:
SONAR_JDBC_URL: jdbc:postgresql://sonar-db:5432/sonar
SONAR_JDBC_URL: jdbc:postgresql://sonar-db:5433/sonar
SONAR_JDBC_USERNAME: sonartest
SONAR_JDBC_PASSWORD: sonartest
sonar.web.port: 9000
Expand All @@ -65,23 +66,28 @@ services:
- "9017:9000"
init:
image: bash
container_name: init
privileged: true
user: root
volumes:
- ./sonarqube/init.sh:/mnt/init.sh
command: [ "sh", "-e", "/mnt/init.sh" ]

sonar-db:
image: postgres:12
image: postgres:14.4
container_name: sonar-db
environment:
POSTGRES_USER: sonartest
POSTGRES_PASSWORD: sonartest
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
- sonar_postgresql:/var/lib/postgresql
- sonar_postgresql_data:/var/lib/postgresql/data
ports:
- '5433:5432'

fluentbit:
image: 'shubham01/template-service-java-springboot-fluentbit:latest'
container_name: fluentbit
hostname: fluentbit
ports:
- "24224:24224"
Expand All @@ -91,8 +97,9 @@ services:
- ./fluentbit/parsers.conf:/fluent-bit/etc/parsers.conf
- ./log/:/etc/data

mysql:
db:
image: 'mysql:latest'
container_name: db
environment:
- 'MYSQL_DATABASE=template-service-java-springboot'
- 'MYSQL_PASSWORD=root1234'
Expand All @@ -101,7 +108,83 @@ services:
ports:
- '3306:3306'

keycloak:
image: 'keycloak/keycloak:22.0'
container_name: keycloak
command: [ 'start-dev' ]
depends_on:
- keycloak-db
environment:
JAVA_OPTS_APPEND: -Dkeycloak.profile.feature.upload_scripts=enabled
TZ: '...'
DB: postgres
DB_URL: jdbc:postgresql://keycloak-db:5432/keycloak?user=postgres
DB_PASSWORD: postgres
LOG_LEVEL: warn
HOSTNAME: localhost
# KC_HOSTNAME: localhost
KC_HOSTNAME_PORT: 8180
KC_HOSTNAME_URL: http://127.0.0.1:8180
KEYCLOAK_USER: admin
KEYCLOAK_PASSWORD: password
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://keycloak-db:5432/keycloak?user=postgres
KC_DB_USERNAME: postgres
KC_DB_PASSWORD: postgres
KC_DB_ADDR: localhost
KC_DB_DATABASE: keycloak
KC_HEALTH_ENABLED: 'true'
KC_HTTP_ENABLED: 'true'
KC_METRICS_ENABLED: 'true'
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: password
KC_LOG_LEVEL: info
ports:
- "8180:8080"
- "8787:8787" # debug port
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:8080/health/ready" ]
interval: 15s
timeout: 2s
retries: 15
# networks:
# - local

pgadmin:
container_name: pgadmin
image: "dpage/pgadmin4:5.1"
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: postgres
ports:
- "5050:80"
# networks:
# - local

keycloak-db:
container_name: keycloak-db
image: "postgres:14.4"
healthcheck:
test: [ "CMD", "pg_isready", "-q", "-d", "postgres", "-U", "root" ]
timeout: 45s
interval: 10s
retries: 10
volumes:
- keycloak_postgresql:/var/lib/postgresql
- keycloak_postgresql_data:/var/lib/postgresql/data
# - ./sql:/docker-entrypoint-initdb.d/:ro # turn it on, if you need run init DB
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: keycloak
POSTGRES_HOST: postgres
# networks:
# - local
ports:
- "5432:5432"

zookeeper:
container_name: zookeeper
image: confluentinc/cp-zookeeper:latest
environment:
ZOOKEEPER_CLIENT_PORT: 2181
Expand All @@ -110,6 +193,7 @@ services:
- 22181:2181

kafka:
container_name: kafka
image: confluentinc/cp-kafka:latest
depends_on:
- zookeeper
Expand All @@ -125,6 +209,7 @@ services:
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

kafdrop:
container_name: kafdrop
image: obsidiandynamics/kafdrop
restart: "no"
ports:
Expand All @@ -136,6 +221,7 @@ services:
- "kafka"

elasticsearch:
container_name: elasticsearch
image: elasticsearch:8.9.1
ports:
- "9200:9200"
Expand Down Expand Up @@ -205,8 +291,10 @@ volumes:
sonarqube_extensions:
sonarqube_logs:
sonarqube_temp:
postgresql:
postgresql_data:
sonar_postgresql:
sonar_postgresql_data:
keycloak_postgresql:
keycloak_postgresql_data:

networks:
template-service-java-springboot:
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
artifactory_user=admin
artifactory_password=password
artifactory_url=http://localhost:8081/artifactory
org.gradle.caching=true
gradle.cache.push=false

0 comments on commit d5efcae

Please sign in to comment.