Skip to content

Commit db0c583

Browse files
authored
Add a 2.2.2 devfile version and set https endpoint to Spring Boot stack (#367)
* Add a 2.2.2 devfile version and set https endpoint to java-springboot stack Signed-off-by: Dmytro Nochevnov <[email protected]> * Address maximum endpoint name length limitation of 15 Signed-off-by: Dmytro Nochevnov <[email protected]> --------- Signed-off-by: Dmytro Nochevnov <[email protected]>
1 parent 1e29e9e commit db0c583

File tree

5 files changed

+232
-2
lines changed

5 files changed

+232
-2
lines changed
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
schemaVersion: 2.2.2
2+
metadata:
3+
name: java-springboot
4+
displayName: Spring Boot®
5+
description: Java application using Spring Boot® and OpenJDK 11
6+
icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg
7+
tags:
8+
- Java
9+
- Spring
10+
projectType: springboot
11+
language: Java
12+
version: 1.4.0
13+
globalMemoryLimit: 2674Mi
14+
starterProjects:
15+
- name: springbootproject
16+
git:
17+
remotes:
18+
origin: "https://github.com/odo-devfiles/springboot-ex.git"
19+
components:
20+
- name: tools
21+
container:
22+
image: registry.access.redhat.com/ubi9/openjdk-17:1.17-1.1705573248
23+
command: ["tail", "-f", "/dev/null"]
24+
memoryLimit: 768Mi
25+
mountSources: true
26+
endpoints:
27+
- name: https-springbt
28+
targetPort: 8080
29+
protocol: https
30+
- exposure: none
31+
name: debug
32+
targetPort: 5858
33+
volumeMounts:
34+
- name: m2
35+
path: /home/user/.m2
36+
env:
37+
- name: DEBUG_PORT
38+
value: "5858"
39+
- name: m2
40+
volume:
41+
size: 3Gi
42+
commands:
43+
- id: build
44+
exec:
45+
component: tools
46+
workingDir: ${PROJECT_SOURCE}
47+
commandLine: "mvn clean -Dmaven.repo.local=/home/user/.m2/repository package -Dmaven.test.skip=true"
48+
group:
49+
kind: build
50+
isDefault: true
51+
- id: run
52+
exec:
53+
component: tools
54+
workingDir: ${PROJECT_SOURCE}
55+
commandLine: "mvn -Dmaven.repo.local=/home/user/.m2/repository spring-boot:run"
56+
group:
57+
kind: run
58+
isDefault: true
59+
- id: debug
60+
exec:
61+
component: tools
62+
workingDir: ${PROJECT_SOURCE}
63+
commandLine: "java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=${DEBUG_PORT},suspend=n -jar target/*.jar"
64+
group:
65+
kind: debug
66+
isDefault: true
+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
schemaVersion: 2.2.2
2+
metadata:
3+
name: java-springboot
4+
displayName: Spring Boot®
5+
description: Java application using Spring Boot® and OpenJDK 11
6+
icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg
7+
tags:
8+
- Java
9+
- Spring
10+
projectType: springboot
11+
language: Java
12+
version: 2.2.0
13+
globalMemoryLimit: 2674Mi
14+
starterProjects:
15+
- name: springbootproject
16+
git:
17+
remotes:
18+
origin: "https://github.com/odo-devfiles/springboot-ex.git"
19+
components:
20+
- name: tools
21+
container:
22+
image: registry.access.redhat.com/ubi9/openjdk-17:1.17-1.1705573248
23+
command: ['tail', '-f', '/dev/null']
24+
memoryLimit: 768Mi
25+
mountSources: true
26+
endpoints:
27+
- name: https-springbt
28+
targetPort: 8080
29+
protocol: https
30+
- exposure: none
31+
name: debug
32+
targetPort: 5858
33+
volumeMounts:
34+
- name: m2
35+
path: /home/user/.m2
36+
env:
37+
- name: DEBUG_PORT
38+
value: "5858"
39+
- name: m2
40+
volume:
41+
size: 3Gi
42+
- name: build
43+
image:
44+
imageName: java-springboot-image:latest
45+
dockerfile:
46+
uri: docker/Dockerfile
47+
buildContext: .
48+
rootRequired: false
49+
- name: deploy
50+
kubernetes:
51+
uri: kubernetes/deploy.yaml
52+
endpoints:
53+
- name: https-8081
54+
targetPort: 8081
55+
protocol: https
56+
commands:
57+
- id: build
58+
exec:
59+
component: tools
60+
workingDir: ${PROJECT_SOURCE}
61+
commandLine: 'mvn clean -Dmaven.repo.local=/home/user/.m2/repository package -Dmaven.test.skip=true'
62+
group:
63+
kind: build
64+
isDefault: true
65+
- id: run
66+
exec:
67+
component: tools
68+
workingDir: ${PROJECT_SOURCE}
69+
commandLine: 'mvn -Dmaven.repo.local=/home/user/.m2/repository spring-boot:run'
70+
group:
71+
kind: run
72+
isDefault: true
73+
- id: debug
74+
exec:
75+
component: tools
76+
workingDir: ${PROJECT_SOURCE}
77+
commandLine: 'java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=${DEBUG_PORT},suspend=n -jar target/*.jar'
78+
group:
79+
kind: debug
80+
isDefault: true
81+
- id: build-image
82+
apply:
83+
component: build
84+
- id: deployk8s
85+
apply:
86+
component: deploy
87+
- id: deploy
88+
composite:
89+
commands:
90+
- build-image
91+
- deployk8s
92+
group:
93+
kind: deploy
94+
isDefault: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
####
2+
# This Dockerfile is used in order to build a container that runs the Spring Boot application
3+
#
4+
# Build the image with:
5+
#
6+
# docker build -f docker/Dockerfile -t springboot/sample-demo .
7+
#
8+
# Then run the container using:
9+
#
10+
# docker run -i --rm -p 8081:8081 springboot/sample-demo
11+
####
12+
FROM quay.io/devfile/maven:3.8.1-openjdk-17-slim
13+
14+
WORKDIR /build
15+
16+
# Build dependency offline to streamline build
17+
COPY pom.xml .
18+
RUN mvn dependency:go-offline
19+
20+
COPY src src
21+
RUN mvn package -Dmaven.test.skip=true
22+
23+
FROM registry.access.redhat.com/ubi9/openjdk-17-runtime:latest
24+
COPY --from=0 /build/target/demo-0.0.1-SNAPSHOT.jar /app/target/demo-0.0.1-SNAPSHOT.jar
25+
26+
EXPOSE 8081
27+
ENTRYPOINT [ "java", "-jar", "/app/target/demo-0.0.1-SNAPSHOT.jar", "--server.port=8081" ]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: my-java-springboot-svc
5+
spec:
6+
ports:
7+
- name: http-8081
8+
port: 8081
9+
protocol: TCP
10+
targetPort: 8081
11+
selector:
12+
app: java-springboot-app
13+
---
14+
kind: Deployment
15+
apiVersion: apps/v1
16+
metadata:
17+
name: my-java-springboot
18+
spec:
19+
replicas: 1
20+
selector:
21+
matchLabels:
22+
app: java-springboot-app
23+
template:
24+
metadata:
25+
labels:
26+
app: java-springboot-app
27+
spec:
28+
containers:
29+
- name: my-java-springboot
30+
image: java-springboot-image:latest
31+
ports:
32+
- name: http
33+
containerPort: 8081
34+
protocol: TCP
35+
resources:
36+
requests:
37+
memory: "180Mi"
38+
cpu: "10m"
39+
limits:
40+
memory: "300Mi"
41+
cpu: "100m"

stacks/java-springboot/stack.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ displayName: Spring Boot
44
icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg
55
versions:
66
- version: 1.2.0
7-
# 1.3.0: with JDK 17
7+
# 1.3.0, 1.4.0: with JDK 17
88
- version: 1.3.0
9+
- version: 1.4.0
910
default: true # should have one and only one default version
1011
- version: 2.0.0
11-
# 2.1.0: with JDK 17
12+
# 2.1.0, 2.2.0: with JDK 17
1213
- version: 2.1.0
14+
- version: 2.2.0

0 commit comments

Comments
 (0)