Skip to content

Commit beac7d1

Browse files
authored
Create springboot sample 2.0.0 version (#37)
* Create new sample version Signed-off-by: thepetk <[email protected]> * Update devfile version * Update port to 8080 Signed-off-by: thepetk <[email protected]> --------- Signed-off-by: thepetk <[email protected]>
1 parent 2f8d1e8 commit beac7d1

File tree

4 files changed

+30
-51
lines changed

4 files changed

+30
-51
lines changed

README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# Creating an application with a Spring Boot code sample
22

3-
**Note:** The Spring Boot code sample uses the **8081** HTTP port.
3+
**Note:** The Spring Boot code sample version `v2.0.0` uses the **8080** HTTP port.
44

55
Before you begin creating an application with this `devfile` code sample, it's helpful to understand the relationship between the `devfile` and `Dockerfile` and how they contribute to your build. You can find these files at the following URLs:
66

7-
* [Spring Boot `devfile.yaml`](https://github.com/devfile-samples/devfile-sample-java-springboot-basic/blob/main/devfile.yaml)
8-
* [Spring Boot `Dockerfile`](https://github.com/devfile-samples/devfile-sample-java-springboot-basic/blob/main/docker/Dockerfile)
7+
- [Spring Boot `devfile.yaml`](https://github.com/devfile-samples/devfile-sample-java-springboot-basic/blob/main/devfile.yaml)
8+
- [Spring Boot `Dockerfile`](https://github.com/devfile-samples/devfile-sample-java-springboot-basic/blob/main/docker/Dockerfile)
99

1010
1. The `devfile.yaml` file has an [`image-build` component](https://github.com/devfile-samples/devfile-sample-java-springboot-basic/blob/main/devfile.yaml#L21-L27) that points to your `Dockerfile`.
1111
2. The [`docker/Dockerfile`](https://github.com/devfile-samples/devfile-sample-java-springboot-basic/blob/main/docker/Dockerfile) contains the instructions you need to build the code sample as a container image.
1212
3. The `devfile.yaml` [`kubernetes-deploy` component](https://github.com/devfile-samples/devfile-sample-java-springboot-basic/blob/main/devfile.yaml#L28-L41) points to a `deploy.yaml` file that contains instructions for deploying the built container image.
1313
4. The `devfile.yaml` [`deploy` command](https://github.com/devfile-samples/devfile-sample-java-springboot-basic/blob/main/devfile.yaml#L43-L56) completes the [outerloop](https://devfile.io/docs/2.2.0/innerloop-vs-outerloop) deployment phase by pointing to the `image-build` and `kubernetes-deploy` components to create your application.
1414

1515
### Additional resources
16-
* For more information about Spring Boot, see [Spring Boot](https://spring.io/projects/spring-boot).
17-
* For more information about devfiles, see [Devfile.io](https://devfile.io/).
18-
* For more information about the deployment outerloop, see [Devfile.io: Innerloop versus outerloop](https://devfile.io/docs/2.2.0/innerloop-vs-outerloop).
19-
* For more information about Dockerfiles, see [Dockerfile reference](https://docs.docker.com/engine/reference/builder/).
16+
17+
- For more information about Spring Boot, see [Spring Boot](https://spring.io/projects/spring-boot).
18+
- For more information about devfiles, see [Devfile.io](https://devfile.io/).
19+
- For more information about the deployment outerloop, see [Devfile.io: Innerloop versus outerloop](https://devfile.io/docs/2.2.0/innerloop-vs-outerloop).
20+
- For more information about Dockerfiles, see [Dockerfile reference](https://docs.docker.com/engine/reference/builder/).

devfile.yaml

+15-37
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
schemaVersion: 2.2.0
22
metadata:
33
name: java-springboot
4-
version: 1.2.1
4+
version: 2.0.0
55
attributes:
66
alpha.dockerimage-port: 8081
77
displayName: Spring Boot®
@@ -17,39 +17,17 @@ metadata:
1717
parent:
1818
id: java-springboot
1919
registryUrl: 'https://registry.devfile.io'
20-
version: 1.2.0
21-
components:
22-
- name: image-build
23-
image:
24-
imageName: java-springboot-image:latest
25-
dockerfile:
26-
uri: docker/Dockerfile
27-
buildContext: .
28-
rootRequired: false
29-
- name: kubernetes-deploy
30-
attributes:
31-
deployment/replicas: 1
32-
deployment/cpuRequest: 10m
33-
deployment/memoryRequest: 180Mi
34-
deployment/container-port: 8081
35-
kubernetes:
36-
uri: deploy.yaml
37-
endpoints:
38-
- name: http-8081
39-
targetPort: 8081
40-
path: /
41-
commands:
42-
- id: build-image
43-
apply:
44-
component: image-build
45-
- id: deployk8s
46-
apply:
47-
component: kubernetes-deploy
48-
- id: deploy
49-
composite:
50-
commands:
51-
- build-image
52-
- deployk8s
53-
group:
54-
kind: deploy
55-
isDefault: true
20+
version: 2.1.0
21+
components:
22+
- name: deploy
23+
attributes:
24+
deployment/replicas: 1
25+
deployment/cpuRequest: 10m
26+
deployment/memoryRequest: 180Mi
27+
deployment/container-port: 8080
28+
kubernetes:
29+
uri: kubernetes/deploy.yaml
30+
endpoints:
31+
- name: http-8080
32+
targetPort: 8080
33+
path: /

docker/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Then run the container using:
99
#
10-
# docker run -i --rm -p 8081:8081 springboot/sample-demo
10+
# docker run -i --rm -p 8080:8080 springboot/sample-demo
1111
####
1212
FROM registry.access.redhat.com/ubi8/openjdk-17:1.15-1.1682053058 AS builder
1313

@@ -27,6 +27,6 @@ RUN mv target/$(cat .env-id)-$(cat .env-version).jar target/export-run-artifact.
2727

2828
FROM registry.access.redhat.com/ubi8/openjdk-17-runtime:1.15-1.1682053056
2929
COPY --from=builder /home/jboss/project/target/export-run-artifact.jar /deployments/export-run-artifact.jar
30-
EXPOSE 8081
31-
ENTRYPOINT ["/opt/jboss/container/java/run/run-java.sh", "--server.port=8081"]
30+
EXPOSE 8080
31+
ENTRYPOINT ["/opt/jboss/container/java/run/run-java.sh", "--server.port=8080"]
3232

deploy.yaml renamed to kubernetes/deploy.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
image: java-springboot-image:latest
1818
ports:
1919
- name: http
20-
containerPort: 8081
20+
containerPort: 8080
2121
protocol: TCP
2222
resources:
2323
requests:
@@ -30,9 +30,9 @@ metadata:
3030
name: my-java-springboot-svc
3131
spec:
3232
ports:
33-
- name: http-8081
34-
port: 8081
33+
- name: http-8080
34+
port: 8080
3535
protocol: TCP
36-
targetPort: 8081
36+
targetPort: 8080
3737
selector:
3838
app: java-springboot-app

0 commit comments

Comments
 (0)