Skip to content

Commit

Permalink
Add a 2.2.2 devfile version and set https endpoint to Spring Boot sta…
Browse files Browse the repository at this point in the history
…ck (#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]>
  • Loading branch information
dmytro-ndp authored Apr 23, 2024
1 parent 1e29e9e commit db0c583
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 2 deletions.
66 changes: 66 additions & 0 deletions stacks/java-springboot/1.4.0/devfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
schemaVersion: 2.2.2
metadata:
name: java-springboot
displayName: Spring Boot®
description: Java application using Spring Boot® and OpenJDK 11
icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg
tags:
- Java
- Spring
projectType: springboot
language: Java
version: 1.4.0
globalMemoryLimit: 2674Mi
starterProjects:
- name: springbootproject
git:
remotes:
origin: "https://github.com/odo-devfiles/springboot-ex.git"
components:
- name: tools
container:
image: registry.access.redhat.com/ubi9/openjdk-17:1.17-1.1705573248
command: ["tail", "-f", "/dev/null"]
memoryLimit: 768Mi
mountSources: true
endpoints:
- name: https-springbt
targetPort: 8080
protocol: https
- exposure: none
name: debug
targetPort: 5858
volumeMounts:
- name: m2
path: /home/user/.m2
env:
- name: DEBUG_PORT
value: "5858"
- name: m2
volume:
size: 3Gi
commands:
- id: build
exec:
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "mvn clean -Dmaven.repo.local=/home/user/.m2/repository package -Dmaven.test.skip=true"
group:
kind: build
isDefault: true
- id: run
exec:
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "mvn -Dmaven.repo.local=/home/user/.m2/repository spring-boot:run"
group:
kind: run
isDefault: true
- id: debug
exec:
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=${DEBUG_PORT},suspend=n -jar target/*.jar"
group:
kind: debug
isDefault: true
94 changes: 94 additions & 0 deletions stacks/java-springboot/2.2.0/devfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
schemaVersion: 2.2.2
metadata:
name: java-springboot
displayName: Spring Boot®
description: Java application using Spring Boot® and OpenJDK 11
icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg
tags:
- Java
- Spring
projectType: springboot
language: Java
version: 2.2.0
globalMemoryLimit: 2674Mi
starterProjects:
- name: springbootproject
git:
remotes:
origin: "https://github.com/odo-devfiles/springboot-ex.git"
components:
- name: tools
container:
image: registry.access.redhat.com/ubi9/openjdk-17:1.17-1.1705573248
command: ['tail', '-f', '/dev/null']
memoryLimit: 768Mi
mountSources: true
endpoints:
- name: https-springbt
targetPort: 8080
protocol: https
- exposure: none
name: debug
targetPort: 5858
volumeMounts:
- name: m2
path: /home/user/.m2
env:
- name: DEBUG_PORT
value: "5858"
- name: m2
volume:
size: 3Gi
- name: build
image:
imageName: java-springboot-image:latest
dockerfile:
uri: docker/Dockerfile
buildContext: .
rootRequired: false
- name: deploy
kubernetes:
uri: kubernetes/deploy.yaml
endpoints:
- name: https-8081
targetPort: 8081
protocol: https
commands:
- id: build
exec:
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: 'mvn clean -Dmaven.repo.local=/home/user/.m2/repository package -Dmaven.test.skip=true'
group:
kind: build
isDefault: true
- id: run
exec:
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: 'mvn -Dmaven.repo.local=/home/user/.m2/repository spring-boot:run'
group:
kind: run
isDefault: true
- id: debug
exec:
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: 'java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=${DEBUG_PORT},suspend=n -jar target/*.jar'
group:
kind: debug
isDefault: true
- id: build-image
apply:
component: build
- id: deployk8s
apply:
component: deploy
- id: deploy
composite:
commands:
- build-image
- deployk8s
group:
kind: deploy
isDefault: true
27 changes: 27 additions & 0 deletions stacks/java-springboot/2.2.0/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
####
# This Dockerfile is used in order to build a container that runs the Spring Boot application
#
# Build the image with:
#
# docker build -f docker/Dockerfile -t springboot/sample-demo .
#
# Then run the container using:
#
# docker run -i --rm -p 8081:8081 springboot/sample-demo
####
FROM quay.io/devfile/maven:3.8.1-openjdk-17-slim

WORKDIR /build

# Build dependency offline to streamline build
COPY pom.xml .
RUN mvn dependency:go-offline

COPY src src
RUN mvn package -Dmaven.test.skip=true

FROM registry.access.redhat.com/ubi9/openjdk-17-runtime:latest
COPY --from=0 /build/target/demo-0.0.1-SNAPSHOT.jar /app/target/demo-0.0.1-SNAPSHOT.jar

EXPOSE 8081
ENTRYPOINT [ "java", "-jar", "/app/target/demo-0.0.1-SNAPSHOT.jar", "--server.port=8081" ]
41 changes: 41 additions & 0 deletions stacks/java-springboot/2.2.0/kubernetes/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
kind: Service
apiVersion: v1
metadata:
name: my-java-springboot-svc
spec:
ports:
- name: http-8081
port: 8081
protocol: TCP
targetPort: 8081
selector:
app: java-springboot-app
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: my-java-springboot
spec:
replicas: 1
selector:
matchLabels:
app: java-springboot-app
template:
metadata:
labels:
app: java-springboot-app
spec:
containers:
- name: my-java-springboot
image: java-springboot-image:latest
ports:
- name: http
containerPort: 8081
protocol: TCP
resources:
requests:
memory: "180Mi"
cpu: "10m"
limits:
memory: "300Mi"
cpu: "100m"
6 changes: 4 additions & 2 deletions stacks/java-springboot/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ displayName: Spring Boot
icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg
versions:
- version: 1.2.0
# 1.3.0: with JDK 17
# 1.3.0, 1.4.0: with JDK 17
- version: 1.3.0
- version: 1.4.0
default: true # should have one and only one default version
- version: 2.0.0
# 2.1.0: with JDK 17
# 2.1.0, 2.2.0: with JDK 17
- version: 2.1.0
- version: 2.2.0

0 comments on commit db0c583

Please sign in to comment.