Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jmtd
Copy link
Member

@jmtd jmtd commented Feb 13, 2024

WIP! TODO:

  • this is not a template!:
    • parameterize "quarkus-quickstarts"
    • parameterize "java-runtime" ?
    • route optional?
  • DeploymentConfig is deprecated; replace with Deployment
  • consider merging the phase-1 objects (oc new-app outputs) for a true one-shot

This is an attempt to capture all of the configuration for the second phase of a two-stage build: the first stage (not described) is a normal S2I-based build, and the second (this one) plucks the artifacts from the first phase and copies them into the runtime images.

The technique was described here: https://red.ht/lean-java-containers

The purpose of committing the template to the source repository is to help to ensure we maintain it and update it to prevent bit rot.

To use:

  1. Ensure your OpenShift instance has java ImageStreams. In particular the java-runtime imagestream, tag :latest.
    E.g., from the 'release'
oc create -f templates/community-image-streams.json
oc create -f templates/rutime-image-streams.json
  1. Define a new-app (oc new-app ...) based on a builder image. Care should be taken to align the JDK version in the builder with java-runtime:latest.

The build needs to output to the ImageStream "quarkus-quickstart" and must be a self-contained application within /deployments, and for which the run-java.sh script can correctly detect the start-up JAR.

E.g.

oc new-app --name=quarkus-quickstart \
    --image-stream=java:latest \
    --context-dir=getting-started \
    https://github.com/quarkusio/quarkus-quickstarts
  1. Load this template
oc create -f templates/multistage.yaml

jmtd added 2 commits February 13, 2024 16:31
These ImageStream definitions are very out-of-date. The "release"
branch contains the maintained ImageStreams. Remove these ones.

Signed-off-by: Jonathan Dowland <[email protected]>
This is an attempt to capture all of the configuration for the
second phase of a two-stage build: the first stage (not described)
is a normal S2I-based build, and the second (this one) plucks the
artifacts from the first phase and copies them into the runtime
images.

The technique was described here: <https://red.ht/lean-java-containers>

The purpose of committing the template to the source repository
is to help to ensure we maintain it and update it to prevent bit
rot.

To use:

1. Ensure your OpenShift instance has java ImageStreams. In
   particular the java-runtime imagestream, tag :latest.
   E.g., from the 'release' branch:

        oc create -f templates/community-image-streams.json
        oc create -f templates/rutime-image-streams.json

2. Define a new-app (oc new-app ...) based on a builder image.
   Care should be taken to align the JDK version in the builder
   with java-runtime:latest.

   The build needs to output to the ImageStream "quarkus-quickstart"
   and must be a self-contained application within /deployments,
   and for which the run-java.sh script can correctly detect the
   start-up JAR.

   E.g.

        oc new-app --name=quarkus-quickstart \
            --image-stream=java:latest \
            --context-dir=getting-started \
            https://github.com/quarkusio/quarkus-quickstarts

3. Load this template

        oc create -f templates/multistage.yaml

Signed-off-by: Jonathan Dowland <[email protected]>
@jmtd jmtd added the ubi9 RHEL UBI 9 label May 19, 2025
@jmtd jmtd marked this pull request as draft July 23, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ubi9 RHEL UBI 9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant