-
Notifications
You must be signed in to change notification settings - Fork 179
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
kie-issues#2659: [SonataFlow] Migrate DBMigration Image from SonataFlow operator repository to kie-tools #2697
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# kogito-db-migrator-tool-image | ||
rhkp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
This is a cekit based image builder for the database migrator application. Details about the database migrator application are [here](../kogito-db-migrator-tool/README.md) | ||
|
||
## Build and Run container image locally | ||
|
||
You can build the cekit build of container image by using the provided image builder shell script | ||
|
||
```shell | ||
./build-container-image.sh | ||
rhkp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
_NOTE_: Before performing this step, be sure that the database migrator application jar has been built and available for inclusion in the image. | ||
|
||
Ensure the script completes without errors. | ||
|
||
Assuming you have a Postgres database running locally, e.g., a `di` database for data index and a `js` database for jobs service, you can run the image with the following command. Substitute appropriate values: | ||
|
||
```shell | ||
podman run \ | ||
--env MIGRATE_DB_DATAINDEX=true \ | ||
--env QUARKUS_DATASOURCE_DATAINDEX_JDBC_URL=<data-index-db-url e.g. jdbc:postgresql://host.docker.internal:5432/di> \ | ||
--env QUARKUS_DATASOURCE_DATAINDEX_USERNAME=<data-index-db-user> \ | ||
--env QUARKUS_DATASOURCE_DATAINDEX_PASSWORD=<data-index-db-password> \ | ||
--env QUARKUS_FLYWAY_DATAINDEX_SCHEMAS=dataindex \ | ||
--env MIGRATE_DB_JOBSSERVICE=true \ | ||
--env QUARKUS_DATASOURCE_JOBSSERVICE_JDBC_URL=<jobs-service-db-url e.g. jdbc:postgresql://host.docker.internal:5432/js> \ | ||
--env QUARKUS_DATASOURCE_JOBSSERVICE_USERNAME=<jobs-service-db-user> \ | ||
--env QUARKUS_DATASOURCE_JOBSSERVICE_PASSWORD=<jobs-service-db-password> \ | ||
--env QUARKUS_FLYWAY_JOBSSERVICE_SCHEMAS=jobsservice \ | ||
docker.io/apache/incubator-kie-kogito-service-db-migration-postgresql:999-SNAPSHOT | ||
``` | ||
|
||
### Environment variables | ||
|
||
| NAME | DESCRIPTION | DEFAULT | | ||
| --------------------------------------- | -------------------------------------------------------------------------------- | ----------------------------------------- | | ||
| MIGRATE_DB_DATAINDEX | Set to true if you want to migrate data index database, set to false otherwise | false | | ||
| QUARKUS_DATASOURCE_DATAINDEX_JDBC_URL | Data index database url e.g. jdbc:postgresql://host.docker.internal:5432/di | jdbc:postgresql://localhost:5432/postgres | | ||
| QUARKUS_DATASOURCE_DATAINDEX_USERNAME | Data index database username | postgres | | ||
| QUARKUS_DATASOURCE_DATAINDEX_PASSWORD | Data index database password | postgres | | ||
| QUARKUS_FLYWAY_DATAINDEX_SCHEMAS | Data index database schema | dataindex | | ||
| MIGRATE_DB_JOBSSERVICE | Set to true if you want to migrate jobs service database, set to false otherwise | false | | ||
| QUARKUS_DATASOURCE_JOBSSERVICE_JDBC_URL | Jobs service database url e.g. jdbc:postgresql://host.docker.internal:5432/js | jdbc:postgresql://localhost:5432/postgres | | ||
| QUARKUS_DATASOURCE_JOBSSERVICE_USERNAME | Jobs service database username | postgres | | ||
| QUARKUS_DATASOURCE_JOBSSERVICE_PASSWORD | Jobs service database password | postgres | | ||
| QUARKUS_FLYWAY_JOBSSERVICE_SCHEMAS | Jobs service database schema | jobsservice | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/sh | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
set -x | ||
set -e | ||
|
||
CEKIT_BUILDER=docker | ||
SOURCE_FILE=/tmp/kogito-db-migrator-tool/sonataflow-db-migrator-0.0.0-runner.jar | ||
TARGET_FILE=./cekit/modules/kogito-postgres-db-migration-deps/sonataflow-db-migrator-runner.jar | ||
|
||
if [ -f "$SOURCE_FILE" ]; then | ||
echo "The file: $SOURCE_FILE found and will be used to build image." | ||
rm -f $TARGET_FILE | ||
cp $SOURCE_FILE $TARGET_FILE | ||
|
||
# Build the container image | ||
cd ./cekit || exit | ||
cekit -v build "$CEKIT_BUILDER" | ||
rm -f $TARGET_FILE | ||
else | ||
echo "The file: $SOURCE_FILE not found. Please build kogito-db-migrator-tool package first before building the image." | ||
exit 1 | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have the |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,45 @@ | ||||||
# | ||||||
# Licensed to the Apache Software Foundation (ASF) under one | ||||||
# or more contributor license agreements. See the NOTICE file | ||||||
# distributed with this work for additional information | ||||||
# regarding copyright ownership. The ASF licenses this file | ||||||
# to you under the Apache License, Version 2.0 (the | ||||||
# "License"); you may not use this file except in compliance | ||||||
# with the License. You may obtain a copy of the License at | ||||||
# | ||||||
# http://www.apache.org/licenses/LICENSE-2.0 | ||||||
# | ||||||
# Unless required by applicable law or agreed to in writing, | ||||||
# software distributed under the License is distributed on an | ||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||||
# KIND, either express or implied. See the License for the | ||||||
# specific language governing permissions and limitations | ||||||
# under the License. | ||||||
# | ||||||
name: "docker.io/apache/incubator-kie-kogito-service-db-migration-postgresql" | ||||||
version: "999-SNAPSHOT" | ||||||
rhkp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
from: registry.access.redhat.com/ubi8/openjdk-17-runtime:1.19 | ||||||
description: Flyway image for DI/JS database migration | ||||||
|
||||||
labels: | ||||||
- name: "org.kie.kogito.version" | ||||||
value: "999-SNAPSHOT" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- name: "maintainer" | ||||||
value: "Apache KIE <dev@kie.apache.org>" | ||||||
- name: "io.k8s.description" | ||||||
value: "Kogito DB Migration creates schemas and tables for Data Index and Jobs Service for PostgreSQL database" | ||||||
- name: "io.k8s.display-name" | ||||||
value: "Kogito DB Migration for Data Index and Jobs Service - PostgreSQL" | ||||||
- name: "io.openshift.tags" | ||||||
value: "kogito,db-migration" | ||||||
|
||||||
modules: | ||||||
repositories: | ||||||
- path: modules | ||||||
install: | ||||||
- name: kogito-postgres-db-migration-deps | ||||||
|
||||||
run: | ||||||
workdir: "/home/kogito" | ||||||
entrypoint: | ||||||
- "/home/kogito/migration.sh" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
set -x | ||
set -e | ||
|
||
useradd -m kogito | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
cd /home/kogito || exit | ||
|
||
chgrp -R 0 /home/kogito | ||
chown -R 0 /home/kogito | ||
chmod -R g=u /home/kogito | ||
|
||
chmod +x /home/kogito/migration.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
set -x | ||
set -e | ||
|
||
OPERATOR_VERSION=999.0.0 | ||
|
||
for arg in "$@"; do | ||
case "$arg" in | ||
OPERATOR_VERSION=*) OPERATOR_VERSION="${arg#*=}" ;; | ||
esac | ||
done | ||
|
||
cd /home/kogito/ | ||
|
||
mv sonataflow-db-migrator-runner.jar sonataflow-db-migrator-"$OPERATOR_VERSION"-runner.jar | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to rename the jar file. Within the image, we will have the |
||
|
||
java -jar sonataflow-db-migrator-"$OPERATOR_VERSION"-runner.jar | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this file. Can't we just have this command as the image's entrypoint? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
schema_version: 1 | ||
name: kogito-postgres-db-migration-deps | ||
version: "1.0" | ||
artifacts: | ||
- name: migration.sh | ||
path: migration.sh | ||
dest: /home/kogito | ||
- name: sonataflow-db-migrator-runner.jar | ||
path: sonataflow-db-migrator-runner.jar | ||
dest: /home/kogito | ||
execute: | ||
- script: install |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
console.log("index.js"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is unncessary if we are not doing anything. But I think you can use this: https://github.com/apache/incubator-kie-tools/blob/main/packages/kogito-data-index-ephemeral-image/env/index.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
console.log("install.js"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"private": true, | ||
"name": "@kie-tools/kogito-db-migrator-tool-image", | ||
"version": "0.0.0", | ||
"description": "", | ||
"license": "Apache-2.0", | ||
"homepage": "https://github.com/apache/incubator-kie-tools", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/apache/incubator-kie-tools.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/apache/incubator-kie-tools/issues" | ||
}, | ||
"scripts": { | ||
"build": "./build-container-image.sh", | ||
"build:dev": "pnpm build", | ||
"build:prod": "pnpm build", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This commands must reflect the image build: https://github.com/apache/incubator-kie-tools/blob/main/packages/kogito-data-index-ephemeral-image/package.json#L16-L33 |
||
"install": "node install.js" | ||
}, | ||
"dependencies": { | ||
"@kie-tools/kogito-db-migrator-tool": "workspace:*", | ||
"@kie-tools/python-venv": "workspace:*", | ||
"@kie-tools/root-env": "workspace:*" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* | ||
!target/*-runner | ||
!target/*-runner.jar | ||
!target/lib/* | ||
!target/quarkus-app/* |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need so many things here? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#Maven | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
release.properties | ||
.flattened-pom.xml | ||
|
||
# Eclipse | ||
.project | ||
.classpath | ||
.settings/ | ||
bin/ | ||
|
||
# IntelliJ | ||
.idea | ||
*.ipr | ||
*.iml | ||
*.iws | ||
|
||
# NetBeans | ||
nb-configuration.xml | ||
|
||
# Visual Studio Code | ||
.vscode | ||
.factorypath | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# Vim | ||
*.swp | ||
*.swo | ||
|
||
# patch | ||
*.orig | ||
*.rej | ||
|
||
# Local environment | ||
.env | ||
|
||
# Plugin directory | ||
/.quarkus/cli/plugins/ | ||
*.iml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# kogito-db-migrator | ||
|
||
This is a java quarkus based postgres database migrator application for Sonataflow Data Index and Jobs Service applications for use by SonataFlow Operator. | ||
rhkp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
_NOTE_: This postgres database migrator application and its corresponding images are only envisaged to be made use of by SonataFlow Operator, Data Index and Jobs Service internally. Conversely this application is of no use outside the usecases involved with SonataFlow Operator, Data Index and Jobs Service. | ||
|
||
## Running the application in dev mode | ||
|
||
Though you can run the application locally in dev mode but it is advisable to run this application as a container image. | ||
The primary reason not to run as standalone application in dev mode, is that by default there are no DDL migration files included in the source. The script `get-kogito-ddl-scripts.sh` can be used to download the needed postgres DDL files into the application. | ||
|
||
You can run your application in dev mode that enables live coding using: | ||
|
||
```shell script | ||
./get-kogito-ddl-scripts.sh | ||
./mvnw compile quarkus:dev | ||
``` | ||
|
||
## Build jar file | ||
|
||
You can build the jar file with the script `build-db-migrator-jar.sh` which places the jar into /tmp/ kogito-db-migrator-tool directory for use by the corresponding image builder in package kogito-db-migrator-tool-image later, which can be found [here](../kogito-db-migrator-tool-image/README.md). | ||
|
||
```shell | ||
./build-db-migrator-jar.sh | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?