Skip to content

Commit

Permalink
Added base image for java. Fixes #439 (#547)
Browse files Browse the repository at this point in the history
* Added base image for java

* Added docker tags and push to cloudbuild.yaml

* Update cloudbuild.yaml

Co-authored-by: Chanseok Oh <chanseok@google.com>

* Update cloudbuild.yaml

Co-authored-by: Chanseok Oh <chanseok@google.com>

* Updated as suggested in review comments

Co-authored-by: Chanseok Oh <chanseok@google.com>
  • Loading branch information
dhawani and chanseokoh committed Jul 10, 2020
1 parent d185276 commit 5a5744e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 5 deletions.
16 changes: 16 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ steps:
#!/bin/sh
set -o errexit
set -o xtrace
bazel run --host_force_python=PY2 //java:java_base_debian9
bazel run --host_force_python=PY2 //java:java_base_debug_debian9
bazel run --host_force_python=PY2 //java:java_base_debian10
bazel run --host_force_python=PY2 //java:java_base_debug_debian10
bazel run --host_force_python=PY2 //java:java8_debian9
bazel run --host_force_python=PY2 //java:java8_debug_debian9
bazel run --host_force_python=PY2 //java:java11_debian9
Expand All @@ -91,6 +95,10 @@ steps:
#!/bin/sh
set -o errexit
set -o xtrace
docker tag bazel/java:java_base_debian9 gcr.io/$PROJECT_ID/java:base
docker tag bazel/java:java_base_debian9 gcr.io/$PROJECT_ID/java-debian9:base
docker tag bazel/java:java_base_debug_debian9 gcr.io/$PROJECT_ID/java:base-debug
docker tag bazel/java:java_base_debug_debian9 gcr.io/$PROJECT_ID/java-debian9:base-debug
docker tag bazel/java:java8_debian9 gcr.io/$PROJECT_ID/java:latest
docker tag bazel/java:java8_debian9 gcr.io/$PROJECT_ID/java:8
docker tag bazel/java:java8_debian9 gcr.io/$PROJECT_ID/java-debian9:latest
Expand All @@ -103,6 +111,8 @@ steps:
docker tag bazel/java:java11_debian9 gcr.io/$PROJECT_ID/java-debian9:11
docker tag bazel/java:java11_debug_debian9 gcr.io/$PROJECT_ID/java:11-debug
docker tag bazel/java:java11_debug_debian9 gcr.io/$PROJECT_ID/java-debian9:11-debug
docker tag bazel/java:java_base_debian10 gcr.io/$PROJECT_ID/java-debian10:base
docker tag bazel/java:java_base_debug_debian10 gcr.io/$PROJECT_ID/java-debian10:base-debug
docker tag bazel/java:java11_debian10 gcr.io/$PROJECT_ID/java-debian10:latest
docker tag bazel/java:java11_debian10 gcr.io/$PROJECT_ID/java-debian10:11
docker tag bazel/java:java11_debug_debian10 gcr.io/$PROJECT_ID/java-debian10:debug
Expand Down Expand Up @@ -239,12 +249,18 @@ images:
- 'gcr.io/$PROJECT_ID/java:8-debug'
- 'gcr.io/$PROJECT_ID/java:11'
- 'gcr.io/$PROJECT_ID/java:11-debug'
- 'gcr.io/$PROJECT_ID/java:base'
- 'gcr.io/$PROJECT_ID/java:base-debug'
- 'gcr.io/$PROJECT_ID/java-debian9:base'
- 'gcr.io/$PROJECT_ID/java-debian9:base-debug'
- 'gcr.io/$PROJECT_ID/java-debian9:latest'
- 'gcr.io/$PROJECT_ID/java-debian9:8'
- 'gcr.io/$PROJECT_ID/java-debian9:debug'
- 'gcr.io/$PROJECT_ID/java-debian9:8-debug'
- 'gcr.io/$PROJECT_ID/java-debian9:11'
- 'gcr.io/$PROJECT_ID/java-debian9:11-debug'
- 'gcr.io/$PROJECT_ID/java-debian10:base'
- 'gcr.io/$PROJECT_ID/java-debian10:base-debug'
- 'gcr.io/$PROJECT_ID/java-debian10:latest'
- 'gcr.io/$PROJECT_ID/java-debian10:11'
- 'gcr.io/$PROJECT_ID/java-debian10:debug'
Expand Down
28 changes: 23 additions & 5 deletions java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ DISTRO_VERSIONS = {
"_debian10",
]]

[container_image(
name = rule_name + distro_suffix,
base = ("//cc:cc" if (not ("debug" in rule_name)) else "//cc:debug") + distro_suffix,
[[container_image(
name = "java_base" + mode + distro_suffix,
base = ("//cc:cc" if (not ("debug" in mode)) else "//cc:debug") + distro_suffix,
debs = [
DISTRO_PACKAGES[distro_suffix]["zlib1g"],
DISTRO_PACKAGES[distro_suffix]["libjpeg62-turbo"],
Expand All @@ -42,7 +42,17 @@ DISTRO_VERSIONS = {
DISTRO_PACKAGES[distro_suffix]["libexpat1"],
DISTRO_PACKAGES[distro_suffix]["libfontconfig1"],
DISTRO_PACKAGES[distro_suffix]["libuuid1"],
] + [DISTRO_PACKAGES[distro_suffix][deb] for deb in java_debs],
],
tars = [":cacerts_java" + distro_suffix],
) for mode in [
"",
"_debug",
]] for distro_suffix in DISTRO_SUFFIXES]

[container_image(
name = rule_name + distro_suffix,
base = ":java_base" + ("_debug" if ("debug" in rule_name) else "") + distro_suffix,
debs = [DISTRO_PACKAGES[distro_suffix][deb] for deb in java_debs],
# We expect users to use:
# cmd = ["/path/to/deploy.jar", "--option1", ...]
entrypoint = [
Expand All @@ -55,7 +65,6 @@ DISTRO_VERSIONS = {
symlinks = {
"/usr/bin/java": java_executable_path,
},
tars = [":cacerts_java" + distro_suffix],
) for (distro_suffix, rule_name, java_debs, java_executable_path) in [
(
"_debian9",
Expand Down Expand Up @@ -125,6 +134,15 @@ alias(
actual = ":java11_debug_debian9",
)

[[container_test(
name = "java_base" + mode + distro_suffix + "_test",
configs = ["testdata/java_base" + mode + ".yaml"],
image = ":java_base" + mode + distro_suffix,
) for mode in [
"",
"_debug",
]] for distro_suffix in DISTRO_SUFFIXES]

container_test(
name = "java8_debian9_test",
configs = ["testdata/java8.yaml"],
Expand Down
14 changes: 14 additions & 0 deletions java/testdata/java_base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
schemaVersion: "2.0.0"
fileExistenceTests:
- name: certs
path: "/etc/ssl/certs/java/cacerts"
shouldExist: true
- name: no-busybox
path: "/busybox/sh"
shouldExist: false
- name: no-shell
path: "/bin/sh"
shouldExist: false
- name: no-jvm
path: "/usr/lib/jvm"
shouldExist: false
14 changes: 14 additions & 0 deletions java/testdata/java_base_debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
schemaVersion: "2.0.0"
fileExistenceTests:
- name: certs
path: "/etc/ssl/certs/java/cacerts"
shouldExist: true
- name: busybox
path: "/busybox/sh"
shouldExist: true
- name: no-shell
path: "/bin/sh"
shouldExist: false
- name: no-jvm
path: "/usr/lib/jvm"
shouldExist: false

0 comments on commit 5a5744e

Please sign in to comment.