Skip to content

Commit

Permalink
Merge pull request #144 from paketo-buildpacks/oracle-native
Browse files Browse the repository at this point in the history
Add Oracle GraalVM
  • Loading branch information
anthonydahanne committed Dec 7, 2023
2 parents f10b4f7 + 26136cc commit 6c58f30
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 27 deletions.
20 changes: 16 additions & 4 deletions .github/pipeline-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,28 @@ dependencies:
- name: JDK 17
id: jdk
version_pattern: "17\\.[\\d]+\\.[\\d]+"
uses: docker://ghcr.io/paketo-buildpacks/actions/foojay-dependency:main
uses: docker://ghcr.io/paketo-buildpacks/actions/oracle-dependency:main
with:
distro: oracle
type: jdk
version: "17"
- name: JDK 21
id: jdk
version_pattern: "21\\.[\\d]+\\.[\\d]+"
uses: docker://ghcr.io/paketo-buildpacks/actions/foojay-dependency:main
uses: docker://ghcr.io/paketo-buildpacks/actions/oracle-dependency:main
with:
distro: oracle
type: jdk
version: "21"
- name: Native Image 17
id: native-image-svm
version_pattern: "17\\.[\\d]+\\.[\\d]+"
uses: docker://ghcr.io/paketo-buildpacks/actions/oracle-dependency:main
with:
type: graalvm
version: "17"
- name: Native Image 21
id: native-image-svm
version_pattern: "21\\.[\\d]+\\.[\\d]+"
uses: docker://ghcr.io/paketo-buildpacks/actions/oracle-dependency:main
with:
type: graalvm
version: "21"
2 changes: 1 addition & 1 deletion .github/workflows/pb-update-go.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Update Go
"on":
schedule:
- cron: 51 2 * * 1
- cron: 27 2 * * 1
workflow_dispatch: {}
jobs:
update:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pb-update-jdk-17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ jobs:
YJ_VERSION: 5.0.0
- uses: actions/checkout@v3
- id: dependency
uses: docker://ghcr.io/paketo-buildpacks/actions/foojay-dependency:main
uses: docker://ghcr.io/paketo-buildpacks/actions/oracle-dependency:main
with:
distro: oracle
type: jdk
version: "17"
- name: Update Buildpack Dependency
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pb-update-jdk-21.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ jobs:
YJ_VERSION: 5.0.0
- uses: actions/checkout@v3
- id: dependency
uses: docker://ghcr.io/paketo-buildpacks/actions/foojay-dependency:main
uses: docker://ghcr.io/paketo-buildpacks/actions/oracle-dependency:main
with:
distro: oracle
type: jdk
version: "21"
- name: Update Buildpack Dependency
Expand Down
115 changes: 115 additions & 0 deletions .github/workflows/pb-update-native-image-17.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Update Native Image 17
"on":
schedule:
- cron: 0 5 * * 1-5
workflow_dispatch: {}
jobs:
update:
name: Update Buildpack Dependency
runs-on:
- ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Install update-buildpack-dependency
run: |
#!/usr/bin/env bash
set -euo pipefail
go install -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/update-buildpack-dependency@latest
- name: Install yj
run: |
#!/usr/bin/env bash
set -euo pipefail
echo "Installing yj ${YJ_VERSION}"
mkdir -p "${HOME}"/bin
echo "${HOME}/bin" >> "${GITHUB_PATH}"
curl \
--location \
--show-error \
--silent \
--output "${HOME}"/bin/yj \
"https://github.com/sclevine/yj/releases/download/v${YJ_VERSION}/yj-linux"
chmod +x "${HOME}"/bin/yj
env:
YJ_VERSION: 5.0.0
- uses: actions/checkout@v3
- id: dependency
uses: docker://ghcr.io/paketo-buildpacks/actions/oracle-dependency:main
with:
type: graalvm
version: "17"
- name: Update Buildpack Dependency
id: buildpack
run: |
#!/usr/bin/env bash
set -euo pipefail
OLD_VERSION=$(yj -tj < buildpack.toml | jq -r "
.metadata.dependencies[] |
select( .id == env.ID ) |
select( .version | test( env.VERSION_PATTERN ) ) |
.version")
update-buildpack-dependency \
--buildpack-toml buildpack.toml \
--id "${ID}" \
--version-pattern "${VERSION_PATTERN}" \
--version "${VERSION}" \
--cpe-pattern "${CPE_PATTERN:-}" \
--cpe "${CPE:-}" \
--purl-pattern "${PURL_PATTERN:-}" \
--purl "${PURL:-}" \
--uri "${URI}" \
--sha256 "${SHA256}" \
--source "${SOURCE_URI}" \
--source-sha256 "${SOURCE_SHA256}"
git add buildpack.toml
git checkout -- .
if [ "$(echo "$OLD_VERSION" | awk -F '.' '{print $1}')" != "$(echo "$VERSION" | awk -F '.' '{print $1}')" ]; then
LABEL="semver:major"
elif [ "$(echo "$OLD_VERSION" | awk -F '.' '{print $2}')" != "$(echo "$VERSION" | awk -F '.' '{print $2}')" ]; then
LABEL="semver:minor"
else
LABEL="semver:patch"
fi
echo "old-version=${OLD_VERSION}" >> "$GITHUB_OUTPUT"
echo "new-version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "version-label=${LABEL}" >> "$GITHUB_OUTPUT"
env:
CPE: ${{ steps.dependency.outputs.cpe }}
CPE_PATTERN: ""
ID: native-image-svm
PURL: ${{ steps.dependency.outputs.purl }}
PURL_PATTERN: ""
SHA256: ${{ steps.dependency.outputs.sha256 }}
SOURCE_SHA256: ${{ steps.dependency.outputs.source_sha256 }}
SOURCE_URI: ${{ steps.dependency.outputs.source }}
URI: ${{ steps.dependency.outputs.uri }}
VERSION: ${{ steps.dependency.outputs.version }}
VERSION_PATTERN: 17\.[\d]+\.[\d]+
- uses: peter-evans/create-pull-request@v5
with:
author: ${{ secrets.JAVA_GITHUB_USERNAME }} <${{ secrets.JAVA_GITHUB_USERNAME }}@users.noreply.github.com>
body: Bumps `Native Image 17` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/native-image-17
commit-message: |-
Bump Native Image 17 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
Bumps Native Image 17 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}.
delete-branch: true
labels: ${{ steps.buildpack.outputs.version-label }}, type:dependency-upgrade
signoff: true
title: Bump Native Image 17 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
# `gcr.io/paketo-buildpacks/oracle`

The Paketo Buildpack for Oracle is a Cloud Native Buildpack that provides the Oracle implementations of JREs and JDKs.
The Paketo Buildpack for Oracle is a Cloud Native Buildpack that provides the Oracle implementations of JREs, JDKs, and Native Image.

This buildpack is designed to work in collaboration with other buildpacks which request contributions of JREs and JDKs.
This buildpack is designed to work in collaboration with other buildpacks which request contributions of JREs, JDKs, and Native Image.

## Behavior

This buildpack will participate if any of the following conditions are met

* Another buildpack requires `jdk`
* Another buildpack requires `jre`
* Another buildpack requires `native-image-builder`

The buildpack will do the following if a JDK is requested:

* Contributes a JDK to a layer marked `build` and `cache` with all commands on `$PATH`
* Contributes `$JAVA_HOME` configured to the build layer
* Contributes `$JDK_HOME` configure to the build layer

The buildpack will do the following if `native-image-builder` is requested:

* Contribute a JDK (see above)
* Downloads [Oracle GraalVM](https://www.graalvm.org), which includes Native Image, instead of Oracle JDK
* Prevents the JRE from being installed, even if requested

The buildpack will do the following if a JRE is requested:

* Contributes a JRE to a layer with all commands on `$PATH`
Expand All @@ -27,7 +34,7 @@ The buildpack will do the following if a JRE is requested:
* If `BPL_JMX_ENABLED = true`
* Contributes `-Djava.rmi.server.hostname=127.0.0.1`, `-Dcom.sun.management.jmxremote.authenticate=false`, `-Dcom.sun.management.jmxremote.ssl=false` & `-Dcom.sun.management.jmxremote.rmi.port=5000`
* If `BPL_DEBUG_ENABLED = true`
* Contributes `-agentlib:jdwp=transport=dt_socket,server=y,address=*:8000,suspend=n`. If Java version is 8, address parameter is `address=:8000`
* Contributes `-agentlib:jdwp=transport=dt_socket,server=y,address=*:8000,suspend=n`.
* If `BPL_JFR_ENABLED = true`
* Contributes `-XX:StartFlightRecording=dumponexit=true,filename=/tmp/recording.jfr`
* Contributes `$MALLOC_ARENA_MAX` to the layer
Expand All @@ -37,7 +44,7 @@ The buildpack will do the following if a JRE is requested:
* If `metadata.launch = true`
* Marks layer as `launch`
* Contributes Memory Calculator to a layer marked `launch`
* * Contributes Heap Dump helper to a layer marked `launch`
* Contributes Heap Dump helper to a layer marked `launch`

## Configuration

Expand Down Expand Up @@ -78,5 +85,6 @@ The buildpack optionally accepts the following bindings:

This buildpack is released under version 2.0 of the [Apache License][a].

[a]: http://www.apache.org/licenses/LICENSE-2.0
Oracle products are owned, distributed, and licensed by Oracle. This buildpack is only a tool to make it easier to install Oracle's Java-related products in your OCI image. The buildpack does not distribute or provide licenses for any Oracle software. As a user, it is your responsibility to ensure you have read, understand, and are complying with all licenses for the software you use whether installed through buildpacks or other means.

[a]: http://www.apache.org/licenses/LICENSE-2.0
44 changes: 33 additions & 11 deletions buildpack.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018-2020 the original author or authors.
# Copyright 2018-2023 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,10 +15,10 @@
api = "0.7"

[buildpack]
description = "A Cloud Native Buildpack that provides the Oracle implementations of JREs and JDKs"
description = "A Cloud Native Buildpack that provides the Oracle implementations of JREs, JDKs, and Native Image"
homepage = "https://github.com/paketo-buildpacks/oracle"
id = "paketo-buildpacks/oracle"
keywords = ["java", "jvm", "jre", "jdk"]
keywords = ["java", "jvm", "jre", "jdk", "native-image"]
name = "Paketo Buildpack for Oracle"
sbom-formats = ["application/vnd.syft+json", "application/vnd.cyclonedx+json"]
version = "{{.version}}"
Expand Down Expand Up @@ -141,10 +141,10 @@ api = "0.7"
[[metadata.dependencies]]
cpes = ["cpe:2.3:a:oracle:jdk:17.0.9:*:*:*:*:*:*:*"]
id = "jdk"
name = "oracle-jdk"
name = "Oracle JDK"
purl = "pkg:generic/oracle-jdk@17.0.9?arch=amd64"
sha256 = "ad45ac97b3bc65497376f98ee276f84f4ab55ef2f62ab7f82ac0013e5b17744a"
stacks = ["io.buildpacks.stacks.bionic", "io.paketo.stacks.tiny", "*"]
stacks = ["*"]
uri = "https://download.oracle.com/java/17/archive/jdk-17.0.9_linux-x64_bin.tar.gz"
version = "17.0.9"

Expand All @@ -155,22 +155,44 @@ api = "0.7"
[[metadata.dependencies]]
cpes = ["cpe:2.3:a:oracle:jdk:21.0.1:*:*:*:*:*:*:*"]
id = "jdk"
name = "oracle-jdk"
name = "Oracle JDK"
purl = "pkg:generic/oracle-jdk@21.0.1?arch=amd64"
sha256 = "7c1f7689db0f4b48ee6978029c4a1aecd1442a8a7637cdf43a5471d0c79712a8"
stacks = ["io.buildpacks.stacks.bionic", "io.paketo.stacks.tiny", "*"]
stacks = ["*"]
uri = "https://download.oracle.com/java/21/archive/jdk-21.0.1_linux-x64_bin.tar.gz"
version = "21.0.1"

[[metadata.dependencies.licenses]]
type = "Oracle No-Fee Terms and Conditions License"
uri = "https://www.oracle.com/downloads/licenses/no-fee-license.html"

[[stacks]]
id = "io.paketo.stacks.tiny"
[[metadata.dependencies]]
cpes = ["cpe:2.3:a:oracle:jdk:17.0.9:*:*:*:*:*:*:*:*"]
id = "native-image-svm"
name = "Oracle GraalVM"
purl = "pkg:generic/graalvm-jdk@17.0.9"
sha256 = "1f4e6dcf1f7fc2e289f92c98fc13e1de4c59b0622a039ae4d55904692392c538"
stacks = ["*"]
uri = "https://download.oracle.com/graalvm/17/archive/graalvm-jdk-17.0.9_linux-x64_bin.tar.gz"
version = "17.0.9"

[[stacks]]
id = "io.buildpacks.stacks.bionic"
[[metadata.dependencies.licenses]]
type = "GraalVM Free Terms and Conditions License"
uri = "https://www.oracle.com/downloads/licenses/graal-free-license.html"

[[metadata.dependencies]]
cpes = ["cpe:2.3:a:oracle:jdk:21.0.1:*:*:*:*:*:*:*:*"]
id = "native-image-svm"
name = "Oracle GraalVM"
purl = "pkg:generic/graalvm-jdk@21.0.1"
sha256 = "1a65e2d3f90ca12fa7c534eec2e32329515d1955cf6be1c56a7e88f02af4bce2"
stacks = ["*"]
uri = "https://download.oracle.com/graalvm/21/archive/graalvm-jdk-21.0.1_linux-x64_bin.tar.gz"
version = "21.0.1"

[[metadata.dependencies.licenses]]
type = "GraalVM Free Terms and Conditions License"
uri = "https://www.oracle.com/downloads/licenses/graal-free-license.html"

[[stacks]]
id = "*"
7 changes: 5 additions & 2 deletions cmd/main/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 the original author or authors.
* Copyright 2018-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,6 +34,9 @@ func main() {

libpak.Main(
libjvm.Detect{},
libjvm.NewBuild(logger),
libjvm.NewBuild(logger, libjvm.WithNativeImage(
libjvm.NativeImage{
BundledWithJDK: true,
})),
)
}

0 comments on commit 6c58f30

Please sign in to comment.