Skip to content

Commit 29caf63

Browse files
authored
Updates README for beta release. (GoogleContainerTools#322)
1 parent b893909 commit 29caf63

6 files changed

Lines changed: 187 additions & 77 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)
22
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.google.cloud.tools/jib-maven-plugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.google.cloud.tools/jib-maven-plugin)
3-
[![Gradle Plugin Portal](https://img.shields.io/badge/gradle%20plugin-v0.1.1-blue.svg)](https://plugins.gradle.org/plugin/com.google.cloud.tools.jib)
3+
[![Gradle Plugin Portal](https://img.shields.io/badge/gradle%20plugin-v0.9.0-blue.svg)](https://plugins.gradle.org/plugin/com.google.cloud.tools.jib)
44
[![Gitter version](https://img.shields.io/gitter/room/gitterHQ/gitter.svg)](https://gitter.im/google/jib)
55

66
# Jib

‎examples/helloworld/README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Builds a container image that outputs `Hello World` when run.
2+
3+
To build the image:
4+
5+
1. In `pom.xml`, replace `REPLACE-WITH-YOUR-GCP-PROJECT` with your GCP project.
6+
7+
1. Run `mvn compile jib:build`.

‎examples/helloworld/build.gradle‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins {
2+
id 'java'
3+
id 'com.google.cloud.tools.jib' version '0.9.0'
4+
}
5+
6+
sourceCompatibility = 1.8
7+
targetCompatibility = 1.8
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
dependencies {
14+
compile 'com.google.guava:guava:23.6-jre'
15+
}
16+
17+
jib.to.image = 'gcr.io/REPLACE-WITH-YOUR-GCP-PROJECT/image-built-with-jib'

‎examples/helloworld/pom.xml‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
<version>1</version>
77

88
<properties>
9-
<jib-maven-plugin.version>0.1.2</jib-maven-plugin.version>
10-
<mainClass>example.HelloWorld</mainClass>
9+
<jib-maven-plugin.version>0.9.0</jib-maven-plugin.version>
1110
</properties>
1211

1312
<dependencies>
@@ -35,10 +34,9 @@
3534
<artifactId>jib-maven-plugin</artifactId>
3635
<version>${jib-maven-plugin.version}</version>
3736
<configuration>
38-
<credentialHelperName>gcr</credentialHelperName>
39-
<registry>gcr.io</registry>
40-
<repository>REPLACE-WITH-YOUR-GCP-PROJECT/image-built-with-jib</repository>
41-
<mainClass>${mainClass}</mainClass>
37+
<to>
38+
<image>gcr.io/REPLACE-WITH-YOUR-GCP-PROJECT/image-built-with-jib</image>
39+
</to>
4240
</configuration>
4341
<executions>
4442
<execution>

‎jib-gradle-plugin/README.md‎

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)
2-
[![Gradle Plugin Portal](https://img.shields.io/badge/gradle%20plugin-v0.1.1-blue.svg)](https://plugins.gradle.org/plugin/com.google.cloud.tools.jib)
2+
[![Gradle Plugin Portal](https://img.shields.io/badge/gradle%20plugin-v0.9.0-blue.svg)](https://plugins.gradle.org/plugin/com.google.cloud.tools.jib)
33
[![Gitter version](https://img.shields.io/gitter/room/gitterHQ/gitter.svg)](https://gitter.im/google/jib)
44

55
# Jib - Containerize your Gradle Java project
@@ -14,7 +14,6 @@ For the Maven plugin, see the [jib-maven-plugin project](../jib-maven-plugin).
1414
These features are not currently supported but will be added in later releases.
1515

1616
* Support for WAR format
17-
* Export to a Docker context
1817
* Run and debug the built container
1918

2019
## Quickstart
@@ -27,11 +26,21 @@ In your Gradle Java project, add the plugin to your `build.gradle`:
2726

2827
```groovy
2928
plugins {
30-
id 'com.google.cloud.tools.jib' version '0.1.1'
29+
id 'com.google.cloud.tools.jib' version '0.9.0'
3130
}
3231
```
3332

34-
See the [Gradle Plugin Portal](https://plugins.gradle.org/plugin/com.google.cloud.tools.jib) for more details.
33+
*See the [Gradle Plugin Portal](https://plugins.gradle.org/plugin/com.google.cloud.tools.jib) for more details.*
34+
35+
You can containerize your application easily with one command:
36+
37+
```shell
38+
gradle jib --image=<MY IMAGE>
39+
```
40+
41+
*If you encounter authentication issues, see [Authentication Methods](#authentication-methods).*
42+
43+
If you would like to set up Jib as part of your Gradle build, follow the guide below.
3544

3645
## Configuration
3746

@@ -74,32 +83,57 @@ jib.to.image = 'my-docker-id/my-app'
7483
Build your container image with:
7584

7685
```shell
77-
gradle build jib
86+
gradle jib
7887
```
7988

8089
Subsequent builds are much faster than the initial build.
8190

82-
If you want to clear Jib's build cache and force it to re-pull the base image and re-build the application layers, run:
91+
*Having trouble? Let us know by [submitting an issue](/../../issues/new), contacting us on [Gitter](https://gitter.im/google/jib), or posting to the [Jib users forum](https://groups.google.com/forum/#!forum/jib-users).*
92+
93+
#### Build to Docker daemon
94+
95+
Jib can also build your image directly to a Docker daemon. This uses the `docker` command line tool and requires that you have `docker` available on your `PATH`.
8396

8497
```shell
85-
gradle clean build jib
98+
gradle jibDockerBuild
8699
```
87100

88-
*Having trouble? Let us know by [submitting an issue](/../../issues/new), contacting us on [Gitter](https://gitter.im/google/jib), or posting to the [Jib users forum](https://groups.google.com/forum/#!forum/jib-users).*
101+
If you are using [`minikube`](https://github.com/kubernetes/minikube)'s remote Docker daemon, make sure you [set up the correct environment variables](https://github.com/kubernetes/minikube/blob/master/docs/reusing_the_docker_daemon.md) to point to the remote daemon:
102+
103+
```shell
104+
eval $(minikube docker-env)
105+
gradle jibDockerBuild
106+
```
89107

90108
### Run `jib` with each build
91109

92110
You can also have `jib` run with each build by attaching it to the `build` task:
93111

94112
```groovy
95-
tasks.build.finalizedBy tasks.jib
113+
tasks.build.dependsOn tasks.jib
96114
```
97115

98116
Then, ```gradle build``` will build and containerize your application.
99117

100118
### Export to a Docker context
101119

102-
*Not yet supported*
120+
Jib can also export a Docker context so that you can build with Docker, if needed:
121+
122+
```shell
123+
gradle jibExportDockerContext
124+
```
125+
126+
The Docker context will be created at `build/jib-docker-context` by default. You can change this directory with the `targetDir` configuration option or the `---jib.dockerDir` parameter:
127+
128+
```shell
129+
gradle jibExportDockerContext --jib.dockerDir=my/docker/context/
130+
```
131+
132+
You can then build your image with Docker:
133+
134+
```shell
135+
docker build -t myimage my/docker/context/
136+
```
103137

104138
## Extended Usage
105139

@@ -110,11 +144,13 @@ Field | Type | Default | Description
110144
`from` | [`from`](#from-closure) | See [`from`](#from-closure) | Configures the base image to build your application on top of.
111145
`to` | [`to`](#to-closure) | *Required* | Configures the target image to build your application to.
112146
`jvmFlags` | `List<String>` | *None* | Additional flags to pass into the JVM when running your application.
113-
`mainClass` | `String` | Uses the main class defined in the `jar` task | The main class to launch your application from.
114-
`reproducible` | `boolean` | `true` | Building with the same application contents always generates the same image.<br>Note that this does NOT preserve file timestamps and ownership.
147+
`mainClass` | `String` | *Inferred\** | The main class to launch your application from.
148+
`args` | `List<String>` | *None* | Default main method arguments to run your application with.
115149
`format` | `String` | `Docker` | Use `OCI` to build an [OCI container image](https://www.opencontainers.org/).
116150
`useProjectOnlyCache` | `boolean` | `false` | If set to true, Jib does not share a cache between different Maven projects.
117151

152+
*\* Uses the main class defined in the `jar` task or tries to find a valid main class.*
153+
118154
<a name="from-closure"></a>`from` is a closure with the following properties:
119155

120156
Property | Type | Default | Description
@@ -127,7 +163,7 @@ Property | Type | Default | Description
127163

128164
Property | Type | Default | Description
129165
--- | --- | --- | ---
130-
`image` | `String` | *Required* | The image reference for the target image.
166+
`image` | `String` | *Required* | The image reference for the target image. This can also be specified via the `--image` command line option.
131167
`credHelper` | `String` | *None* | Suffix for the credential helper that can authenticate pulling the base image (following `docker-credential-`).
132168
`auth` | [`auth`](#auth-closure) | *None* | Specify credentials directly (alternative to `credHelper`).
133169

@@ -143,7 +179,7 @@ Property | Type
143179
In this configuration, the image is:
144180
* Built from a base of `openjdk:alpine` (pulled from Docker Hub)
145181
* Pushed to `localhost:5000/my-image:built-with-jib`
146-
* Runs by calling `java -Xms512m -Xdebug -Xmy:flag=jib-rules -cp app/libs/*:app/resources:app/classes mypackage.MyApp`
182+
* Runs by calling `java -Xms512m -Xdebug -Xmy:flag=jib-rules -cp app/libs/*:app/resources:app/classes mypackage.MyApp some args`
147183
* Reproducible
148184
* Built as OCI format
149185

@@ -157,8 +193,8 @@ jib {
157193
credHelper = 'osxkeychain'
158194
}
159195
jvmFlags = ['-Xms512m', '-Xdebug', '-Xmy:flag=jib-rules']
196+
args = ['some', 'args']
160197
mainClass = 'mypackage.MyApp'
161-
reproducible = true
162198
format = 'OCI'
163199
}
164200
```
@@ -242,7 +278,6 @@ See the [Jib project README](/../../#how-jib-works).
242278

243279
These limitations will be fixed in later releases.
244280

245-
* Does not build directly to a Docker daemon.
246281
* Pushing to Azure Container Registry is not currently supported.
247282

248283
## Frequently Asked Questions (FAQ)

0 commit comments

Comments
 (0)