ricardozanini commented on code in PR #2697: URL: https://github.com/apache/incubator-kie-tools/pull/2697#discussion_r1811280731
########## packages/kogito-db-migrator-tool-image/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" Review Comment: ```suggestion value: "### SET ME DURING BUILD PROCESS ###" ``` ########## packages/kogito-db-migrator-tool-image/package.json: ########## @@ -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", Review Comment: 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 ########## packages/kogito-db-migrator-tool/install.js: ########## @@ -0,0 +1,35 @@ +/* + * 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. + */ + +const { env } = require("./env"); +const { setupMavenConfigFile, installMvnw, buildTailFromPackageJsonDependencies } = require("@kie-tools/maven-base"); + +setupMavenConfigFile( + ` + --batch-mode + -Dstyle.color=always + -Drevision=${env.devDeploymentQuarkusApp.version} + -Dversion.quarkus=${env.versions.quarkus} + -Dversion.org.kie.kogito=${env.versions.kogito} Review Comment: Here too, I don't see these set in the `env/index.js`. ########## packages/kogito-db-migrator-tool-image/README.md: ########## @@ -0,0 +1,47 @@ +# kogito-db-migrator-tool-image + +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 Review Comment: Instead of shell, we can provide the pnpm command `pnpm build:dev`. ########## packages/kogito-db-migrator-tool/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" Review Comment: ```suggestion version: "0.0.0" ``` ########## packages/kogito-db-migrator-tool/pom.xml: ########## @@ -0,0 +1,213 @@ +<?xml version="1.0" ?> +<!-- + ~ 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. +--> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +> + <parent> + <groupId>org.kie</groupId> + <artifactId>kie-tools-maven-base</artifactId> + <version>${revision}</version> + <relativePath>./node_modules/@kie-tools/maven-base/pom.xml</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + <groupId>org.kie.kogito</groupId> + <artifactId>sonataflow-db-migrator</artifactId> + <properties> + <project.build.outputTimestamp>2024-11-01T00:00:00Z</project.build.outputTimestamp> + <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> + <skipITs>true</skipITs> + <surefire-plugin.version>3.2.5</surefire-plugin.version> + <jacoco.version>0.8.12</jacoco.version> + <systemrules.version>1.19.0</systemrules.version> Review Comment: These come from the maven-base pom. ########## packages/kogito-db-migrator-tool-image/cekit/modules/kogito-postgres-db-migration-deps/migration.sh: ########## @@ -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 + +java -jar sonataflow-db-migrator-"$OPERATOR_VERSION"-runner.jar Review Comment: I don't think we need this file. Can't we just have this command as the image's entrypoint? ########## packages/kogito-db-migrator-tool-image/cekit/modules/kogito-postgres-db-migration-deps/install: ########## @@ -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 Review Comment: Please use this instead: https://github.com/apache/incubator-kie-tools/blob/main/packages/sonataflow-management-console-image/resources/incubator-kie-sonataflow-management-console-image.yaml#L44 ########## packages/kogito-db-migrator-tool/install.js: ########## @@ -0,0 +1,35 @@ +/* + * 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. + */ + +const { env } = require("./env"); +const { setupMavenConfigFile, installMvnw, buildTailFromPackageJsonDependencies } = require("@kie-tools/maven-base"); + +setupMavenConfigFile( + ` + --batch-mode + -Dstyle.color=always + -Drevision=${env.devDeploymentQuarkusApp.version} Review Comment: I think we must have this env in this package. ########## packages/kogito-db-migrator-tool-image/install.js: ########## @@ -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"); Review Comment: Let's do as is: https://github.com/apache/incubator-kie-tools/blob/main/packages/kogito-data-index-ephemeral-image/install.js ########## packages/kogito-db-migrator-tool-image/README.md: ########## @@ -0,0 +1,47 @@ +# kogito-db-migrator-tool-image Review Comment: See this readme to use as inspiration: https://github.com/apache/incubator-kie-tools/tree/main/packages/sonataflow-management-console-image ########## packages/kogito-db-migrator-tool-image/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" Review Comment: ```suggestion version: "0.0.0" ``` ########## packages/kogito-db-migrator-tool-image/env/index.js: ########## @@ -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"); Review Comment: 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 ########## .gitignore: ########## @@ -346,3 +346,6 @@ turbo.json # IntelliJ projects should be on _intellij-projects folder, never on specific packages. packages/*/.idea examples/*/.idea + +# Jar files +**/*.jar Review Comment: Why do we need this? ########## packages/kogito-db-migrator-tool-image/build-container-image.sh: ########## @@ -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 Review Comment: I think we should have the `package.js` reflect what we are doing here. ########## packages/kogito-db-migrator-tool/README.md: ########## @@ -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. Review Comment: ```suggestion This is a java quarkus based postgres database migrator application for SonataFlow Data Index and Jobs Service applications for use by SonataFlow Operator. ``` ########## packages/kogito-db-migrator-tool-image/cekit/modules/kogito-postgres-db-migration-deps/migration.sh: ########## @@ -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 Review Comment: We don't need to rename the jar file. Within the image, we will have the `KOGITO_VERSION` variable set. ########## packages/kogito-db-migrator-tool/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 Review Comment: ```suggestion from: registry.access.redhat.com/ubi8/openjdk-17-runtime:1.20 ``` ########## packages/kogito-db-migrator-tool/get-kogito-ddl-scripts.sh: ########## @@ -0,0 +1,64 @@ +#!/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 + +# Script variables with default values. These values will be updated by hack/bump-version.sh, don't change it. +DDL_VERSION=10.0.999-SNAPSHOT +DDL_FILE=kogito-ddl-10.0.999-20241018.012042-73-db-scripts.zip +DDL_BASE_URL=https://repository.apache.org/content/groups/snapshots/org/kie/kogito/kogito-ddl Review Comment: These data can come from the `env/index.js`. We have a few root parameters that we can also use here, see: https://github.com/apache/incubator-kie-tools/blob/main/packages/root-env/env/index.js#L67-L75 ########## packages/kogito-db-migrator-tool/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" Review Comment: ```suggestion value: "### SET ME DURING BUILD PROCESS ###" ``` ########## packages/kogito-db-migrator-tool/src/main/cekit/modules/kogito-postgres-db-migration-deps/migration.sh: ########## @@ -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 Review Comment: I think these files are repeated here? ########## packages/kogito-db-migrator-tool/src/main/cekit/modules/kogito-postgres-db-migration-deps/install: ########## @@ -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 Review Comment: We already have a module doing this: https://github.com/apache/incubator-kie-tools/blob/main/packages/sonataflow-management-console-image/resources/incubator-kie-sonataflow-management-console-image.yaml#L44 -- 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]
