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

[OPENJDK-2735] Jlink Stage 3 template #471

Merged
merged 6 commits into from
Apr 5, 2024
Merged
Changes from all 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
106 changes: 106 additions & 0 deletions templates/multistage-dockerfile-buildconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
apiVersion: template.openshift.io/v1
kind: Template
metadata:
annotations:
description: Template to produce a light weight imagestream and buildconfig for a multistage build
name: multistage-build-template
objects:
##############################################################################
# the INPUT ImageStream (from phase 2)
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: intermediate
spec:
lookupPolicy:
local: true
tags:
- from:
kind: DockerImage
name: quay.io/jdowland/jlink:ubi9-jlinked-image
name: latest
referencePolicy:
type: Local
##############################################################################
# the ubi-micro ImageStream
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: ubimicro
spec:
lookupPolicy:
local: true
tags:
- from:
kind: DockerImage
name: registry.access.redhat.com/ubi9/ubi-micro
name: latest
referencePolicy:
type: Local
##############################################################################
# the OUTPUT ImageStream
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: lightweight-image
spec:
lookupPolicy:
local: false
##############################################################################
- apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
name: multistage-buildconfig
spec:
source:
images:
- from:
kind: ImageStreamTag
name: intermediate:latest
paths:
- sourcePath: /mnt/jrootfs
destinationDir: jrootfs
- sourcePath: /deployments
destinationDir: deployments
- sourcePath: /tmp/jre/.
destinationDir: customJVM
- sourcePath: /opt/jboss/container/.
destinationDir: runScripts
type: Dockerfile
dockerfile: |
FROM -
ARG JAVA_HOME=/usr/lib/jvm/java

COPY jrootfs/* /
COPY deployments /
COPY customJVM ${JAVA_HOME}
COPY runScripts /opt/jboss/container/
# these are in the micro image
RUN rm -rf /var/lib/dnf /var/lib/rpm

ENV JAVA_HOME="${JAVA_HOME}" PATH="${JAVA_HOME}/bin:$PATH"
USER 185
CMD /opt/jboss/container/java/run/run-java.sh
strategy:
type: Docker
dockerStrategy:
from:
kind: ImageStreamTag
name: ubimicro:latest
output:
to:
kind: ImageStreamTag
name: lightweight-image:latest # Tag for the final output image
triggers:
- type: ConfigChange
- type: ImageChange
imageChange:
from:
kind: ImageStreamTag
name: intermediate:latest # ImageStreamTag for phase-2 output
- type: ImageChange
imageChange:
from:
kind: ImageStreamTag
name: ubimicro:latest # ImageStreamTag for registry.access.redhat.com/ubi9/ubi-micro
Loading