Skip to content

Instantly share code, notes, and snippets.

@schnatterer
Last active November 18, 2020 20:46
Show Gist options
  • Save schnatterer/45b583ca255809d659e425cd4df64d3e to your computer and use it in GitHub Desktop.
Save schnatterer/45b583ca255809d659e425cd4df64d3e to your computer and use it in GitHub Desktop.
Find out the JRE version for a specific builder image version when using Cloud Native Buildpacks
BUILDER_VERSION=base-platform-api-0.3
JDK_MAJOR_VERSION=11
BUILDPACK=paketo-buildpacks/bellsoft-liberica
BUILDER_IMAGE="gcr.io/paketo-buildpacks/builder:${BUILDER_VERSION}"
JQ_PARSE_BUILDPACK_VERSION=".Labels[\"io.buildpacks.buildpack.layers\"] | fromjson | .[\"${BUILDPACK}\"] | keys[0]"
if command -v skopeo; then
# Skopeo does not need to pull the image, so its much faster when the image is not present locally
BUILD_PACK_VERSION=$(skopeo inspect "docker://${BUILDER_IMAGE}" | jq -r "${JQ_PARSE_BUILDPACK_VERSION}")
else
# docker inspect is faster when the image is present locally
docker pull "${BUILDER_IMAGE}" >/dev/null
BUILD_PACK_VERSION=$(docker image inspect gcr.io/paketo-buildpacks/builder:base-platform-api-0.3 | jq -r ".[0].Config${JQ_PARSE_BUILDPACK_VERSION}")
fi
# shellcheck disable=SC2016
curl -s \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/paketo-buildpacks/bellsoft-liberica/releases/tags/v${BUILD_PACK_VERSION}" |
jq -r '.body' |
grep "BellSoft Liberica JRE | \`${JDK_MAJOR_VERSION}" |
sed 's/BellSoft Liberica JRE | `\([^`]*\).*/\1/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment