Skip to content

Commit 0fa6a7e

Browse files
authored
Merge pull request #336 from graalvm/move-tiny-containers-demo
[GR-60094] Move tiny containers demo under native-image/containerize category.
2 parents 46fe4af + d4d9d1a commit 0fa6a7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+127
-25
lines changed

.github/workflows/native-image-containerize.yml renamed to .github/workflows/containerize-spring-boot-jibber.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
name: native-image/containerize
1+
name: native-image/containerize/spring-boot-microservice-jibber
22
on:
33
push:
44
paths:
5-
- 'native-image/containerize/**'
6-
- '.github/workflows/native-image-containerize.yml'
5+
- 'native-image/containerize/spring-boot-microservice-jibber/**'
6+
- '.github/workflows/containerize-spring-boot-jibber.yml'
77
pull_request:
88
paths:
9-
- 'native-image/containerize/**'
10-
- '.github/workflows/native-image-containerize.yml'
9+
- 'native-image/containerize/spring-boot-microservice-jibber/**'
10+
- '.github/workflows/containerize-spring-boot-jibber.yml'
1111
schedule:
1212
- cron: "0 0 1 * *" # run every month
1313
workflow_dispatch:
1414
permissions:
1515
contents: read
1616
jobs:
1717
run:
18-
name: Run 'native-image/containerize'
18+
name: Run 'native-image/containerize/spring-boot-microservice-jibber'
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 20
2121
strategy:
@@ -30,9 +30,9 @@ jobs:
3030
github-token: ${{ secrets.GITHUB_TOKEN }}
3131
cache: 'maven'
3232
native-image-job-reports: 'true'
33-
- name: Run 'native-image/containerize'
33+
- name: Run 'native-image/containerize/spring-boot-microservice-jibber'
3434
run: |
35-
cd native-image/containerize
35+
cd native-image/containerize/spring-boot-microservice-jibber
3636
mvn --no-transfer-progress package
3737
mvn --no-transfer-progress native:compile -Pnative
3838
./target/benchmark-jibber &

.github/workflows/tiny-java-containers.yml renamed to .github/workflows/containerize-tiny-java-containers.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
name: tiny-java-containers
1+
name: native-image/containerize/tiny-java-containers
22
on:
33
push:
44
paths:
5-
- 'tiny-java-containers/**'
6-
- '.github/workflows/tiny-java-containers.yml'
5+
- 'native-image/containerize/tiny-java-containers/**'
6+
- '.github/workflows/containerize-tiny-java-containers.yml'
77
schedule:
88
- cron: "0 0 1 * *" # run every month
99
workflow_dispatch:
1010
permissions:
1111
contents: read
1212
jobs:
1313
run:
14-
name: Run 'tiny-java-containers'
14+
name: Run 'native-image/containerize/tiny-java-containers'
1515
runs-on: ubuntu-20.04 # Docker has changed its behavior on Ubuntu 22.04
1616
timeout-minutes: 20
17+
strategy:
18+
matrix:
19+
java-version: ['21', '24-ea']
1720
steps:
1821
- uses: actions/checkout@v4
1922
- uses: graalvm/setup-graalvm@v1
2023
with:
21-
java-version: '21'
24+
java-version: ${{ matrix.java-version }}
2225
distribution: 'graalvm'
2326
github-token: ${{ secrets.GITHUB_TOKEN }}
24-
- name: Run 'tiny-java-containers'
27+
- name: Run 'native-image/containerize/tiny-java-containers'
2528
run: |
2629
sleep_period=5
27-
cd tiny-java-containers
30+
cd native-image/containerize/tiny-java-containers
2831
# Hello World
2932
#
3033
cd helloworld

README.md

Lines changed: 3 additions & 3 deletions

native-image/containerize/README.md renamed to native-image/containerize/spring-boot-microservice-jibber/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright © 2023, Oracle and/or its affiliates.
3+
* Released under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/.
4+
*/
5+
6+
package com.example.benchmarks.jibber;
7+
8+
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.boot.SpringApplication;
10+
import org.springframework.boot.autoconfigure.SpringBootApplication;
11+
import org.springframework.http.ResponseEntity;
12+
import org.springframework.web.bind.annotation.RequestMapping;
13+
import org.springframework.web.bind.annotation.RequestMethod;
14+
import org.springframework.web.bind.annotation.RestController;
15+
16+
17+
@SpringBootApplication
18+
@RestController
19+
public class DemoApplication {
20+
21+
@Autowired
22+
Jabberwocky j;
23+
24+
public static void main(String[] args) {
25+
SpringApplication.run(DemoApplication.class, args);
26+
}
27+
28+
@RequestMapping(method = RequestMethod.GET, path = "/jibber")
29+
ResponseEntity<String> jibber() {
30+
return ResponseEntity.ok(j.generate());
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright © 2023, Oracle and/or its affiliates.
3+
* Released under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/.
4+
*/
5+
6+
package com.example.benchmarks.jibber;
7+
8+
import org.springframework.context.annotation.Scope;
9+
import org.springframework.stereotype.Service;
10+
11+
import rita.RiMarkov;
12+
13+
@Service
14+
@Scope("singleton")
15+
public class Jabberwocky {
16+
//
17+
private RiMarkov r;
18+
19+
public Jabberwocky() {
20+
loadModel();
21+
}
22+
23+
private void loadModel() {
24+
//
25+
String text = "’Twas brillig, and the slithy toves " +
26+
"Did gyre and gimble in the wabe: " +
27+
"All mimsy were the borogoves, " +
28+
"And the mome raths outgrabe. " +
29+
"Beware the Jabberwock, my son! " +
30+
"The jaws that bite, the claws that catch! " +
31+
"Beware the Jubjub bird, and shun " +
32+
"The frumious Bandersnatch! " +
33+
"He took his vorpal sword in hand; " +
34+
"Long time the manxome foe he sought— " +
35+
"So rested he by the Tumtum tree " +
36+
"And stood awhile in thought. " +
37+
"And, as in uffish thought he stood, " +
38+
"The Jabberwock, with eyes of flame, " +
39+
"Came whiffling through the tulgey wood, " +
40+
"And burbled as it came! " +
41+
"One, two! One, two! And through and through " +
42+
"The vorpal blade went snicker-snack! " +
43+
"He left it dead, and with its head " +
44+
"He went galumphing back. " +
45+
"And hast thou slain the Jabberwock? " +
46+
"Come to my arms, my beamish boy! " +
47+
"O frabjous day! Callooh! Callay! " +
48+
"He chortled in his joy. " +
49+
"’Twas brillig, and the slithy toves " +
50+
"Did gyre and gimble in the wabe: " +
51+
"All mimsy were the borogoves, " +
52+
"And the mome raths outgrabe.";
53+
this.r = new RiMarkov(3);
54+
this.r.addText(text);
55+
}
56+
public String generate() {
57+
String[] lines = this.r.generate(10);
58+
StringBuilder b = new StringBuilder();
59+
//
60+
for (String line : lines ) {
61+
b.append(line);
62+
b.append("<br/>\n");
63+
}
64+
//
65+
return b.toString();
66+
}
67+
68+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
management.endpoints.web.exposure.include=metrics,health,info,prometheus

tiny-java-containers/README.md renamed to native-image/containerize/tiny-java-containers/README.md

Lines changed: 4 additions & 6 deletions

0 commit comments

Comments
 (0)