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

kie-issues#2659: [SonataFlow] Migrate DBMigration Image from SonataFlow operator repository to kie-tools #2697

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
20 changes: 20 additions & 0 deletions .ci/jenkins/Jenkinsfile.daily-dev-publish
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ pipeline {
KOGITO_MANAGEMENT_CONSOLE__name = 'incubator-kie-kogito-management-console'
KOGITO_MANAGEMENT_CONSOLE__buildTag = "${params.BRANCH_NAME}"

KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry = 'docker.io'
KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account = 'apache'
KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name = 'kogito-postgresql-db-migrator-tool'
KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__buildTag = "${params.BRANCH_NAME}"

SONATAFLOW_BUILDER_IMAGE__registry = 'docker.io'
SONATAFLOW_BUILDER_IMAGE__account = 'apache'
SONATAFLOW_BUILDER_IMAGE__name = 'incubator-kie-sonataflow-builder'
Expand Down Expand Up @@ -550,6 +555,21 @@ pipeline {
}
}

stage('Push kogito-postgresql-db-migrator-tool to Docker Hub') {
steps {
script {
dockerUtils.pushImageToRegistry(
"${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry}",
"${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account}",
"${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name}",
"${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__buildTag}",
"${pipelineVars.dockerHubUserCredentialsId}",
"${pipelineVars.dockerHubTokenCredentialsId}"
)
}
}
}

stage('Push kie-sandbox-helm-chart to Docker Hub') {
steps {
dir('kie-tools') {
Expand Down
210 changes: 210 additions & 0 deletions .ci/jenkins/release-jobs/Jenkinsfile.kogito-db-migrator-tool
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
/*
* 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.
*/
pipeline {
agent {
docker {
image 'docker.io/apache/incubator-kie-tools-ci-build:main'
args '--shm-size=2g --privileged --group-add docker'
}
}

options {
timeout(time: 60, unit: 'MINUTES')
}

parameters {
booleanParam(description: 'Dry run', name: 'DRY_RUN', defaultValue: true)
string(description: 'Release Version', name: 'RELEASE_VERSION', defaultValue: '0.0.0')
string(description: 'Base Ref', name: 'BASE_REF')
string(description: 'Release Candidate Version', name: 'RELEASE_CANDIDATE_VERSION', defaultValue: '')
}

environment {
KIE_TOOLS_BUILD__runLinters = 'false'
KIE_TOOLS_BUILD__runTests = 'false'
KIE_TOOLS_BUILD__runEndToEndTests = 'false'
KIE_TOOLS_BUILD__buildContainerImages = 'true'


KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry = 'docker.io'
KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account = 'apache'
KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name = 'kogito-postgresql-db-migrator-tool'
KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__buildTag = "${params.RELEASE_VERSION}"

RELEASE_ARTIFACTS_DIR = "${WORKSPACE}/release-artifacts"

DOCKER_CONFIG = "${WORKSPACE}/.docker"

PNPM_FILTER_STRING = '-F @kie-tools/kogito-postgresql-db-migrator-tool...'
}

stages {
stage('Load local shared scripts') {
steps {
script {
pipelineVars = load '.ci/jenkins/shared-scripts/pipelineVars.groovy'
buildUtils = load '.ci/jenkins/shared-scripts/buildUtils.groovy'
githubUtils = load '.ci/jenkins/shared-scripts/githubUtils.groovy'
dockerUtils = load '.ci/jenkins/shared-scripts/dockerUtils.groovy'
releaseUtils = load '.ci/jenkins/shared-scripts/releaseUtils.groovy'
}
}
}

stage('Start required services for build and tests (DinD, Xvfb, Fluxbox)') {
steps {
script {
buildUtils.startRequiredServices()
}
}
}

stage('Clean workspace before build') {
steps {
cleanWs(deleteDirs: true, disableDeferredWipeout: true)
}
}

stage('Load upstream images') {
when {
expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' }
}
steps {
script {
upstreamReleaseArtifactsDir = "${WORKSPACE}/upstream-release-artifacts"
releaseUtils.downloadReleaseArtifacts("${pipelineVars.asfReleaseStagingRepository}", "${upstreamReleaseArtifactsDir}", "${params.RELEASE_CANDIDATE_VERSION}")
upstreamImagesArtifacts = releaseUtils.getUpstreamImagesArtifactsList("${upstreamReleaseArtifactsDir}", "${params.RELEASE_CANDIDATE_VERSION}")
dockerUtils.loadImages(upstreamImagesArtifacts as String[])
}
}
}

stage('Checkout kie-tools') {
steps {
dir('kie-tools') {
script {
githubUtils.checkoutRepo(
"http://github.com/${pipelineVars.githubRepositorySlug}.git",
"${params.BASE_REF}",
"${pipelineVars.kieToolsBotGithubCredentialsId}"
)
}
}
}
}

stage('Setup PNPM') {
steps {
dir('kie-tools') {
script {
buildUtils.setupPnpm("${pipelineVars.mavenSettingsReleaseConfigFileId}")
}
}
}
}

stage('PNPM Bootstrap') {
steps {
dir('kie-tools') {
script {
buildUtils.pnpmBootstrap("${env.PNPM_FILTER_STRING}")
}
}
}
}

stage('Build') {
steps {
dir('kie-tools') {
script {
buildUtils.pnpmBuild("${env.PNPM_FILTER_STRING}")
}
}
}
}

stage('Push kogito-postgresql-db-migrator-tool to Docker Hub') {
when {
expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION == '' }
}
steps {
script {
dockerUtils.pushImageToRegistry(
"${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry}",
"${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account}",
"${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name}",
"${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL_buildTag}",
"${pipelineVars.dockerHubUserCredentialsId}",
"${pipelineVars.dockerHubTokenCredentialsId}"
)
}
}
}

stage('Setup release candidate artifacts') {
when {
expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' }
}
steps {
script {
env.RELEASE_IMAGE_TAR_FILE = "incubator-kie-${params.RELEASE_CANDIDATE_VERSION}-kogito-postgresql-db-migrator-tool-image.tar.gz"

sh """#!/bin/bash -el
mkdir ${env.RELEASE_ARTIFACTS_DIR}
docker save "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry}/${env.KOGITO_MANAGEMENT_CONSOLE__account}/${env.KOGITO_MANAGEMENT_CONSOLE__name}:${params.RELEASE_VERSION}" | gzip > "${env.RELEASE_ARTIFACTS_DIR}/${env.RELEASE_IMAGE_TAR_FILE}"
""".trim()
}
}
}

stage('Sign artifact for Apache release') {
when {
expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' }
}
steps {
dir("${env.RELEASE_ARTIFACTS_DIR}") {
script {
releaseUtils.setupSigningKey("${pipelineVars.asfReleaseGPGKeyCredentialsId}")
releaseUtils.signArtifact("${env.RELEASE_IMAGE_TAR_FILE}")
}
}
}
}

stage('Publish Release Candidate artifacts') {
when {
expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' }
}
steps {
script {
releaseUtils.publishArtifacts(
"${env.RELEASE_ARTIFACTS_DIR}",
"${pipelineVars.asfReleaseStagingRepository}",
"${params.RELEASE_CANDIDATE_VERSION}",
"${pipelineVars.asfReleaseSVNStagingCredentialsId}"
)
}
}
}
}

post {
always {
cleanWs(deleteDirs: true)
}
}
}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,5 @@ turbo.json
packages/*/.idea
examples/*/.idea


# Apache RAT check excludes file
!.rat-excludes
!.rat-excludes
94 changes: 94 additions & 0 deletions packages/kogito-postgresql-db-migrator-tool-image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!--
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.
-->

# Kogito PostgreSQL DB Migrator Tool Image

This package contains the `Containerfile/Dockerfile` and scripts to build a container image for Kogito PostgreSQL DB Migrator Tool. Details about the Kogito PostgreSQL DB Migrator Tool can be found [here](../kogito-postgresql-db-migrator-tool/README.md)

## Additional requirements

- docker

## Run

- Start up a clean container with:

```bash
docker run docker.io/apache/incubator-kie-kogito-service-db-migration-postgresql:main
```

## Customization

1. Run a container with custom 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 | data-index-service |
| 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 | jobs-service |

### Example

An example to use diverse environment variables

```bash
docker 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=data-index-service \
--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=jobs-service \
docker.io/apache/incubator-kie-kogito-postgresql-db-migrator-tool:main
```

---

Apache KIE (incubating) is an effort undergoing incubation at The Apache Software
Foundation (ASF), sponsored by the name of Apache Incubator. Incubation is
required of all newly accepted projects until a further review indicates that
the infrastructure, communications, and decision making process have stabilized
in a manner consistent with other successful ASF projects. While incubation
status is not necessarily a reflection of the completeness or stability of the
code, it does indicate that the project has yet to be fully endorsed by the ASF.

Some of the incubating project’s releases may not be fully compliant with ASF
policy. For example, releases may have incomplete or un-reviewed licensing
conditions. What follows is a list of known issues the project is currently
aware of (note that this list, by definition, is likely to be incomplete):

- Hibernate, an LGPL project, is being used. Hibernate is in the process of
relicensing to ASL v2
- Some files, particularly test files, and those not supporting comments, may
be missing the ASF Licensing Header

If you are planning to incorporate this work into your product/project, please
be aware that you will need to conduct a thorough licensing review to determine
the overall implications of including this work. For the current status of this
project through the Apache Incubator visit:
https://incubator.apache.org/projects/kie.html
Loading
Loading