Skip to content

Commit

Permalink
Merge pull request #477 from jhuttana/OPENJDK-2911
Browse files Browse the repository at this point in the history
[OPENJDK-2911] Merge all 3-templates into one
  • Loading branch information
jmtd authored Apr 12, 2024
2 parents 22233e0 + 6007bd4 commit a903061
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 325 deletions.
30 changes: 0 additions & 30 deletions templates/jlink/Dockerfile

This file was deleted.

74 changes: 38 additions & 36 deletions templates/jlink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,57 @@

Try it out:

## Stage 1: build and analyse application with OpenShift source-to-image (S2I)
## Stage 1: create ubi9 jlink imagestream and push a ubi9 image with jmods installed to it.

You need:

1. Access to an OpenShift instance, or, use [the s2i standalone program](https://github.com/openshift/source-to-image)
* _([you might need to use an old version](https://github.com/openshift/source-to-image/issues/1135))_
2. The OpenJDK builder image (with the customisations from the `jlink-dev` branch).
There's one at `quay.io/jdowland/jlink:latest`
3. A quickstart ([there's a specially-prepared Quarkus quickstart](https://github.com/jmtd/quarkus-quickstarts/tree/OPENJDK-631-fastjar-layout);
in the future [the mainline Quarkus quickstarts will be suitable](https://github.com/quarkusio/quarkus-quickstarts/pull/1359))
1. Access to an OpenShift instance, such as crc
2. UBI9 OpenJDK ImageStreams. You can load them from this repository with

Here's a recipe using local `s2i`
oc create -f templates/ubi9-community-image-streams.json

```
BASEIMG=quay.io/jdowland/jlink:latest
APPSRC=https://github.com/jmtd/quarkus-quickstarts.git
CONTEXTDIR=getting-started
REV=OPENJDK-631-fastjar-layout
OUTIMG=ubi9-jlinked-image
Steps to produce the imagestream and image:

s2i build --pull-policy never --context-dir=${CONTEXTDIR} -r=${REV} \
-e QUARKUS_PACKAGE_TYPE=uber-jar \
-e S2I_ENABLE_JLINK=true \
${APPSRC} \
${BASEIMG} \
${OUTIMG}
```
1. install the template

## Stage 2: multi-stage build to assemble micro runtime
oc create -f templates/jlink/jlink-builder/jlink-builder-template.yaml

You need:
This will create a Template called jlink-builder-template, you should see

template.template.openshift.io/jlink-builder-template created

and after running oc get template, it should be in the list as

jlink-builder-template Template to produce an imagestream and buildconfig for a Jlink builder image 1 (all set) 2

2. Set the parameters and create the imagestream and buildconfig from the template.

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.

oc process --parameters jlink-builder-template

NAME DESCRIPTION GENERATOR VALUE
JDK_VERSION JDK version to produce a jmods image for 11

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

1. The output image from the first stage
* _here's one we made earlier: `quay.io/jdowland/jlink:quarkus-getting-started`_
2. OpenShift, or a container runtime (e.g. Docker)
3. [this Dockerfile](Dockerfile) (In future this is an OpenShift template)
oc process jlink-builder-template -p JDK_VERSION=11 | oc create -f -

imagestream.image.openshift.io/ubi9-openjdk-11-jlink created
buildconfig.build.openshift.io/jlink-builder-jdk-11 created

With docker, from a clone of this repository, in this directory:
3. Start and observe the build

```
docker build -t myapp -f .
```
Start the build using

## Stage 3: try it out!
oc start-build jlink-builder-jdk-11

build.build.openshift.io/jlink-builder-jdk-11-1 started

Does it work?
Then observe it by using

docker run --rm -ti -p 8080 myapp
oc logs -f bc/jlink-builder-jdk-11

How big is it?
## Stage 2: build and analyse application with OpenShift source-to-image (S2I)

docker inspect -f '{{.Size}}' myapp
TODO
58 changes: 0 additions & 58 deletions templates/jlink/jlink-builder/README.md

This file was deleted.

95 changes: 0 additions & 95 deletions templates/jlink/jlink-builder/jlink-builder-template.yaml

This file was deleted.

Loading

0 comments on commit a903061

Please sign in to comment.