Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base mvn builder on official maven image (#451)
* Base mvn builder on official maven image * Remove deps.txt and resolve-deps.sh * Fix Dockerfile, remove examples/Dockerfile * minimally invoke maven * fix example
- Loading branch information
Showing
9 changed files
with
55 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,3 @@ | ||
ARG BASE_IMAGE=gcr.io/cloud-builders/javac:8 | ||
FROM ${BASE_IMAGE} | ||
|
||
ARG MAVEN_VERSION=3.5.0 | ||
ARG USER_HOME_DIR="/root" | ||
ARG SHA=beb91419245395bd69a4a6edad5ca3ec1a8b64e41457672dc687c173a495f034 | ||
ARG BASE_URL=https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries | ||
|
||
RUN apt-get update -qqy && apt-get install -qqy curl \ | ||
&& mkdir -p /usr/share/maven /usr/share/maven/ref \ | ||
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-$MAVEN_VERSION-bin.tar.gz \ | ||
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha256sum -c - \ | ||
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \ | ||
&& rm -f /tmp/apache-maven.tar.gz \ | ||
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn \ | ||
# clean up build packages | ||
&& apt-get remove -qqy --purge curl \ | ||
&& rm /var/lib/apt/lists/*_* | ||
|
||
ENV M2_HOME /usr/share/maven | ||
|
||
# transitively resolve all dependencies | ||
ADD deps.txt /builder/deps.txt | ||
ADD resolve-deps.sh /builder/resolve-deps.sh | ||
|
||
RUN /builder/resolve-deps.sh | ||
|
||
ARG MAVEN_VERSION=latest | ||
FROM maven:${MAVEN_VERSION} | ||
ENTRYPOINT ["mvn"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
# Tool builder: `gcr.io/cloud-builders/mvn` | ||
|
||
This Cloud Build builder runs Maven. It also includes a number of dependencies | ||
that are precached within the image. | ||
This Cloud Build builder runs Maven. | ||
|
||
You should consider instead using an [official `maven` | ||
image](https://hub.docker.com/_/maven/) and specifying the `mvn` entrypoint: | ||
|
||
```yaml | ||
steps: | ||
- name: maven:3.6.0-jdk-11-slim | ||
entrypoint: 'mvn' | ||
args: ['install'] | ||
``` | ||
|
||
This allows you to use any supported version of Maven with any supported JDK | ||
version. | ||
|
||
## Building this builder | ||
|
||
To build this builder, run the following command in this directory. | ||
|
||
$ gcloud builds submit . --config=cloudbuild.yaml | ||
$ gcloud builds submit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,51 @@ | ||
# In this directory, run the following command to build this builder. | ||
# $ gcloud builds submit . --config=cloudbuild.yaml | ||
# | ||
# TODO(franklinn): Stop tagging java/mvn images once usage has dropped off. | ||
# $ gcloud builds submit | ||
|
||
steps: | ||
# Build the java / maven matrix. | ||
# Build old tagged images. | ||
# TODO(jasonhall): Deprecate and stop building these tagged images. Users | ||
# should use the official maven image directly. | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: | ||
- 'build' | ||
- '--build-arg=BASE_IMAGE=gcr.io/$PROJECT_ID/javac:8' | ||
- '--build-arg=MAVEN_VERSION=3.3.9' | ||
- '--build-arg=SHA=6e3e9c949ab4695a204f74038717aa7b2689b1be94875899ac1b3fe42800ff82' | ||
- '--build-arg=MAVEN_VERSION=3.3.9-jdk-8' | ||
- '--tag=gcr.io/$PROJECT_ID/mvn:3.3.9-jdk-8' | ||
- '--tag=gcr.io/$PROJECT_ID/java/mvn:3.3.9-jdk-8' | ||
- '.' | ||
wait_for: ['-'] | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: | ||
- 'build' | ||
- '--build-arg=BASE_IMAGE=gcr.io/$PROJECT_ID/javac:8' | ||
- '--build-arg=MAVEN_VERSION=3.5.0' | ||
- '--build-arg=SHA=beb91419245395bd69a4a6edad5ca3ec1a8b64e41457672dc687c173a495f034' | ||
- '--build-arg=MAVEN_VERSION=3.5.0-jdk-8' | ||
- '--tag=gcr.io/$PROJECT_ID/mvn:3.5.0-jdk-8' | ||
- '--tag=gcr.io/$PROJECT_ID/java/mvn:3.5.0-jdk-8' | ||
- '.' | ||
wait_for: ['-'] | ||
|
||
# Tag a default builder version. | ||
# Build the latest version. | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: | ||
- 'tag' | ||
- 'gcr.io/$PROJECT_ID/mvn:3.5.0-jdk-8' | ||
- 'gcr.io/$PROJECT_ID/java/mvn' | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: | ||
- 'tag' | ||
- 'gcr.io/$PROJECT_ID/mvn:3.5.0-jdk-8' | ||
- 'gcr.io/$PROJECT_ID/mvn' | ||
- 'build' | ||
- '--tag=gcr.io/$PROJECT_ID/mvn' | ||
- '.' | ||
|
||
# run examples | ||
# Minimally invoke Maven. | ||
- name: 'gcr.io/$PROJECT_ID/mvn' | ||
args: ['--version'] | ||
|
||
# Run example builds. | ||
- name: 'gcr.io/$PROJECT_ID/mvn:3.3.9-jdk-8' | ||
args: ['install'] | ||
dir: 'examples/spring_boot' | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: ['build', '.'] | ||
dir: 'examples/spring_boot' | ||
|
||
- name: 'gcr.io/$PROJECT_ID/mvn:3.5.0-jdk-8' | ||
args: ['install'] | ||
dir: 'examples/spring_boot' | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: ['build', '.'] | ||
- name: 'gcr.io/$PROJECT_ID/mvn' | ||
args: ['install'] | ||
dir: 'examples/spring_boot' | ||
|
||
# Demonstrate using the maven image directly. | ||
- name: 'maven' | ||
args: ['mvn', 'install'] | ||
dir: 'examples/spring_boot' | ||
|
||
images: | ||
- 'gcr.io/$PROJECT_ID/mvn:3.5.0-jdk-8' | ||
- 'gcr.io/$PROJECT_ID/mvn:3.3.9-jdk-8' | ||
- 'gcr.io/$PROJECT_ID/mvn:3.5.0-jdk-8' | ||
- 'gcr.io/$PROJECT_ID/mvn' | ||
- 'gcr.io/$PROJECT_ID/java/mvn:3.5.0-jdk-8' | ||
- 'gcr.io/$PROJECT_ID/java/mvn:3.3.9-jdk-8' | ||
- 'gcr.io/$PROJECT_ID/java/mvn' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters