Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incubator-kie-issues#1483: Create a common Kie Flyway initializer for Kie Modules #2014

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ echo "Kogito Image version: ${KOGITO_VERSION}"
echo "KOGITO_VERSION=${KOGITO_VERSION}" > ".env"
echo "COMPOSE_PROFILES='${PROFILE}'" >> ".env"

if [ "$(uname)" == "Darwin" ]; then
if [ "$(uname)" = "Darwin" ]; then
echo "DOCKER_GATEWAY_HOST=kubernetes.docker.internal" >> ".env"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
elif [ "$(expr substr $(uname -s) 1 5)" = "Linux" ]; then
echo "DOCKER_GATEWAY_HOST=172.17.0.1" >> ".env"
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ kogito.dataindex.http.url=http://localhost:8080
kogito.dataindex.ws.url=ws://localhost:8080

# run create tables scripts
quarkus.flyway.migrate-at-start=true
quarkus.flyway.baseline-on-migrate=true
quarkus.flyway.baseline-version=0.0
quarkus.flyway.locations=classpath:/db/migration,classpath:/db/jobs-service,classpath:/db/data-audit/postgresql
quarkus.flyway.table=FLYWAY_RUNTIME_SERVICE
kie.flyway.enabled=true

kogito.persistence.type=jdbc
quarkus.datasource.db-kind=postgresql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,47 @@ version: "3"

services:
postgres-compose:
image: postgres:13.4-alpine3.14
image: postgres:16.1-alpine3.19
container_name: postgres
environment:
POSTGRES_PASSWORD: pass
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
volumes:
- ./sql:/docker-entrypoint-initdb.d/
healthcheck:
test: [ "CMD", "pg_isready", "-q", "-d", "kogito", "-U", "kogito-user" ]
timeout: 45s
interval: 10s
retries: 50
networks:
- postgres-compose-network
container_name: postgres-container

pgadmin-compose:
image: dpage/pgadmin4:5.0
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: pass
image: dpage/pgadmin4:8.2
container_name: pgadmin
ports:
- 8055:80
depends_on:
- postgres-compose
volumes:
- ./pgadmin/servers.json:/pgadmin4/servers.json
- ./pgadmin/pgpass:/pgadmin4/pgpass
entrypoint: >
/bin/sh -c "
cp -f /pgadmin4/pgpass /var/lib/pgadmin/;
chmod 600 /var/lib/pgadmin/pgpass;
/entrypoint.sh
"
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: pass
PGADMIN_CONFIG_SERVER_MODE: "False"
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "False"
GUNICORN_ACCESS_LOGFILE: "/dev/null"
networks:
- postgres-compose-network
container_name: pgadmin-container

networks:
postgres-compose-network:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
postgres:5432:kogito:kogito-user:kogito-pass
postgres:5432:postgres:kogito-user:kogito-pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Servers": {
"1": {
"Name": "kogito",
"Group": "Servers",
"Host": "postgres",
"Port": 5432,
"MaintenanceDB": "kogito",
"Username": "kogito-user",
"SSLMode": "disable",
"PassFile": "/var/lib/pgadmin/pgpass"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CREATE ROLE "kogito-user" WITH
CREATEDB
CREATEROLE
NOREPLICATION
ENCRYPTED PASSWORD 'md54adb613a8ffdd707e032c918d791e2e5';
PASSWORD 'kogito-pass';

CREATE DATABASE kogito
WITH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ quarkus.datasource.db-kind=postgresql
%prod.quarkus.datasource.username=kogito-user
%prod.quarkus.datasource.password=kogito-pass
%prod.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/kogito
quarkus.flyway.migrate-at-start=true

kie.flyway.enabled=true

%dev.quarkus.kogito.devservices.enabled=false
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@

import io.quarkus.test.junit.QuarkusTest;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import jakarta.inject.Inject;
import jakarta.inject.Named;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@QuarkusTest
public class ApprovalsProcessTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
# under the License.
#

version: '2.1'
version: '3'

services:
postgres:
image: postgres:13.4-alpine3.14
image: postgres:16.1-alpine3.19
ports:
- "5432:5432"
volumes:
Expand All @@ -32,19 +32,30 @@ services:
interval: 10s
retries: 50
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres

pgadmin-compose:
image: dpage/pgadmin4:5.0
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: pass
pgadmin:
image: dpage/pgadmin4:8.2
ports:
- 8055:80
depends_on:
- postgres
container_name: pgadmin-container
volumes:
- ./pgadmin/servers.json:/pgadmin4/servers.json
- ./pgadmin/pgpass:/pgadmin4/pgpass
entrypoint: >
/bin/sh -c "
cp -f /pgadmin4/pgpass /var/lib/pgadmin/;
chmod 600 /var/lib/pgadmin/pgpass;
/entrypoint.sh
"
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: pass
PGADMIN_CONFIG_SERVER_MODE: "False"
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "False"
GUNICORN_ACCESS_LOGFILE: "/dev/null"

zookeeper:
container_name: zookeeper
Expand Down Expand Up @@ -95,7 +106,7 @@ services:
environment:
DB_VENDOR: POSTGRES
DB_ADDR: postgres
DB_DATABASE: kogito
DB_DATABASE: keycloak
DB_USER: kogito-user
DB_SCHEMA: public
DB_PASSWORD: kogito-pass
Expand All @@ -105,7 +116,7 @@ services:

data-index:
container_name: data-index
image: quay.io/kiegroup/kogito-data-index-postgresql:${KOGITO_VERSION}
image: docker.io/apache/incubator-kie-kogito-data-index-postgresql:${KOGITO_VERSION}
ports:
- "8180:8080"
depends_on:
Expand All @@ -119,13 +130,15 @@ services:
QUARKUS_DATASOURCE_JDBC_URL: "jdbc:postgresql://postgres:5432/kogito"
QUARKUS_DATASOURCE_USERNAME: kogito-user
QUARKUS_DATASOURCE_PASSWORD: kogito-pass
QUARKUS_FLYWAY_MIGRATE_AT_START: "true"
QUARKUS_FLYWAY_BASELINE_ON_MIGRATE: "true"
QUARKUS_FLYWAY_TABLE: FLYWAY_DATA_INDEX
KAFKA_BOOTSTRAP_SERVERS: kafka:29092
QUARKUS_HTTP_CORS_ORIGINS: "/.*/"
KOGITO_DATA_INDEX_PROPS: -Dquarkus.hibernate-orm.database.generation=update

jobs-service:
container_name: jobs-service
image: quay.io/kiegroup/kogito-jobs-service-postgresql:${KOGITO_VERSION}
image: docker.io/apache/incubator-kie-kogito-jobs-service-postgresql:${KOGITO_VERSION}
ports:
- "8580:8080"
depends_on:
Expand All @@ -138,15 +151,17 @@ services:
QUARKUS_DATASOURCE_REACTIVE_URL: "postgresql://postgres:5432/kogito"
QUARKUS_DATASOURCE_USERNAME: kogito-user
QUARKUS_DATASOURCE_PASSWORD: kogito-pass
QUARKUS_FLYWAY_MIGRATE_AT_START: "true"
QUARKUS_FLYWAY_BASELINE_ON_MIGRATE: "true"
QUARKUS_FLYWAY_TABLE: FLYWAY_JOBS_SERVICE
KAFKA_BOOTSTRAP_SERVERS: kafka:29092
QUARKUS_PROFILE: events-support
QUARKUS_HTTP_PORT: 8580
QUARKUS_HTTP_CORS_ORIGINS: "/.*/"

management-console:
container_name: management-console
image: quay.io/kiegroup/kogito-management-console:${KOGITO_VERSION}
image: docker.io/apache/incubator-kie-kogito-management-console:${KOGITO_VERSION}
ports:
- "8280:8080"
depends_on:
Expand All @@ -159,15 +174,16 @@ services:
volumes:
- ../target/classes/META-INF/processSVG/:/home/kogito/data/svg/
environment:
KOGITO_DATAINDEX_HTTP_URL: http://${DOCKER_GATEWAY_HOST:-host.docker.internal}:8180/graphql
QUARKUS_HTTP_CORS_ORIGINS: "/.*/"
KOGITO_MANAGEMENT_CONSOLE_PROPS: -Dkogito.consoles.keycloak.config.url=http://localhost:8480/auth
-Dkogito.consoles.keycloak.config.health-check-url=http://localhost:8480/auth/realms/kogito/.well-known/openid-configuration
-Dkogito.svg.folder.path=/home/kogito/data/svg
RUNTIME_TOOLS_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE: "PROD"
RUNTIME_TOOLS_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT: http://${DOCKER_GATEWAY_HOST:-host.docker.internal}:8180/graphql
KOGITO_CONSOLES_KEYCLOAK_HEALTH_CHECK_URL: http://localhost:8480/auth/realms/kogito/.well-known/openid-configuration
KOGITO_CONSOLES_KEYCLOAK_URL: http://localhost:8480/auth
KOGITO_CONSOLES_KEYCLOAK_REALM: kogito
KOGITO_CONSOLES_KEYCLOAK_CLIENT_ID: kogito-console-quarkus

task-console:
container_name: task-console
image: quay.io/kiegroup/kogito-task-console:${KOGITO_VERSION}
image: docker.io/apache/incubator-kie-kogito-task-console:${KOGITO_VERSION}
ports:
- "8380:8080"
depends_on:
Expand All @@ -176,7 +192,9 @@ services:
keycloak:
condition: service_healthy
environment:
KOGITO_DATAINDEX_HTTP_URL: http://${DOCKER_GATEWAY_HOST:-host.docker.internal}:8180/graphql
QUARKUS_HTTP_CORS_ORIGINS: "/.*/"
KOGITO_TASK_CONSOLE_PROPS: -Dkogito.consoles.keycloak.config.url=http://localhost:8480/auth
-Dkogito.consoles.keycloak.config.health-check-url=http://localhost:8480/auth/realms/kogito/.well-known/openid-configuration
RUNTIME_TOOLS_TASK_CONSOLE_KOGITO_ENV_MODE: "PROD"
RUNTIME_TOOLS_TASK_CONSOLE_DATA_INDEX_ENDPOINT: http://${DOCKER_GATEWAY_HOST:-host.docker.internal}:8180/graphql
KOGITO_CONSOLES_KEYCLOAK_HEALTH_CHECK_URL: http://localhost:8480/auth/realms/kogito/.well-known/openid-configuration
KOGITO_CONSOLES_KEYCLOAK_URL: http://localhost:8480/auth
KOGITO_CONSOLES_KEYCLOAK_REALM: kogito
KOGITO_CONSOLES_KEYCLOAK_CLIENT_ID: kogito-console-quarkus
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
postgres:5432:kogito:kogito-user:kogito-pass
postgres:5432:postgres:kogito-user:kogito-pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Servers": {
"1": {
"Name": "kogito",
"Group": "Servers",
"Host": "postgres",
"Port": 5432,
"MaintenanceDB": "kogito",
"Username": "kogito-user",
"SSLMode": "disable",
"PassFile": "/var/lib/pgadmin/pgpass"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,18 @@ CREATE DATABASE kogito
TABLESPACE = pg_default
CONNECTION LIMIT = -1;

CREATE DATABASE keycloak
WITH
OWNER = "kogito-user"
ENCODING = 'UTF8'
LC_COLLATE = 'en_US.utf8'
LC_CTYPE = 'en_US.utf8'
TABLESPACE = pg_default
CONNECTION LIMIT = -1;

GRANT ALL PRIVILEGES ON DATABASE postgres TO "kogito-user";
GRANT ALL PRIVILEGES ON DATABASE kogito TO "kogito-user";
GRANT ALL PRIVILEGES ON DATABASE kogito TO postgres;

GRANT ALL PRIVILEGES ON DATABASE keycloak TO "kogito-user";
GRANT ALL PRIVILEGES ON DATABASE keycloak TO postgres;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
Expand Down Expand Up @@ -27,7 +27,7 @@ echo "Project version: ${PROJECT_VERSION}"

if [[ $PROJECT_VERSION == *SNAPSHOT ]];
then
KOGITO_VERSION="latest"
KOGITO_VERSION="main"
else
KOGITO_VERSION=${PROJECT_VERSION%.*}
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ kogito.jobs-service.url=http://localhost:8580
%postgresql.quarkus.datasource.username=kogito-user
%postgresql.quarkus.datasource.password=kogito-pass
%postgresql.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/kogito
%postgresql.kie.flyway.enabled=true
%postgresql.quarkus.kogito.devservices.enabled=false
%postgresql.quarkus.flyway.migrate-at-start=true

%infinispan.kogito.persistence.type=infinispan
%infinispan.quarkus.infinispan-client.hosts=localhost:11222
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ To make use of this application it is as simple as putting a sending request to

Complete curl command can be found below:

```
```bash
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"name" : "my fancy deal", "traveller" : { "firstName" : "John", "lastName" : "Doe", "email" : "[email protected]", "nationality" : "American","address" : { "street" : "main street", "city" : "Boston", "zipCode" : "10005", "country" : "US" }}}' http://localhost:8080/deals
```

Expand All @@ -156,13 +156,13 @@ this will then trigger the review user task that you can work with.

First you can display all active reviews of deals

```
```bash
curl -H 'Content-Type:application/json' -H 'Accept:application/json' http://localhost:8080/dealreviews
```

based on the response you can select one of the reviews to see more details

```
```bash
curl -H 'Content-Type:application/json' -H 'Accept:application/json' http://localhost:8080/dealreviews/{uuid}/tasks?user=john
```

Expand Down
Loading
Loading