Skip to content

Commit ef966a9

Browse files
committed
Added Oracle GraalVM for JDK 17 and 20
1 parent f7d139a commit ef966a9

File tree

3 files changed

+123
-12
lines changed

3 files changed

+123
-12
lines changed

oci-build-examples/oci_devops_graalee_micronaut/README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Using GraalVM Enterprise in OCI DevOps to build a Micronaut REST App
1+
# Using Oracle GraalVM in OCI DevOps to build a Micronaut REST App
22

3-
This sample shows how to use `Oracle GraalVM Enterprise Edition` in `OCI DevOps build pipelines` to build a simple Micronaut hello world REST application. You can use this approach to build any high-performance Java application with Micronaut, GraalVM Enterprise and OCI DevOps.
3+
This sample shows how to use `Oracle GraalVM` in `OCI DevOps build pipelines` to build a simple Micronaut hello world REST application. You can use this approach to build any high performance Java application with Micronaut, Oracle GraalVM and OCI DevOps.
44

55
## What is GraalVM?
66

7-
- Oracle GraalVM Enterprise is a high-performance JDK distribution that can accelerate any Java workload running on the HotSpot JVM.
7+
- GraalVM is a high performance JDK distribution that can accelerate any Java workload running on the HotSpot JVM.
88

9-
- Oracle GraalVM Enterprise Native Image ahead-of-time compilation enables you to build lightweight Java applications that are smaller, faster, and use less memory and CPU. At build time, GraalVM Native Image analyzes a Java application and its dependencies to identify just what classes, methods, and fields are necessary and generates optimized machine code for just those elements.
9+
- GraalVM Native Image ahead-of-time compilation enables you to build lightweight Java applications that are smaller, faster, and use less memory and CPU. At build time, GraalVM Native Image analyzes a Java application and its dependencies to identify just what classes, methods, and fields are necessary and generates optimized machine code for just those elements.
1010

11-
- Oracle GraalVM Enterprise Edition is available for use on Oracle Cloud Infrastructure (OCI) at no additional cost.
11+
- Oracle GraalVM is available for use on Oracle Cloud Infrastructure (OCI) at no additional cost.
1212

1313
## What is Micronaut
1414

@@ -32,7 +32,7 @@ This sample shows how to use `Oracle GraalVM Enterprise Edition` in `OCI DevOps
3232
## Objectives
3333

3434
- Create an OCI build pipeline.
35-
- Make a build using Oracle GraalVM Enterprise Edition.
35+
- Make a build using Oracle GraalVM.
3636
- Here the focus will be on the build specification and DevOps build pipeline
3737

3838

@@ -82,6 +82,7 @@ Allow dynamic-group <YOUR_DynamicGroup_NAME> to use ons-topics in compartment <
8282
![](images/oci_buildpipeline_managedbuild.png)
8383

8484
- Click `Next` and provide the details.
85+
- In the `Build spec file path`, enter `build_spec.yaml` to use the [GraalVM Enterprise 22.x Java 17 build spec](build_spec.yaml). Alternatively, you can enter `build_spec_oracle_graalvm_jdk17.yaml` to use the [Oracle GraalVM for JDK 17 build spec](./build_spec_oracle_graalvm_jdk17.yaml) or `build_spec_oracle_graalvm_jdk20.yaml` to use the [Oracle GraalVM for JDK 20 build spec](./build_spec_oracle_graalvm_jdk20.yaml).
8586

8687
![](images/oci_buildstage_1.png)
8788

@@ -96,14 +97,14 @@ Allow dynamic-group <YOUR_DynamicGroup_NAME> to use ons-topics in compartment <
9697

9798
## Take a closer look at the build instructions below
9899

99-
To install and use GraalVM Enterprise with Micronaut REST in the DevOps build pipeline, the build specification file is as follows:
100+
To install and use Oracle GraalVM with Micronaut REST in the DevOps build pipeline, the build specification file is as follows:
100101

101-
1. Add the following command to install one or more required GraalVM Enterprise components. For example, this command installs Native Image along with the Java Development Kit (JDK) and other necessary dependencies.
102+
1. Add the following command to install the required Oracle GraalVM components. For example, this command installs Native Image along with the Java Development Kit (JDK) and other necessary dependencies.
102103

103104
```shell
104105
steps:
105106
- type: Command
106-
name: "Install GraalVM Enterprise 22.x Native Image for Java17"
107+
name: "Install Oracle GraalVM Enterprise 22.x Native Image for Java17"
107108
command: |
108109
yum -y install graalvm22-ee-17-native-image
109110
```
@@ -170,7 +171,9 @@ To install and use GraalVM Enterprise with Micronaut REST in the DevOps build pi
170171
type: DOCKER_IMAGE
171172
location: ${TAG}
172173
```
173-
Here's the complete [build specification](build_spec.yaml) file.
174+
Here's the complete [build specification for GraalVM Enterprise 22.x Java 17](build_spec.yaml) file. Alternatively, you can use the
175+
[build specification for Oracle GraalVM for JDK 17](./build_spec_oracle_graalvm_jdk17.yaml) or
176+
[build specification for Oracle GraalVM for JDK 20](./build_spec_oracle_graalvm_jdk20.yaml).
174177
175178
176179
## How to export the executable file outside of the build pipeline stage.
@@ -338,9 +341,9 @@ You can create an OCI Container registry and push the build container image whic
338341
References
339342
==========
340343

341-
- Using GraalVM Enterprise in DevOps Build Pipelines - https://docs.oracle.com/en-us/iaas/Content/devops/using/graalvm.htm
344+
- Using Oracle GraalVM in DevOps Build Pipelines - https://docs.oracle.com/en-us/iaas/Content/devops/using/graalvm.htm
342345
- Oracle Cloud Infrastructure DevOps - https://docs.oracle.com/en-us/iaas/Content/devops/using/home.htm
343-
- Oracle Graal VM Enterprise - https://www.oracle.com/java/graalvm/
346+
- Oracle GraalVM - https://www.oracle.com/java/graalvm/
344347

345348
Contributors
346349
===========
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: 0.1
2+
component: build
3+
timeoutInSeconds: 900
4+
runAs: root
5+
shell: bash
6+
env:
7+
variables:
8+
"JAVA_HOME" : "/usr/lib64/graalvm/graalvm-java17"
9+
# PATH is a reserved variable and cannot be defined as a variable.
10+
# However, PATH can be changed in a build step and the change is visible in subsequent steps.
11+
TAG: "mn-hello-ni:0.0.1"
12+
APP_FILE: "MnHelloRest"
13+
14+
# exportedVariables are made available to use as parameters in sucessor Build Pipeline stages
15+
# For this Build to run, the Build Pipeline needs to have a BUILDRUN_HASH parameter set
16+
exportedVariables:
17+
- BUILDRUN_HASH
18+
19+
steps:
20+
- type: Command
21+
name: "Define unique image tag"
22+
timeoutInSeconds: 140
23+
command: |
24+
echo "OCI_BUILD_RUN_ID: ${OCI_BUILD_RUN_ID}"
25+
export BUILDRUN_HASH=`echo ${OCI_BUILD_RUN_ID} | rev | cut -c 1-7`
26+
echo "BUILDRUN_HASH: " $BUILDRUN_HASH
27+
- type: Command
28+
name: "Install Oracle GraalVM for JDK 17 (Native Image and JDK)"
29+
command: |
30+
yum -y install graalvm-17-native-image
31+
- type: Command
32+
name: "Set PATH Variable."
33+
command: |
34+
export PATH=$JAVA_HOME/bin:$PATH
35+
- type: Command
36+
name: "Build a native executable"
37+
command: |
38+
./mvnw --no-transfer-progress package -Dpackaging=native-image
39+
- type: Command
40+
name: "Build a container image with Native executable"
41+
command: |
42+
docker build -f ./Dockerfile \
43+
--build-arg APP_FILE=${APP_FILE} \
44+
-t ${TAG} .
45+
outputArtifacts:
46+
- name: app_native_executable
47+
type: BINARY
48+
location: target/MnHelloRest
49+
- name: runtime_image
50+
type: DOCKER_IMAGE
51+
# this is only the locally exported container image name
52+
# this location tag doesn't affect the tag used to deliver the container image
53+
# to the Container Registry.
54+
location: ${TAG}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: 0.1
2+
component: build
3+
timeoutInSeconds: 900
4+
runAs: root
5+
shell: bash
6+
env:
7+
variables:
8+
"JAVA_HOME" : "/usr/lib64/graalvm/graalvm-java20"
9+
# PATH is a reserved variable and cannot be defined as a variable.
10+
# However, PATH can be changed in a build step and the change is visible in subsequent steps.
11+
TAG: "mn-hello-ni:0.0.1"
12+
APP_FILE: "MnHelloRest"
13+
14+
# exportedVariables are made available to use as parameters in sucessor Build Pipeline stages
15+
# For this Build to run, the Build Pipeline needs to have a BUILDRUN_HASH parameter set
16+
exportedVariables:
17+
- BUILDRUN_HASH
18+
19+
steps:
20+
- type: Command
21+
name: "Define unique image tag"
22+
timeoutInSeconds: 140
23+
command: |
24+
echo "OCI_BUILD_RUN_ID: ${OCI_BUILD_RUN_ID}"
25+
export BUILDRUN_HASH=`echo ${OCI_BUILD_RUN_ID} | rev | cut -c 1-7`
26+
echo "BUILDRUN_HASH: " $BUILDRUN_HASH
27+
- type: Command
28+
name: "Install Oracle GraalVM for JDK 20 (Native Image and JDK)"
29+
command: |
30+
yum -y install graalvm-20-native-image
31+
- type: Command
32+
name: "Set PATH Variable."
33+
command: |
34+
export PATH=$JAVA_HOME/bin:$PATH
35+
- type: Command
36+
name: "Build a native executable"
37+
command: |
38+
./mvnw --no-transfer-progress package -Dpackaging=native-image
39+
- type: Command
40+
name: "Build a container image with Native executable"
41+
command: |
42+
docker build -f ./Dockerfile \
43+
--build-arg APP_FILE=${APP_FILE} \
44+
-t ${TAG} .
45+
outputArtifacts:
46+
- name: app_native_executable
47+
type: BINARY
48+
location: target/MnHelloRest
49+
- name: runtime_image
50+
type: DOCKER_IMAGE
51+
# this is only the locally exported container image name
52+
# this location tag doesn't affect the tag used to deliver the container image
53+
# to the Container Registry.
54+
location: ${TAG}

0 commit comments

Comments
 (0)