Skip to content

Commit d34ca87

Browse files
committed
Merge all 3-templates into one
Signed-off-by: Jayashree Huttanagoudar <[email protected]>
1 parent 22233e0 commit d34ca87

File tree

1 file changed

+190
-0
lines changed

1 file changed

+190
-0
lines changed

templates/jlink/jlinked-app.yaml

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
apiVersion: template.openshift.io/v1
3+
kind: Template
4+
metadata:
5+
annotations:
6+
description: Template to produce imagestreams and buildconfigs for jlinked application
7+
name: jlink-app-template
8+
##############################################################################
9+
# List of parameters required to create template
10+
parameters:
11+
- description: JDK version to produce a jmods image and imagestream for
12+
name: JDK_VERSION
13+
value: "11"
14+
required: true
15+
- description: Application to run the jlink workflow on
16+
name: APP_URI
17+
required: true
18+
- description: Git Ref to run the jlink workflow on
19+
name: REF
20+
required: true
21+
- description: Context Dir to use for the jlink workflow
22+
name: CONTEXT_DIR
23+
required: true
24+
##############################################################################
25+
# Following are the objects(imagestream and buildconfigs) for all the 3-stages
26+
objects:
27+
##############################################################################
28+
# stage-1: Output ImageStream
29+
- apiVersion: image.openshift.io/v1
30+
kind: ImageStream
31+
metadata:
32+
name: ubi9-openjdk-${JDK_VERSION}-jlink
33+
spec:
34+
lookupPolicy:
35+
local: false
36+
##############################################################################
37+
# stage-1: BuildConfig
38+
- apiVersion: build.openshift.io/v1
39+
kind: BuildConfig
40+
metadata:
41+
name: jlink-builder-jdk-${JDK_VERSION}
42+
labels:
43+
app: jlink-builder-jdk-${JDK_VERSION}
44+
spec:
45+
source:
46+
dockerfile: |
47+
FROM -
48+
USER 0
49+
RUN microdnf --setopt=install_weak_deps=0 --setopt=tsflags=nodocs install -y java-${JDK_VERSION}-openjdk-jmods
50+
RUN mkdir -p /mnt/jrootfs
51+
RUN microdnf install --installroot /mnt/jrootfs --releasever 9 --setopt install_weak_deps=0 --nodocs -y \
52+
--config=/etc/dnf/dnf.conf \
53+
--noplugins \
54+
--setopt=cachedir=/var/cache \
55+
--setopt=reposdir=/etc/yum.repos.d \
56+
--setopt=varsdir=/etc/dnf/vars \
57+
grep gawk
58+
RUN rm -rf /mnt/jrootfs/var/cache/* /mnt/jrootfs/var/lib/rpm /mnt/jrootfs/var/lib/dnf
59+
USER 185
60+
strategy:
61+
dockerStrategy:
62+
from:
63+
kind: ImageStreamTag
64+
name: ubi9-openjdk-${JDK_VERSION}:1.18 # Refer README.md to create this ImageStream
65+
output:
66+
to:
67+
kind: ImageStreamTag
68+
name: ubi9-openjdk-${JDK_VERSION}-jlink:latest
69+
##############################################################################
70+
# stage-2: Output ImageStream
71+
- apiVersion: image.openshift.io/v1
72+
kind: ImageStream
73+
metadata:
74+
name: intermediate
75+
spec:
76+
lookupPolicy:
77+
local: false
78+
##############################################################################
79+
# stage-2: BuildConfig
80+
- apiVersion: build.openshift.io/v1
81+
kind: BuildConfig
82+
metadata:
83+
name: jlink-s2i-jdk-${JDK_VERSION}
84+
labels:
85+
app: jlink-s2i-jdk-${JDK_VERSION}
86+
spec:
87+
source:
88+
type: Git
89+
git:
90+
uri: ${APP_URI}
91+
ref: ${REF}
92+
contextDir: ${CONTEXT_DIR}
93+
strategy:
94+
sourceStrategy:
95+
from:
96+
kind: ImageStreamTag
97+
name: ubi9-openjdk-${JDK_VERSION}-jlink:latest # Output Imagestream from stage-1
98+
pullPolicy: Always
99+
env:
100+
- name: S2I_ENABLE_JLINK
101+
value: "true"
102+
- name: LOGGING_SCRIPT_DEBUG
103+
value: "true"
104+
output:
105+
to:
106+
kind: ImageStreamTag
107+
name: intermediate:latest
108+
##############################################################################
109+
# stage-3: The ubi-micro ImageStream
110+
- apiVersion: image.openshift.io/v1
111+
kind: ImageStream
112+
metadata:
113+
name: ubimicro
114+
spec:
115+
lookupPolicy:
116+
local: true
117+
tags:
118+
- from:
119+
kind: DockerImage
120+
name: registry.access.redhat.com/ubi9/ubi-micro
121+
name: latest
122+
referencePolicy:
123+
type: Local
124+
##############################################################################
125+
# stage-3: Output ImageStream
126+
- apiVersion: image.openshift.io/v1
127+
kind: ImageStream
128+
metadata:
129+
name: lightweight-image
130+
spec:
131+
lookupPolicy:
132+
local: false
133+
##############################################################################
134+
# stage-3: BuildConfig
135+
- apiVersion: build.openshift.io/v1
136+
kind: BuildConfig
137+
metadata:
138+
name: multistage-buildconfig
139+
spec:
140+
source:
141+
images:
142+
- from:
143+
kind: ImageStreamTag
144+
name: intermediate:latest
145+
paths:
146+
- sourcePath: /mnt/jrootfs
147+
destinationDir: jrootfs
148+
- sourcePath: /deployments
149+
destinationDir: deployments
150+
- sourcePath: /tmp/jre/.
151+
destinationDir: customJVM
152+
- sourcePath: /opt/jboss/container/.
153+
destinationDir: runScripts
154+
type: Dockerfile
155+
dockerfile: |
156+
FROM -
157+
ARG JAVA_HOME=/usr/lib/jvm/java
158+
159+
COPY jrootfs/* /
160+
COPY deployments /
161+
COPY customJVM ${JAVA_HOME}
162+
COPY runScripts /opt/jboss/container/
163+
# these are in the micro image
164+
RUN rm -rf /var/lib/dnf /var/lib/rpm
165+
166+
ENV JAVA_HOME="${JAVA_HOME}" PATH="${JAVA_HOME}/bin:$PATH"
167+
USER 185
168+
CMD /opt/jboss/container/java/run/run-java.sh
169+
strategy:
170+
type: Docker
171+
dockerStrategy:
172+
from:
173+
kind: ImageStreamTag
174+
name: ubimicro:latest
175+
output:
176+
to:
177+
kind: ImageStreamTag
178+
name: lightweight-image:latest # Tag for the final output image
179+
# triggers:
180+
# - type: ConfigChange
181+
# - type: ImageChange
182+
# imageChange:
183+
# from:
184+
# kind: ImageStreamTag
185+
# name: intermediate:latest # output of stage-2
186+
# - type: ImageChange
187+
# imageChange:
188+
# from:
189+
# kind: ImageStreamTag
190+
# name: ubimicro:latest # ImageStreamTag for registry.access.redhat.com/ubi9/ubi-micro

0 commit comments

Comments
 (0)