ricardozanini commented on code in PR #517:
URL: 
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/517#discussion_r1711418197


##########
images/tools/sonataflow-db-migrator/src/main/cekit/image.yaml:
##########
@@ -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"
+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"
+  - name: "maintainer"
+    value: "Apache KIE <[email protected]>"
+  - 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/default"

Review Comment:
   ```suggestion
     workdir: "/home/kogito"
   ```



##########
images/tools/sonataflow-db-migrator/build-container-image.sh:
##########
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# cleanup temporary files
+cleanup () {
+    rm -rf target
+    rm -rf src/main/resources/postgresql
+    rm -rf tmp
+    rm -f 
src/main/cekit/modules/kogito-postgres-db-migration-deps/sonataflow-db-migrator-1.0-SNAPSHOT-runner.jar
+}
+
+# Start with cleanup
+cleanup
+
+# Get Data Index/ Jobs Service DDL Files
+mkdir -p tmp
+# Change the variables below, as needed
+DDL_VERSION=10.0.999-SNAPSHOT
+DDL_FILE=kogito-ddl-10.0.999-20240806.011718-23-db-scripts.zip
+DDL_URL=https://repository.apache.org/content/groups/snapshots/org/kie/kogito/kogito-ddl/$DDL_VERSION/$DDL_FILE
+wget $DDL_URL
+mv $DDL_FILE tmp
+cd tmp
+unzip $DDL_FILE
+mv ./postgresql ../src/main/resources
+cd ..
+
+# Create an Uber jar
+mvn package -Dquarkus.package.jar.type=uber-jar
+cp target/sonataflow-db-migrator-1.0-SNAPSHOT-runner.jar 
src/main/cekit/modules/kogito-postgres-db-migration-deps
+
+# Build the container image
+cd src/main/cekit
+cekit -v build podman

Review Comment:
   The builder also must come from an argument. Many community users rely on 
Docker.



##########
images/tools/sonataflow-db-migrator/src/main/docker/Dockerfile.legacy-jar:
##########
@@ -0,0 +1,93 @@
+####
+# This Dockerfile is used in order to build a container that runs the Quarkus 
application in JVM mode

Review Comment:
   We can delete these auto-generated Dockerfiles.



##########
images/tools/sonataflow-db-migrator/pom.xml:
##########
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.redhat.sonataflow.flyway</groupId>
+    <artifactId>sonataflow-db-migrator</artifactId>
+    <version>1.0-SNAPSHOT</version>

Review Comment:
   Please use the operator's version instead. You can read from `version.go`.



##########
images/tools/sonataflow-db-migrator/build-container-image.sh:
##########
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# cleanup temporary files
+cleanup () {
+    rm -rf target
+    rm -rf src/main/resources/postgresql
+    rm -rf tmp
+    rm -f 
src/main/cekit/modules/kogito-postgres-db-migration-deps/sonataflow-db-migrator-1.0-SNAPSHOT-runner.jar
+}
+
+# Start with cleanup
+cleanup
+
+# Get Data Index/ Jobs Service DDL Files
+mkdir -p tmp
+# Change the variables below, as needed

Review Comment:
   This script can receive these vars via arguments and have defaults replaced 
once we branch to release a version. So, please keep the default in constants 
at the beginning of the script and read the input arguments to replace these 
vars.



##########
images/tools/sonataflow-db-migrator/src/main/cekit/image.yaml:
##########
@@ -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"
+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"
+  - name: "maintainer"
+    value: "Apache KIE <[email protected]>"
+  - 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/default"
+  entrypoint:
+    - "/home/default/migration.sh"

Review Comment:
   ```suggestion
       - "/home/kogito/migration.sh"
   ```



##########
images/tools/sonataflow-db-migrator/src/main/cekit/modules/kogito-postgres-db-migration-deps/install:
##########
@@ -0,0 +1,30 @@
+#!/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.
+#
+
+mkdir -p /home/default

Review Comment:
   ```suggestion
   mkdir -p /home/kogito
   ```
   Since there are many places, please create the user `kogito` instead, and a 
home dir will be created by the system.



##########
images/tools/sonataflow-db-migrator/pom.xml:
##########
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.redhat.sonataflow.flyway</groupId>
+    <artifactId>sonataflow-db-migrator</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <compiler-plugin.version>3.13.0</compiler-plugin.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
+        
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
+        <quarkus.platform.version>3.13.0</quarkus.platform.version>

Review Comment:
   We have a script to update versions in this repo: 
https://github.com/apache/incubator-kie-kogito-serverless-operator/blob/main/hack/bump-version.sh.
   
   Please update it to set the Quarkus version there once we do an aligned 
release with the platform. That script must receive a Quarkus Version argument 
to replace here. Please feel free to use Python to parse the XML if necessary.



##########
images/tools/sonataflow-db-migrator/README.md:
##########
@@ -0,0 +1,56 @@
+# sonataflow-db-migrator
+
+This is a quarkus postgres database migrator application for Sonataflow Data 
Index and Jobs Service applications.
+
+## 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 as described in the next section. 
+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. 
+However the DDL files are dynamically included from its respective sources 
when a container image is created.
+
+You can run your application in dev mode that enables live coding using:
+
+```shell script
+./mvnw compile quarkus:dev
+```
+
+## Build and Run container image locally
+You can build the cekit container image by using the provided image builder 
shell script
+```shell
+./build-container-image.sh
+```
+Ensure the script completes without errors.
+If you may have a cekit specific Python virtual environment, be sure to 
activate it, so the script can find the cekit command.
+```shell
+virtualenv ~/cekit
+source ~/cekit/bin/activate;
+```
+
+Assuming you have Postgres database running locally and e.g. have a di 
database for data index and js database for jobs service, you can run the image 
by command as follows, just substitute appropriate values.

Review Comment:
   ```suggestion
   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:
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to