Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Java 11 images (latest and debug) / add more tags #285

Merged
merged 9 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ container_bundle(
"gcr.io/{PROJECT_ID}/cc:latest": "//cc",
"gcr.io/{PROJECT_ID}/cc:debug": "//cc:debug",
"gcr.io/{PROJECT_ID}/java:latest": "//java:java8",
"gcr.io/{PROJECT_ID}/java:debug": "//java:debug",
"gcr.io/{PROJECT_ID}/java/jetty:latest": "//java/jetty",
"gcr.io/{PROJECT_ID}/java/jetty:debug": "//java/jetty:debug",
"gcr.io/{PROJECT_ID}/java:8": "//java:java8",
"gcr.io/{PROJECT_ID}/java:debug": "//java:java8_debug",
"gcr.io/{PROJECT_ID}/java:8-debug": "//java:java8_debug",
"gcr.io/{PROJECT_ID}/java:11": "//java:java11",
"gcr.io/{PROJECT_ID}/java:11-debug": "//java:java11_debug",
"gcr.io/{PROJECT_ID}/java/jetty:latest": "//java/jetty:jetty_java8",
"gcr.io/{PROJECT_ID}/java/jetty:java8": "//java/jetty:jetty_java8",
"gcr.io/{PROJECT_ID}/java/jetty:debug": "//java/jetty:jetty_java8_debug",
"gcr.io/{PROJECT_ID}/java/jetty:java8-debug": "//java/jetty:jetty_java8_debug",
"gcr.io/{PROJECT_ID}/python3:latest": "//experimental/python3:python3",
"gcr.io/{PROJECT_ID}/python3:debug": "//experimental/python3:debug",
"gcr.io/{PROJECT_ID}/python2.7:latest": "//experimental/python2.7:python27",
Expand Down
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ dpkg_list(
#java
"zlib1g",
"openjdk-8-jre-headless",
"openjdk-11-jre-headless",

#python
"libpython2.7-minimal",
Expand Down
38 changes: 31 additions & 7 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,39 @@ steps:
args: ['run', '//java:java8']
- name: gcr.io/cloud-builders/docker
args: ['tag', 'bazel/java:java8', 'gcr.io/$PROJECT_ID/java:latest']
- name: gcr.io/cloud-builders/docker
args: ['tag', 'bazel/java:java8', 'gcr.io/$PROJECT_ID/java:8']

- name: gcr.io/cloud-builders/bazel
args: ['run', '//java:java8_debug']
- name: gcr.io/cloud-builders/docker
args: ['tag', 'bazel/java:java8_debug', 'gcr.io/$PROJECT_ID/java:debug']
- name: gcr.io/cloud-builders/docker
args: ['tag', 'bazel/java:java8_debug', 'gcr.io/$PROJECT_ID/java:8-debug']

- name: gcr.io/cloud-builders/bazel
args: ['run', '//java:debug']
args: ['run', '//java:java11']
- name: gcr.io/cloud-builders/docker
args: ['tag', 'bazel/java:debug', 'gcr.io/$PROJECT_ID/java:debug']
args: ['tag', 'bazel/java:java11', 'gcr.io/$PROJECT_ID/java:11']

- name: gcr.io/cloud-builders/bazel
args: ['run', '//java/jetty']
args: ['run', '//java:java11_debug']
- name: gcr.io/cloud-builders/docker
args: ['tag', 'bazel/java/jetty:jetty', 'gcr.io/$PROJECT_ID/java/jetty:latest']
args: ['tag', 'bazel/java:java11_debug', 'gcr.io/$PROJECT_ID/java:11-debug']

- name: gcr.io/cloud-builders/bazel
args: ['run', '//java/jetty:debug']
args: ['run', '//java/jetty:jetty_java8']
- name: gcr.io/cloud-builders/docker
args: ['tag', 'bazel/java/jetty:jetty_java8', 'gcr.io/$PROJECT_ID/java/jetty:latest']
- name: gcr.io/cloud-builders/docker
args: ['tag', 'bazel/java/jetty:jetty_java8', 'gcr.io/$PROJECT_ID/java/jetty:java8']

- name: gcr.io/cloud-builders/bazel
args: ['run', '//java/jetty:jetty_java8_debug']
- name: gcr.io/cloud-builders/docker
args: ['tag', 'bazel/java/jetty:jetty_java8_debug', 'gcr.io/$PROJECT_ID/java/jetty:debug']
- name: gcr.io/cloud-builders/docker
args: ['tag', 'bazel/java/jetty:debug', 'gcr.io/$PROJECT_ID/java/jetty:debug']
args: ['tag', 'bazel/java/jetty:jetty_java8_debug', 'gcr.io/$PROJECT_ID/java/jetty:java8-debug']

- name: gcr.io/cloud-builders/bazel
args: ['run', '//experimental/python3:python3']
Expand Down Expand Up @@ -93,14 +111,20 @@ images:
- 'gcr.io/$PROJECT_ID/cc:latest'
- 'gcr.io/$PROJECT_ID/cc:debug'
- 'gcr.io/$PROJECT_ID/java:latest'
- 'gcr.io/$PROJECT_ID/java:8'
- 'gcr.io/$PROJECT_ID/java:debug'
- '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/jetty:latest'
- 'gcr.io/$PROJECT_ID/java/jetty:java8'
- 'gcr.io/$PROJECT_ID/java/jetty:debug'
- 'gcr.io/$PROJECT_ID/java/jetty:java8-debug'
- 'gcr.io/$PROJECT_ID/python3:latest'
- 'gcr.io/$PROJECT_ID/python3:debug'
- 'gcr.io/$PROJECT_ID/python2.7:latest'
- 'gcr.io/$PROJECT_ID/python2.7:debug'
- 'gcr.io/$PROJECT_ID/nodejs:latest'
- 'gcr.io/$PROJECT_ID/nodejs:debug'
- 'gcr.io/$PROJECT_ID/dotnet:latest'
- 'gcr.io/$PROJECT_ID/dotnet:debug'
- 'gcr.io/$PROJECT_ID/dotnet:debug'
43 changes: 35 additions & 8 deletions java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ cacerts_java(
)

[container_image(
name = "java8" if (not mode) else mode[1:],
base = "//cc" + mode,
name = rule_name,
base = "//cc" if (not ("debug" in rule_name)) else "//cc:debug",
debs = [
packages["zlib1g"],
packages["openjdk-8-jre-headless"],
packages[jre_deb],
],
entrypoint = [
"/usr/bin/java",
Expand All @@ -23,12 +23,14 @@ cacerts_java(
# cmd = ["/path/to/deploy.jar", "--option1", ...]
],
symlinks = {
"/usr/bin/java": "/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java",
"/usr/bin/java": java_executable_path,
},
tars = [":cacerts_java"],
) for mode in [
"",
":debug",
) for (rule_name, jre_deb, java_executable_path) in [
Copy link
Member

@loosebazooka loosebazooka Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably just get some bazel person to look at this, is there a way to share the java_executable_path reference or would that make this section look super wonky?
@nlopezgi wdyt?

Copy link
Member Author

@chanseokoh chanseokoh Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, if you look at them closely, the java_executable_path values are different between Java 8 and Java 11. (Java 8 has the "jre" directory.) I could add an if-else logic like "add jre only when Java 8", but wasn't sure if it would look better than this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel super strongly about this. I was concerned about each java path could potentially be shared for each java8, java11 option, but it seems like it's not worth the trouble right now

("java8", "openjdk-8-jre-headless", "/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java"),
("java8_debug", "openjdk-8-jre-headless", "/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java"),
("java11", "openjdk-11-jre-headless", "/usr/lib/jvm/java-11-openjdk-amd64/bin/java"),
("java11_debug", "openjdk-11-jre-headless", "/usr/lib/jvm/java-11-openjdk-amd64/bin/java"),
]]

load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
Expand All @@ -42,7 +44,19 @@ container_test(
container_test(
name = "java8_debug_test",
configs = ["testdata/java8_debug.yaml"],
image = ":debug",
image = ":java8_debug",
)

container_test(
name = "java11_test",
configs = ["testdata/java11.yaml"],
image = ":java11",
)

container_test(
name = "java11_debug_test",
configs = ["testdata/java11_debug.yaml"],
image = ":java11_debug",
)

java_image(
Expand All @@ -52,8 +66,21 @@ java_image(
main_class = "testdata.CheckCerts",
)

java_image(
name = "check_certs_java11",
srcs = ["testdata/CheckCerts.java"],
base = "//java:java11",
main_class = "testdata.CheckCerts",
)

container_test(
name = "check_certs_java8_test",
configs = ["testdata/java8_certs.yaml"],
image = ":check_certs_java8",
)

container_test(
name = "check_certs_java11_test",
configs = ["testdata/java11_certs.yaml"],
image = ":check_certs_java11",
)
10 changes: 5 additions & 5 deletions java/jetty/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_docker//container:container.bzl", "container_image")

[container_image(
name = "jetty" if (mode == ":java8") else mode[1:],
base = "//java" + mode,
name = rule_name,
base = "//java:java8" if (not ("debug" in rule_name)) else "//java:java8_debug",
cmd = ["/jetty/start.jar"],
ports = ["8080"],
tars = ["@jetty//:tar"],
workdir = "/jetty",
# We expect users to add their WAR under /jetty/webapps.
) for mode in [
":java8",
":debug",
) for rule_name in [
"jetty_java8",
"jetty_java8_debug",
]]
18 changes: 18 additions & 0 deletions java/testdata/java11.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
schemaVersion: "1.0.0"
commandTests:
- name: java
command: ["/usr/lib/jvm/java-11-openjdk-amd64/bin/java", "-version"]
expectedError: ['openjdk version "11\.*']
- name: java-symlink
command: ["/usr/bin/java", "-version"]
expectedError: ['openjdk version "11\.*']
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
9 changes: 9 additions & 0 deletions java/testdata/java11_certs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
schemaVersion: "1.0.0"
commandTests:
- name: connect_to_https_google_com
# This is a bit ugly because structure tests can't test the default entrypoint yet.
command: ["/usr/bin/java",
"-cp",
"/app/distroless/java/check_certs_java11.binary.jar:/app/distroless/java/check_certs_java11.binary",
"testdata.CheckCerts"]
expectedOutput: ['Successfully connected: 200']
18 changes: 18 additions & 0 deletions java/testdata/java11_debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
schemaVersion: "1.0.0"
commandTests:
- name: java
command: ["/usr/lib/jvm/java-11-openjdk-amd64/bin/java", "-version"]
expectedError: ['openjdk version "11\.*']
- name: java-symlink
command: ["/usr/bin/java", "-version"]
expectedError: ['openjdk version "11\.*']
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