Skip to content

Commit

Permalink
Base mvn builder on official maven image (#451)
Browse files Browse the repository at this point in the history
* 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
imjasonh committed Feb 7, 2019
1 parent 40d069b commit a3d23b2
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 107 deletions.
29 changes: 2 additions & 27 deletions mvn/Dockerfile
@@ -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"]
18 changes: 15 additions & 3 deletions mvn/README.md
@@ -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
57 changes: 23 additions & 34 deletions mvn/cloudbuild.yaml
@@ -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'
7 changes: 0 additions & 7 deletions mvn/deps.txt

This file was deleted.

3 changes: 0 additions & 3 deletions mvn/examples/spring_boot/Dockerfile

This file was deleted.

23 changes: 0 additions & 23 deletions mvn/resolve-deps.sh

This file was deleted.

9 changes: 6 additions & 3 deletions npm/README.md
Expand Up @@ -2,17 +2,20 @@

This Cloud Build builder runs the `npm` tool.

You might also consider using an [official `node` image](https://hub.docker.com/_/node/) and specifying the `npm` entrypoint:
You should consider instead using an [official `node`
image](https://hub.docker.com/_/node/) and specifying the `npm` entrypoint:

```yaml
steps:
- name: node:10.10.0
- name: node:10.15.1
entrypoint: npm
args: ['install']
```

This allows you to use any supported version of NPM.

## Building this builder

To build this builder, run the following command in this directory.

$ gcloud builds submit . --config=cloudbuild.yaml
$ gcloud builds submit
9 changes: 6 additions & 3 deletions yarn/README.md
Expand Up @@ -2,17 +2,20 @@

This Cloud Build builder runs the `yarn` tool.

You might also consider using an [official `node` image](https://hub.docker.com/_/node/) and specifying the `yarn` entrypoint:
You should consider instead using an [official `node`
image](https://hub.docker.com/_/node/) and specifying the `yarn` entrypoint:

```yaml
steps:
- name: node:10.10.0
- name: node:10.15.1
entrypoint: yarn
args: ['install']
```

This allows you to use any supported version of Yarn.

## Building this builder

To build this builder, run the following command in this directory.

$ gcloud builds submit . --config=cloudbuild.yaml
$ gcloud builds submit
7 changes: 3 additions & 4 deletions yarn/cloudbuild.yaml
@@ -1,10 +1,10 @@
# In this directory, run the following command to build this builder.
# $ gcloud builds submit . --config=cloudbuild.yaml
#
# TODO(franklinn): Stop tagging nodejs/yarn images once usage has dropped off.
# $ gcloud builds submit

steps:
# Build all supported versions.
# TODO(jasonhall): Deprecate and stop building these tagged images. Users
# should use the official node image directly.
- name: 'gcr.io/cloud-builders/docker'
args:
- 'build'
Expand Down Expand Up @@ -74,4 +74,3 @@ images:
- 'gcr.io/$PROJECT_ID/yarn:node-8.4.0'
- 'gcr.io/$PROJECT_ID/yarn:node-9.11.2'
- 'gcr.io/$PROJECT_ID/yarn:node-10.10.0'
- 'gcr.io/$PROJECT_ID/nodejs/yarn'

0 comments on commit a3d23b2

Please sign in to comment.