From 7fb7db3c6adf7b2de44d8f90d4d15f04974fcb1e Mon Sep 17 00:00:00 2001 From: Armel Soro Date: Thu, 6 Apr 2023 23:32:38 +0200 Subject: [PATCH 1/3] Add new 1.3.0 version for 'java-springboot', with JDK 17 Signed-off-by: Armel Soro --- stacks/java-springboot/1.3.0/devfile.yaml | 65 +++++++++++++++++++++++ stacks/java-springboot/stack.yaml | 2 + 2 files changed, 67 insertions(+) create mode 100644 stacks/java-springboot/1.3.0/devfile.yaml diff --git a/stacks/java-springboot/1.3.0/devfile.yaml b/stacks/java-springboot/1.3.0/devfile.yaml new file mode 100644 index 00000000..2755a1ad --- /dev/null +++ b/stacks/java-springboot/1.3.0/devfile.yaml @@ -0,0 +1,65 @@ +schemaVersion: 2.1.0 +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.3.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.16-1.1696518670 + command: ["tail", "-f", "/dev/null"] + memoryLimit: 768Mi + mountSources: true + endpoints: + - name: http-springboot + targetPort: 8080 + - 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 diff --git a/stacks/java-springboot/stack.yaml b/stacks/java-springboot/stack.yaml index 4628d082..2a71709e 100644 --- a/stacks/java-springboot/stack.yaml +++ b/stacks/java-springboot/stack.yaml @@ -5,4 +5,6 @@ icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main versions: - version: 1.2.0 default: true # should have one and only one default version + # 1.3.0: with JDK 17 + - version: 1.3.0 - version: 2.0.0 From ae7d84e8972b081d34541a9967772fbca2d75478 Mon Sep 17 00:00:00 2001 From: Armel Soro Date: Thu, 6 Apr 2023 23:33:44 +0200 Subject: [PATCH 2/3] Add new 2.1.0 version for 'java-springboot', with JDK 17 Signed-off-by: Armel Soro --- stacks/java-springboot/2.1.0/devfile.yaml | 92 +++++++++++++++++++ .../java-springboot/2.1.0/docker/Dockerfile | 27 ++++++ .../2.1.0/kubernetes/deploy.yaml | 41 +++++++++ stacks/java-springboot/stack.yaml | 2 + 4 files changed, 162 insertions(+) create mode 100644 stacks/java-springboot/2.1.0/devfile.yaml create mode 100644 stacks/java-springboot/2.1.0/docker/Dockerfile create mode 100644 stacks/java-springboot/2.1.0/kubernetes/deploy.yaml diff --git a/stacks/java-springboot/2.1.0/devfile.yaml b/stacks/java-springboot/2.1.0/devfile.yaml new file mode 100644 index 00000000..9b8a5c4c --- /dev/null +++ b/stacks/java-springboot/2.1.0/devfile.yaml @@ -0,0 +1,92 @@ +schemaVersion: 2.2.0 +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.1.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.16-1.1696518670 + command: ['tail', '-f', '/dev/null'] + memoryLimit: 768Mi + mountSources: true + endpoints: + - name: http-springboot + targetPort: 8080 + - 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: http-8081 + targetPort: 8081 +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 diff --git a/stacks/java-springboot/2.1.0/docker/Dockerfile b/stacks/java-springboot/2.1.0/docker/Dockerfile new file mode 100644 index 00000000..ee91d95e --- /dev/null +++ b/stacks/java-springboot/2.1.0/docker/Dockerfile @@ -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" ] diff --git a/stacks/java-springboot/2.1.0/kubernetes/deploy.yaml b/stacks/java-springboot/2.1.0/kubernetes/deploy.yaml new file mode 100644 index 00000000..0878b82b --- /dev/null +++ b/stacks/java-springboot/2.1.0/kubernetes/deploy.yaml @@ -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" diff --git a/stacks/java-springboot/stack.yaml b/stacks/java-springboot/stack.yaml index 2a71709e..59484dfc 100644 --- a/stacks/java-springboot/stack.yaml +++ b/stacks/java-springboot/stack.yaml @@ -8,3 +8,5 @@ versions: # 1.3.0: with JDK 17 - version: 1.3.0 - version: 2.0.0 + # 2.1.0: with JDK 17 + - version: 2.1.0 From eb0570687cc6bf693c52e24747b5321e4e47f1f9 Mon Sep 17 00:00:00 2001 From: Armel Soro Date: Wed, 18 Oct 2023 17:51:57 +0200 Subject: [PATCH 3/3] Switch the default version to 1.3.0 1.3.0 is the most up-to-date version using Devfile 2.1.0 schema, for backward compatibility with current samples. We are purposely not using the most up-date version on 2.2.0 schema, as this would reportedly break current samples. See [1] for more context. [1] https://github.com/devfile/registry/pull/169#issuecomment-1551785206 Signed-off-by: Armel Soro --- stacks/java-springboot/stack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stacks/java-springboot/stack.yaml b/stacks/java-springboot/stack.yaml index 59484dfc..9eae3af4 100644 --- a/stacks/java-springboot/stack.yaml +++ b/stacks/java-springboot/stack.yaml @@ -4,9 +4,9 @@ displayName: Spring Boot icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/spring.svg versions: - version: 1.2.0 - default: true # should have one and only one default version # 1.3.0: with JDK 17 - version: 1.3.0 + default: true # should have one and only one default version - version: 2.0.0 # 2.1.0: with JDK 17 - version: 2.1.0