Skip to content

Commit

Permalink
Build java 21 from temurin archives for debian 12
Browse files Browse the repository at this point in the history
This is "experimental" and we shouldn't advertise it.

TODO:
1. auto updater: check github releases for a new version
   and generate an appropriate java_archives.bzl
2. eventually cover java 11, 17 on debian 12 with temurin
3. ask someone with intimate knowledge of bazel how to get
   version from the custom repository_rule into the env
   of the container

Signed-off-by: Appu Goundan <[email protected]>
  • Loading branch information
loosebazooka committed Oct 29, 2023
1 parent c4057ee commit d8a6b9a
Show file tree
Hide file tree
Showing 14 changed files with 373 additions and 92 deletions.
67 changes: 42 additions & 25 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ JAVA_ARCHITECTURES = BASE_ARCHITECTURES + [
"ppc64le",
]

JAVA_BASE_VARIATIONS = [
JAVA_VARIATIONS = [
("latest", "root"),
("nonroot", "nonroot"),
("debug", "debug_root"),
Expand All @@ -280,34 +280,27 @@ JAVA_BASE = {
JAVA_BASE |= {
"{REGISTRY}/{PROJECT_ID}/java-base-debian11:" + tag_base + "-" + arch: "//java:java_base_" + label + "_" + arch + "_debian11"
for arch in JAVA_ARCHITECTURES
for (tag_base, label) in JAVA_BASE_VARIATIONS
for (tag_base, label) in JAVA_VARIATIONS
}

JAVA_BASE |= {
"{REGISTRY}/{PROJECT_ID}/java-base-debian12:" + tag_base + "-" + arch: "//java:java_base_" + label + "_" + arch + "_debian12"
for arch in JAVA_ARCHITECTURES
for (tag_base, label) in JAVA_BASE_VARIATIONS
for (tag_base, label) in JAVA_VARIATIONS
}

# oci_image_index
JAVA_BASE |= {
"{REGISTRY}/{PROJECT_ID}/java-base-debian11:" + tag_base: "//java:java_base_" + label + "_debian11"
for (tag_base, label) in JAVA_BASE_VARIATIONS
for (tag_base, label) in JAVA_VARIATIONS
}

JAVA_BASE |= {
"{REGISTRY}/{PROJECT_ID}/java-base-debian12:" + tag_base: "//java:java_base_" + label + "_debian12"
for (tag_base, label) in JAVA_BASE_VARIATIONS
for (tag_base, label) in JAVA_VARIATIONS
}

## JAVA11
JAVA11_VARIATIONS = [
("latest", "root"),
("nonroot", "nonroot"),
("debug", "debug_root"),
("debug-nonroot", "debug_nonroot"),
]

JAVA11 = {
"{REGISTRY}/{PROJECT_ID}/java11:latest": "//java:java11_root_amd64_debian11",
"{REGISTRY}/{PROJECT_ID}/java11:nonroot": "//java:java11_nonroot_amd64_debian11",
Expand All @@ -317,24 +310,17 @@ JAVA11 = {

JAVA11 |= {
"{REGISTRY}/{PROJECT_ID}/java11-debian11:" + tag_base + "-" + arch: "//java:java11_" + label + "_" + arch + "_debian11"
for (tag_base, label) in JAVA11_VARIATIONS
for (tag_base, label) in JAVA_VARIATIONS
for arch in JAVA_ARCHITECTURES
}

# oci_image_index
JAVA11 |= {
"{REGISTRY}/{PROJECT_ID}/java11-debian11:" + tag_base: "//java:java11_" + label + "_debian11"
for (tag_base, label) in JAVA11_VARIATIONS
for (tag_base, label) in JAVA_VARIATIONS
}

## JAVA17
JAVA17_VARIATIONS = [
("latest", "root"),
("nonroot", "nonroot"),
("debug", "debug_root"),
("debug-nonroot", "debug_nonroot"),
]

JAVA17 = {
"{REGISTRY}/{PROJECT_ID}/java17:latest": "//java:java17_root_amd64_debian11",
"{REGISTRY}/{PROJECT_ID}/java17-debian12:latest": "//java:java17_root_amd64_debian12",
Expand All @@ -348,25 +334,49 @@ JAVA17 = {

JAVA17 |= {
"{REGISTRY}/{PROJECT_ID}/java17-debian11:" + tag_base + "-" + arch: "//java:java17_" + label + "_" + arch + "_debian11"
for (tag_base, label) in JAVA17_VARIATIONS
for (tag_base, label) in JAVA_VARIATIONS
for arch in JAVA_ARCHITECTURES
}

JAVA17 |= {
"{REGISTRY}/{PROJECT_ID}/java17-debian12:" + tag_base + "-" + arch: "//java:java17_" + label + "_" + arch + "_debian12"
for (tag_base, label) in JAVA17_VARIATIONS
for (tag_base, label) in JAVA_VARIATIONS
for arch in JAVA_ARCHITECTURES
}

# oci_image_index
JAVA17 |= {
"{REGISTRY}/{PROJECT_ID}/java17-debian11:" + tag_base: "//java:java17_" + label + "_debian11"
for (tag_base, label) in JAVA17_VARIATIONS
for (tag_base, label) in JAVA_VARIATIONS
}

JAVA17 |= {
"{REGISTRY}/{PROJECT_ID}/java17-debian12:" + tag_base: "//java:java17_" + label + "_debian12"
for (tag_base, label) in JAVA17_VARIATIONS
for (tag_base, label) in JAVA_VARIATIONS
}

## JAVA 21 (experimental for now)
JAVA_21_ARCHITECTURES = [
"amd64",
"arm64",
"ppc64le",
]

JAVA21 = {
"{REGISTRY}/{PROJECT_ID}/java21-debian12:" + tag_base + "-" + arch: "//java:java21_" + label + "_" + arch + "_debian12"
for (tag_base, label) in JAVA_VARIATIONS
for arch in JAVA_21_ARCHITECTURES
}

# oci_image_index
JAVA21 |= {
"{REGISTRY}/{PROJECT_ID}/java21:" + tag_base: "//java:java21_" + label + "_debian12"
for (tag_base, label) in JAVA_VARIATIONS
}

JAVA21 |= {
"{REGISTRY}/{PROJECT_ID}/java21-debian12:" + tag_base: "//java:java21_" + label + "_debian12"
for (tag_base, label) in JAVA_VARIATIONS
}

## JETTY
Expand Down Expand Up @@ -401,9 +411,16 @@ ALL |= JAVA11

ALL |= JAVA17

ALL |= JAVA21

ALL |= JETTY

sign_and_push_all(
name = "sign_and_push",
images = ALL,
)

sign_and_push_all(
name = "sign_and_push_java21",
images = JAVA21,
)
4 changes: 4 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ load(":node_archives.bzl", node_repositories = "repositories")

node_repositories()

load(":java_archives.bzl", java_repositories = "repositories")

java_repositories()

# For Jetty
http_archive(
name = "jetty",
Expand Down
128 changes: 119 additions & 9 deletions java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ load("//base:base.bzl", "deb_pkg")
load("//base:distro.bzl", "DISTROS")
load("//cacerts:java.bzl", "cacerts_java")
load("//java:jre_ver.bzl", "jre_ver")
load("//:checksums.bzl", ARCHITECTURES = "BASE_ARCHITECTURES")
load("//:debian_versions.bzl", DEBIAN_VERSIONS = "DEBIAN_PACKAGE_VERSIONS")

package(default_visibility = ["//visibility:public"])
Expand All @@ -15,14 +14,18 @@ USERS = [
"nonroot",
]

JAVA_ARCHITECTURES = ARCHITECTURES + [
JAVA_ARCHITECTURES = [
"amd64",
"arm64",
"s390x",
"ppc64le",
]

JAVA_VERSIONS = [
"11",
"17",
JAVA_21_ARCHITECTURES = [
"amd64",
"arm64",
# "s390x", adoptium doesn't have a build yet
"ppc64le",
]

JAVA_VERSIONS_PER_DISTRO = [
Expand Down Expand Up @@ -58,6 +61,36 @@ JAVA_VERSIONS_PER_DISTRO = [
for java_version, distro in JAVA_VERSIONS_PER_DISTRO
]

# special case for java 21, we will start using temurin, the goal is to slowly transition all builds
# to temurin, to also back support java 11 on debian12.
[
pkg_tar(
name = "temurin_jre_" + java_version + "_" + arch,
symlinks = {
"usr/bin/java": "/usr/lib/jvm/temurin" + java_version + "_jre_" + arch + "/bin/java",
},
deps = [
"@temurin" + java_version + "_jre_" + arch,
],
)
for arch in JAVA_21_ARCHITECTURES
for java_version in ["21"]
]

[
pkg_tar(
name = "temurin_jdk_" + java_version + "_" + arch,
symlinks = {
"usr/bin/java": "/usr/lib/jvm/temurin" + java_version + "_jdk_" + arch + "/bin/java",
},
deps = [
"@temurin" + java_version + "_jdk_" + arch,
],
)
for arch in JAVA_21_ARCHITECTURES
for java_version in ["21"]
]

# Base
[
oci_image_index(
Expand Down Expand Up @@ -196,6 +229,81 @@ DISTRO_SPECIFIC_LIBRARIES = {
for java_version, distro in JAVA_VERSIONS_PER_DISTRO
]

# Temurin Java 21
[
oci_image_index(
name = "java" + java_version + "_" + user + "_" + distro,
images = [
"java" + java_version + "_" + user + "_" + arch + "_" + distro
for arch in JAVA_21_ARCHITECTURES
],
)
for user in USERS
for java_version, distro in [("21", "debian12")]
]

[
oci_image(
name = "java" + java_version + "_" + user + "_" + arch + "_" + distro,
base = ":java_base_" + user + "_" + arch + "_" + distro,
# We expect users to use:
# cmd = ["/path/to/deploy.jar", "--option1", ...]
entrypoint = [
"/usr/bin/java",
"-jar",
],
# TODO: I don't know how to set this correctly in bazel yet, so lets get
# someone who is a bazel expert to help with this to get this informations
# directly from the custom repository rule
# env = {
# "JAVA_VERSION": TBD,
# },
tars = [
":temurin_jre_" + java_version + "_" + arch,
],
)
for arch in JAVA_21_ARCHITECTURES
for user in USERS
for java_version, distro in [("21", "debian12")]
]

# Temurin Java 21 Debug
[
oci_image_index(
name = "java" + java_version + "_debug_" + user + "_" + distro,
images = [
"java" + java_version + "_debug_" + user + "_" + arch + "_" + distro
for arch in JAVA_21_ARCHITECTURES
],
)
for user in USERS
for java_version, distro in [("21", "debian12")]
]

[
oci_image(
name = "java" + java_version + "_debug_" + user + "_" + arch + "_" + distro,
architecture = arch,
base = ":java_base_debug_" + user + "_" + arch + "_" + distro,
# We expect users to use:
# cmd = ["/path/to/deploy.jar", "--option1", ...]
entrypoint = [
"/usr/bin/java",
"-jar",
],
# see oci_image for non debug image
# env = {
# "JAVA_VERSION": TBD ,
# },
tars = [
":temurin_jdk_" + java_version + "_" + arch,
],
)
for user in USERS
for arch in JAVA_21_ARCHITECTURES
for java_version, distro in [("21", "debian12")]
]

[
structure_test(
name = "java_base" + mode + "_" + user + "_" + arch + "_" + distro + "_test",
Expand Down Expand Up @@ -225,9 +333,9 @@ DISTRO_SPECIFIC_LIBRARIES = {
"manual",
],
)
for arch in JAVA_ARCHITECTURES
for user in USERS
for java_version, distro in JAVA_VERSIONS_PER_DISTRO
for java_version, distro in JAVA_VERSIONS_PER_DISTRO + [("21", "debian12")]
for arch in (JAVA_ARCHITECTURES if java_version != "21" else JAVA_21_ARCHITECTURES)
]

[
Expand All @@ -240,9 +348,9 @@ DISTRO_SPECIFIC_LIBRARIES = {
"manual",
],
)
for arch in JAVA_ARCHITECTURES
for user in USERS
for java_version, distro in JAVA_VERSIONS_PER_DISTRO
for java_version, distro in JAVA_VERSIONS_PER_DISTRO + [("21", "debian12")]
for arch in (JAVA_ARCHITECTURES if java_version != "21" else JAVA_21_ARCHITECTURES)
]

RULE_NAMES = [
Expand All @@ -252,6 +360,8 @@ RULE_NAMES = [
("java17_root_debian12", "java17_root_amd64_debian12"),
("java17_nonroot_debian11", "java17_nonroot_amd64_debian11"),
("java17_nonroot_debian12", "java17_nonroot_amd64_debian12"),
("java21_root_debian12", "java21_root_amd64_debian12"),
("java21_nonroot_debian12", "java21_nonroot_amd64_debian12"),
]

[
Expand Down
7 changes: 7 additions & 0 deletions java/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Package: Eclipse Temurin
Version: {{VERSION}}
Architecture: {{ARCHITECTURE}}
Maintainer: Adoptium Working Group <https://adoptium.net/>
Homepage: https://adoptium.net
SHA256: {{SHA256}}
Description: Eclipse Temurin is the name of the OpenJDK distribution from Adoptium.
9 changes: 0 additions & 9 deletions java/testdata/java17_nonroot_debian12_certs.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions java/testdata/java17_nonroot_debian12_encoding.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions java/testdata/java17_nonroot_debian12_libharfbuzz.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions java/testdata/java17_root_debian12_certs.yaml

This file was deleted.

Loading

0 comments on commit d8a6b9a

Please sign in to comment.