Skip to content

Commit 612d017

Browse files
committed
Rework buildconfigs into a template, add a readme with instructions.
1 parent 47e70e9 commit 612d017

File tree

6 files changed

+104
-93
lines changed

6 files changed

+104
-93
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# OpenShift-JLink PoC
2+
3+
Try it out:
4+
5+
## Stage 1: create ubi9 jlink imagestream and push a ubi9 image with jmods installed to it.
6+
7+
You need:
8+
9+
1. Access to an OpenShift instance, such as crc
10+
11+
Steps to produce the imagestream and image:
12+
13+
1. Switch to the openshift project and install the template
14+
15+
oc project openshift
16+
oc create -f templates/jlink/jlink-builder/jlink-builder-template.yaml
17+
18+
This will create a Template called jlink-builder-template, you should see
19+
20+
template.template.openshift.io/jlink-builder-template created
21+
22+
and after running oc get template, it should be in the list as
23+
24+
jlink-builder-template Template to produce an imagestream and buildconfig for a Jlink builder image 1 (all set) 2
25+
26+
2. Set the parameters and create the imagestream and buildconfig from the template.
27+
28+
The template for now defines a single parameter, JDK_VERSION. Setting this will set the version of the builder image used in the BuildConfig. Currently suppoted values are 11, 17, and 21. By default this will be 11.
29+
30+
oc process --parameters jlink-builder-template
31+
32+
NAME DESCRIPTION GENERATOR VALUE
33+
JDK_VERSION JDK version to produce a jmods image for 11
34+
35+
In order to set the JDK version, you will need to use the -p flag of oc process. To process the template and create the imagestreams, simply run
36+
37+
oc process -n openshift jlink-builder-template -p JDK_VERSION=11 | oc create -f -
38+
39+
imagestream.image.openshift.io/ubi9-openjdk-11-jlink created
40+
buildconfig.build.openshift.io/jlink-builder-jdk-11 created
41+
42+
3. Start and observe the build
43+
44+
Start the build using
45+
46+
oc start-build jlink-builder-jdk-11
47+
48+
build.build.openshift.io/jlink-builder-jdk-11-1 started
49+
50+
Then observe it by using
51+
52+
oc logs -f bc/jlink-builder-jdk-11
53+
54+
## Stage 2: build and analyse application with OpenShift source-to-image (S2I)
55+
56+
TODO

templates/jlink/jlink-builder/build-imagestreams.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

templates/jlink/jlink-builder/jdk-11-buildconfig.yaml

Lines changed: 0 additions & 40 deletions
This file was deleted.

templates/jlink/jlink-builder/jdk-17-buildconfig.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

templates/jlink/jlink-builder/jdk-21-buildconfig.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
apiVersion: template.openshift.io/v1
3+
kind: Template
4+
metadata:
5+
annotations:
6+
description: Template to produce an imagestream and buildconfig for a Jlink builder image
7+
name: jlink-builder-template
8+
namespace: openshift
9+
objects:
10+
- apiVersion: image.openshift.io/v1
11+
kind: ImageStream
12+
metadata:
13+
generation: 1
14+
name: ubi9-openjdk-${JDK_VERSION}-jlink
15+
namespace: default
16+
spec:
17+
lookupPolicy:
18+
local: false
19+
status:
20+
dockerImageRepository: image-registry.openshift-image-registry.svc:5000/default/ubi9-openjdk-${JDK_VERSION}-jlink
21+
publicDockerImageRepository: default-route-openshift-image-registry.apps-crc.testing/default/ubi9-openjdk-${JDK_VERSION}-jlink
22+
- apiVersion: build.openshift.io/v1
23+
kind: BuildConfig
24+
metadata:
25+
name: jlink-builder-jdk-${JDK_VERSION}
26+
labels:
27+
app: jlink-builder-jdk-${JDK_VERSION}
28+
spec:
29+
source:
30+
dockerfile: |
31+
FROM -
32+
USER 0
33+
RUN microdnf --setopt=install_weak_deps=0 --setopt=tsflags=nodocs install -y java-${JDK_VERSION}-openjdk-jmods
34+
USER 185
35+
strategy:
36+
dockerStrategy:
37+
from:
38+
kind: ImageStreamTag
39+
name: ubi9-openjdk-${JDK_VERSION}:1.18
40+
output:
41+
to:
42+
kind: ImageStreamTag
43+
name: ubi9-openjdk-${JDK_VERSION}-jlink:latest
44+
parameters:
45+
- description: JDK version to produce a jmods image and imagestream for
46+
name: JDK_VERSION
47+
value: "11"
48+
required: true

0 commit comments

Comments
 (0)