Skip to content

Commit

Permalink
[KOGITO-4619] - Prepare the kogito-images repository for productizati…
Browse files Browse the repository at this point in the history
…on (apache#383)

* [KOGITO-4619] - Prepare the kogito-images repository for productization

Signed-off-by: spolti <[email protected]>

Co-authored-by: Tristan Radisson <[email protected]>
Co-authored-by: Ricardo Zanini <[email protected]>
  • Loading branch information
3 people authored Mar 19, 2021
1 parent 4e1de0c commit 27b8e92
Show file tree
Hide file tree
Showing 35 changed files with 883 additions and 569 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ bats/*
*.db
*.tlog

# python
scripts/__pycache__

23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ endif

.PHONY: list
list:
@python3 scripts/list-images.py
@python3 scripts/list-images.py $(arg)

# Build all images
.PHONY: build
Expand All @@ -22,6 +22,7 @@ build: clone-repos _build
_build:
@for f in $(shell make list); do make build-image image_name=$${f}; done


.PHONY: build-image
image_name=
build-image:
Expand All @@ -36,6 +37,26 @@ ifneq ($(findstring rc,$(IMAGE_VERSION)),rc)
${BUILD_ENGINE} tag quay.io/kiegroup/${image_name}:${IMAGE_VERSION} quay.io/kiegroup/${image_name}:${SHORTENED_LATEST_VERSION}
endif


# Build all images
.PHONY: build-prod
# start to build the images
build-prod: clone-repos
@for iname in $(shell make list arg=--prod); do make build-prod-image image_name=$${iname} ; done


.PHONY: build-prod-image
image_name=
build-prod-image:
ifneq ($(ignore_build),true)
scripts/build-product-image.sh "build" $(image_name) ${BUILD_ENGINE}
endif
# if ignore_test is set to true, ignore the tests
ifneq ($(ignore_test),true)
scripts/build-product-image.sh "test" $(image_name)
endif


# push images to quay.io, this requires permissions under kiegroup organization
.PHONY: push
push: build _push
Expand Down
6 changes: 6 additions & 0 deletions container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
platforms:
only:
- x86_64
compose:
pulp_repos: true
16 changes: 16 additions & 0 deletions content_sets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is a file defining which content sets (yum repositories) are needed to
# update content in this image. Data provided here helps determine which images
# are vulnerable to specific CVEs. Generally you should only need to update this
# file when:
# 1. You start depending on a new product
# 2. You are preparing new product release and your content sets will change
#
# See https://mojo.redhat.com/docs/DOC-1023066 for more information on
# maintaining this file and the format and examples
#
# You should have one top level item for each architecture being built. Most
# likely this will be x86_64 and ppc64le initially.
---
x86_64:
- rhel-8-for-x86_64-baseos-rpms
- rhel-8-for-x86_64-appstream-rpms
3 changes: 1 addition & 2 deletions kogito-runtime-jvm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ labels:
- name: "io.k8s.display-name"
value: "Kogito based on Quarkus or Spring Boot JVM image"
- name: "io.openshift.tags"
value: "builder,runtime,kogito,quarkus,springboot,jvm"
value: "runtime,kogito,quarkus,springboot,jvm"
- name: "io.openshift.s2i.assemble-input-files"
value: "/home/kogito/bin"

Expand Down Expand Up @@ -38,7 +38,6 @@ modules:
- name: org.kie.kogito.s2i.core
- name: org.kie.kogito.runtime.jvm


## s2i build . quay.io/kiegroup/kogito-builder:latest kogitotest:10.0 --runtime-image quay.io/kiegroup/kogito-runtime-jvm:latest
## where "." is the sources dir, ie: /data/dev/sources/kogito-examples/rules-quarkus-helloworld
run:
Expand Down
7 changes: 7 additions & 0 deletions osbs-extra/rhpam-kogito-builder-rhel8/gating.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--- !Policy
id: "cvp-rhpam-kogito-builder"
product_versions:
- cvp
decision_context: cvp_default
rules:
- !PassingTestCaseRule {test_case_name: rhpam-kogito-builder.openshift.external}
7 changes: 7 additions & 0 deletions osbs-extra/rhpam-kogito-runtime-jvm-rhel8/gating.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--- !Policy
id: "cvp-rhpam-kogito-runtime-jvm"
product_versions:
- cvp
decision_context: cvp_default
rules:
- !PassingTestCaseRule {test_case_name: rhpam-kieserver-kogito-runtime-jvm.openshift.external}
25 changes: 25 additions & 0 deletions rhpam-kogito-builder-rhel8-overrides.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
schema_version: 1

name: "rhpam-7/rhpam-kogito-builder-rhel8"
version: "7.11.0"
from: "registry.redhat.io/ubi8/ubi-minimal:latest"
description: "RHPAM Platform for building Kogito based on Quarkus or SpringBoot"

labels:
- name: "com.redhat.component"
value: "rhpam-7-kogito-runtime-jvm-rhel8-container"
- name: "io.k8s.display-name"
value: "Red Hat build of Kogito based on Quarkus or SpringBoot"
- name: "io.openshift.tags"
value: "rhpam-kogito,builder,kogito,quarkus,springboot"

packages:
content_sets_file: content_sets.yaml

osbs:
configuration:
container_file: container.yaml
extra_dir: osbs-extra/rhpam-kogito-builder-rhel8
repository:
name: containers/rhpam-7-kogito-builder
branch: rhba-7-rhel-8
50 changes: 50 additions & 0 deletions rhpam-kogito-imagestream.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
kind: ImageStreamList
apiVersion: v1
metadata:
name: rhpam-kogito-image-streams
annotations:
description: ImageStream definitions for Red Hat build of Kogito images
openshift.io/provider-display-name: Kie Group.
items:
- kind: ImageStream
apiVersion: v1
metadata:
name: rhpam-kogito-runtime-jvm-rhel8
annotations:
openshift.io/display-name: Runtime image for Kogito based on Quarkus or SpringBoot JVM image
openshift.io/provider-display-name: Kie Group.
spec:
tags:
- name: '7.11.0'
annotations:
description: Runtime image for Kogito based on Quarkus or SpringBoot JVM image
iconClass: icon-jbpm
tags: rhpam-kogito,runtime,kogito,quarkus,springboot,jvm
supports: quarkus
version: '7.11.0'
referencePolicy:
type: Local
from:
kind: DockerImage
name: registry.redhat.io/rhpam-7/rhpam-kogito-runtime-jvm-rhel8:7.11.0
- kind: ImageStream
apiVersion: v1
metadata:
name: rhpam-kogito-builder-rhel8
annotations:
openshift.io/display-name: Platform for building Kogito based on Quarkus or SpringBoot
openshift.io/provider-display-name: Kie Group.
spec:
tags:
- name: '7.11.0'
annotations:
description: Platform for building Kogito based on Quarkus or SpringBoot
iconClass: icon-jbpm
tags: rhpam-kogito,builder,kogito,quarkus,springboot
supports: quarkus
version: '7.11.0'
referencePolicy:
type: Local
from:
kind: DockerImage
name: registry.redhat.io/rhpam-7/rhpam-kogito-builder-rhel8:7.11.0
25 changes: 25 additions & 0 deletions rhpam-kogito-runtime-jvm-rhel8-overrides.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
schema_version: 1

name: "rhpam-7/rhpam-kogito-runtime-jvm-rhel8"
version: "7.11.0"
from: "registry.redhat.io/ubi8/ubi-minimal:latest"
description: "RHPAM Runtime image for Kogito based on Quarkus or SpringBoot JVM image"

labels:
- name: "com.redhat.component"
value: "rhpam-7-kogito-runtime-jvm-rhel8-container"
- name: "io.k8s.display-name"
value: "Red Hat build of Kogito based on Quarkus or SpringBoot JVM image"
- name: "io.openshift.tags"
value: "rhpam-kogito,runtime,kogito,quarkus,springboot,jvm"

packages:
content_sets_file: content_sets.yaml

osbs:
configuration:
container_file: container.yaml
extra_dir: osbs-extra/rhpam-kogito-runtime-jvm-rhel8
repository:
name: containers/rhpam-7-kogito-runtime-jvm
branch: rhba-7-rhel-8
60 changes: 56 additions & 4 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,68 @@ On this directory you can find some python scripts used to help with some repeti

Today we have these scripts:

- [build-product-image.sh](build-product-image.sh)
- [common.py](common.py)
- [list-images.py](list-images.py)
- [manage-kogito-version.py](manage-kogito-version.py)
- [push-local-registry.sh](push-local-registry.sh)
- [push-staging.py](push-staging.py)
- [run-bats.sh](run-bats.sh)
- [update-maven-artifacts.py](update-maven-artifacts.py)
- [update-tests.py](update-tests.py)
- [common.py](common.py)

### Managing Kogito images version


### Build Product Image Script

Script should not be used to build community images. Handled by `make build-prod` command.

To switch the `build_engine` do the following:

```bash
make BUILD_ENGINE=osbs build-prod
```


It receives the Product image name to build the images.

The build works in the follow CEKit build hierarchy:

- image.yaml -> kogito-community-image-name-overrides.yaml -> kogito-product-image-name-overrides.yaml

Example:

```bash
cekit --verbose --redhat build --overrides-file kogito-runtime-jvm-overrides.yaml --overrides-file rhpam-kogito-runtime-jvm-rhel8-overrides.yaml docker
```

The product image name must respect the community image name:

- rhpam-$(kogito_image_name)-rhel8


### Common script

The `common.py` script defines some common functions for the scripts.


### List Images Script

Utilitary script used to retrieve all images that can be built on this repo, there is possible to retrieve
the community image list:

```bash
$ python3 list-images.py
```

And the product image list by using the `--prod` flag:

```bash
$ python3 list-images.py --prod
```


### Managing Kogito images version script

The manage-kogito-version script will help when we need to update the current version due a new release.

Expand Down Expand Up @@ -189,6 +243,4 @@ $ python update-tests.py --examples-uri https://github.com/<yournamespace>/kogit

This will update the examples uri and/or the ref for the tests.

### Common script

The `common.py` script defines some common functions for the scripts.
40 changes: 40 additions & 0 deletions scripts/build-product-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Simple usage: /bin/sh scripts/push-local-registry.sh ${REGISTRY} ${SHORTENED_LATEST_VERSION} ${NS}

ver=$(cekit --version )
ver=$((${ver//./} + 0))
if [ ${ver//./} -lt 379 ]; then
echo "Using CEKit version $ver, Please use CEKit version 3.8.0 or greater."
exit 10
fi

image="${2}"
if [ "x${image}" == "x" ]; then
echo "image_name can't be empty.."
exit 8
fi

BUILD_ENGINE="${3:-docker}"
CEKIT_CMD="cekit --verbose --redhat"

# extract the community image name from its product relative.
# $1 - prod image name
function get_parent_image_overrides() {
echo "${1}" | awk -v FS="(rhpam-|-rhel8)" '{print $2}'
}

ACTION=${1}
case ${ACTION} in
"build")
echo "Using ${BUILD_ENGINE} build engine"
${CEKIT_CMD} build --overrides-file $(get_parent_image_overrides ${image})-overrides.yaml --overrides-file ${image_name}-overrides.yaml ${BUILD_ENGINE}
;;

"test")
${CEKIT_CMD} test --overrides-file $(get_parent_image_overrides ${image})-overrides.yaml --overrides-file ${image_name}-overrides.yaml behave
;;
*)
echo "Please use build or test actions."
;;
esac

Loading

0 comments on commit 27b8e92

Please sign in to comment.