Skip to content

Commit 4c8f7b2

Browse files
authored
feat(java): contribute Dockerfile for GraalVM native image testing (#169)
1 parent 74551ae commit 4c8f7b2

5 files changed

Lines changed: 118 additions & 0 deletions

File tree

java/cloudbuild-test.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,22 @@ steps:
5151
"gcr.io/cloud-devrel-public-resources/java11",
5252
]
5353
waitFor: ["java11-build"]
54+
55+
# GraalVM build
56+
- name: gcr.io/cloud-builders/docker
57+
args: ["build", "-t", "gcr.io/$PROJECT_ID/graalvm", "."]
58+
dir: java/graalvm
59+
id: graalvm-build
60+
waitFor: ["-"]
61+
- name: gcr.io/gcp-runtimes/structure_test
62+
args:
63+
["-i", "gcr.io/$PROJECT_ID/graalvm", "--config", "java/graalvm.yaml", "-v"]
64+
waitFor: ["graalvm-build"]
65+
- name: gcr.io/cloud-builders/docker
66+
args:
67+
[
68+
"tag",
69+
"gcr.io/$PROJECT_ID/graalvm",
70+
"gcr.io/cloud-devrel-public-resources/graalvm",
71+
]
72+
waitFor: ["graalvm-build"]

java/cloudbuild.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,29 @@ steps:
5353
]
5454
waitFor: ["java11-build"]
5555

56+
# GraalVM build
57+
- name: gcr.io/cloud-builders/docker
58+
args: ["build", "-t", "gcr.io/$PROJECT_ID/graalvm", "."]
59+
dir: java/graalvm
60+
id: graalvm-build
61+
waitFor: ["-"]
62+
- name: gcr.io/gcp-runtimes/structure_test
63+
args:
64+
["-i", "gcr.io/$PROJECT_ID/graalvm", "--config", "java/graalvm.yaml", "-v"]
65+
waitFor: ["graalvm-build"]
66+
- name: gcr.io/cloud-builders/docker
67+
args:
68+
[
69+
"tag",
70+
"gcr.io/$PROJECT_ID/graalvm",
71+
"gcr.io/cloud-devrel-public-resources/graalvm",
72+
]
73+
waitFor: ["graalvm-build"]
74+
5675
images:
5776
- gcr.io/$PROJECT_ID/java8
5877
- gcr.io/cloud-devrel-public-resources/java8
5978
- gcr.io/$PROJECT_ID/java11
6079
- gcr.io/cloud-devrel-public-resources/java11
80+
- gcr.io/$PROJECT_ID/graalvm
81+
- gcr.io/cloud-devrel-public-resources/graalvm

java/graalvm.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
schemaVersion: 1.0.0
16+
commandTests:
17+
- name: "version"
18+
command: ["java", "-version"]
19+
# java -version outputs to stderr...
20+
expectedError: ["GraalVM CE"]
21+
- name: "maven"
22+
command: ["mvn", "-version"]
23+
expectedOutput: ["Apache Maven 3.8.*"]
24+
- name: "gradle"
25+
command: ["gradle", "-version"]
26+
expectedOutput: ["Gradle 4.9"]
27+
- name: "gcloud"
28+
command: ["gcloud", "version"]
29+
expectedOutput: ["Google Cloud SDK"]

java/graalvm/Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM ghcr.io/graalvm/graalvm-ce:ol7-java11-21.2.0
16+
17+
RUN gu install native-image && \
18+
yum update -y && \
19+
yum install -y wget unzip git && \
20+
# Install maven, do not upgrade to 3.8.2
21+
wget -q https://archive.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.zip -O /tmp/maven.zip && \
22+
unzip /tmp/maven.zip -d /tmp/maven && \
23+
mv /tmp/maven/apache-maven-3.8.1 /usr/local/lib/maven && \
24+
rm /tmp/maven.zip && \
25+
ln -s $JAVA_HOME/lib $JAVA_HOME/conf && \
26+
# Install Gradle
27+
wget -q https://services.gradle.org/distributions/gradle-4.9-bin.zip -O /tmp/gradle.zip && \
28+
mkdir -p /usr/local/lib/gradle && \
29+
unzip -q /tmp/gradle.zip -d /usr/local/lib/gradle && \
30+
rm /tmp/gradle.zip
31+
32+
ENV PATH $PATH:/usr/local/lib/maven/bin:/usr/local/lib/gradle/gradle-4.9/bin
33+
34+
# Install gcloud SDK
35+
COPY google-cloud-sdk.repo /etc/yum.repos.d/google-cloud-sdk.repo
36+
RUN yum install -y google-cloud-sdk
37+
38+
# Adding the package path to local
39+
ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin
40+
41+
WORKDIR /workspace

java/graalvm/google-cloud-sdk.repo

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[google-cloud-sdk]
2+
name=Google Cloud SDK
3+
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
4+
enabled=1
5+
gpgcheck=1
6+
repo_gpgcheck=0
7+
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
8+
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

0 commit comments

Comments
 (0)