Skip to content

Commit e0bdeea

Browse files
authored
Add 'container' config to READMEs (GoogleContainerTools#427)
* Add 'container' config to readmes * Fix syntax highlighting in gradle readme * Add 'ports' descriptions/examples
1 parent 2451652 commit e0bdeea

2 files changed

Lines changed: 59 additions & 36 deletions

File tree

‎jib-gradle-plugin/README.md‎

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,7 @@ Field | Type | Default | Description
143143
--- | --- | --- | ---
144144
`from` | [`from`](#from-closure) | See [`from`](#from-closure) | Configures the base image to build your application on top of.
145145
`to` | [`to`](#to-closure) | *Required* | Configures the target image to build your application to.
146-
`jvmFlags` | `List<String>` | *None* | Additional flags to pass into the JVM when running your application.
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.
149-
`format` | `String` | `Docker` | Use `OCI` to build an [OCI container image](https://www.opencontainers.org/).
146+
`container` | [`container`](#container-closure) | See [`container`](#container-closure) | Configures the container that is run from your built image.
150147
`useProjectOnlyCache` | `boolean` | `false` | If set to true, Jib does not share a cache between different Maven projects.
151148

152149
*\* Uses the main class defined in the `jar` task or tries to find a valid main class.*
@@ -174,14 +171,24 @@ Property | Type
174171
`username` | `String`
175172
`password` | `String`
176173

174+
<a name="container-closure"></a>`container` is a closure with the following properties:
175+
176+
Property | Type | Default | Description
177+
--- | --- | --- | ---
178+
`jvmFlags` | `List<String>` | *None* | Additional flags to pass into the JVM when running your application.
179+
`mainClass` | `String` | *Inferred\** | The main class to launch your application from.
180+
`args` | `List<String>` | *None* | Default main method arguments to run your application with.
181+
`ports` | `List<String>` | *None* | Ports that the container exposes at runtime (similar to Docker's [EXPOSE](https://docs.docker.com/engine/reference/builder/#expose) instruction).
182+
`format` | `String` | `Docker` | Use `OCI` to build an [OCI container image](https://www.opencontainers.org/).
183+
177184
### Example
178185

179-
In this configuration, the image is:
180-
* Built from a base of `openjdk:alpine` (pulled from Docker Hub)
181-
* Pushed to `localhost:5000/my-image:built-with-jib`
186+
In this configuration, the image:
187+
* Is built from a base of `openjdk:alpine` (pulled from Docker Hub)
188+
* Is pushed to `localhost:5000/my-image:built-with-jib`
182189
* Runs by calling `java -Xms512m -Xdebug -Xmy:flag=jib-rules -cp app/libs/*:app/resources:app/classes mypackage.MyApp some args`
183-
* Reproducible
184-
* Built as OCI format
190+
* Exposes port 1000 for tcp (default), and ports 2000, 2001, 2002, and 2003 for udp
191+
* Is built as OCI format
185192

186193
```groovy
187194
jib {
@@ -192,10 +199,13 @@ jib {
192199
image = 'localhost:5000/my-image/built-with-jib'
193200
credHelper = 'osxkeychain'
194201
}
195-
jvmFlags = ['-Xms512m', '-Xdebug', '-Xmy:flag=jib-rules']
196-
args = ['some', 'args']
197-
mainClass = 'mypackage.MyApp'
198-
format = 'OCI'
202+
container {
203+
jvmFlags = ['-Xms512m', '-Xdebug', '-Xmy:flag=jib-rules']
204+
mainClass = 'mypackage.MyApp'
205+
args = ['some', 'args']
206+
ports = ['1000', '2000-2003/udp']
207+
format = 'OCI'
208+
}
199209
}
200210
```
201211

@@ -218,7 +228,7 @@ Some common credential helpers include:
218228
Configure credential helpers to use by specifying them as a `credHelper` for their respective image in the `jib` extension.
219229

220230
*Example configuration:*
221-
```xml
231+
```groovy
222232
jib {
223233
from {
224234
image = 'aws_account_id.dkr.ecr.region.amazonaws.com/my-base-image'
@@ -235,7 +245,7 @@ jib {
235245

236246
You can specify credentials directly in the extension for the `from` and/or `to` images.
237247

238-
```xml
248+
```groovy
239249
jib {
240250
from {
241251
image = 'aws_account_id.dkr.ecr.region.amazonaws.com/my-base-image'
@@ -258,7 +268,7 @@ These credentials can be stored in `gradle.properties`, retrieved from a command
258268

259269
For example, you can use a key file for authentication (for GCR, see [Using a JSON key file](https://cloud.google.com/container-registry/docs/advanced-authentication#using_a_json_key_file)):
260270

261-
```xml
271+
```groovy
262272
jib {
263273
to {
264274
image = 'gcr.io/my-gcp-project/my-app'

‎jib-maven-plugin/README.md‎

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,7 @@ Field | Type | Default | Description
184184
--- | --- | --- | ---
185185
`from` | [`from`](#from-object) | See [`from`](#from-object) | Configures the base image to build your application on top of.
186186
`to` | [`to`](#to-object) | *Required* | Configures the target image to build your application to.
187-
`jvmFlags` | list | *None* | Additional flags to pass into the JVM when running your application.
188-
`mainClass` | string | *Inferred\** | The main class to launch the application from.
189-
`args` | list | *None* | Default main method arguments to run your application with.
190-
`format` | string | `Docker` | Use `OCI` to build an [OCI container image](https://www.opencontainers.org/).
187+
`container` | [`container`](#container-object) | See [`container`](#container-object) | Configures the container that is run from your image.
191188
`useOnlyProjectCache` | boolean | `false` | If set to true, Jib does not share a cache between different Gradle projects.
192189

193190
*\* Uses `mainClass` from `maven-jar-plugin` or tries to find a valid main class.*
@@ -206,14 +203,24 @@ Property | Type | Default | Description
206203
`image` | string | *Required* | The image reference for the target image. This can also be specified via the `-Dimage` command line option.
207204
`credHelper` | string | *None* | Suffix for the credential helper that can authenticate pulling the base image (following `docker-credential-`).
208205

206+
<a name="container-object"></a>`container` is an object with the following properties:
207+
208+
Property | Type | Default | Description
209+
--- | --- | --- | ---
210+
`jvmFlags` | list | *None* | Additional flags to pass into the JVM when running your application.
211+
`mainClass` | string | *Inferred\** | The main class to launch the application from.
212+
`args` | list | *None* | Default main method arguments to run your application with.
213+
`ports` | `List<String>` | *None* | Ports that the container exposes at runtime (similar to Docker's [EXPOSE](https://docs.docker.com/engine/reference/builder/#expose) instruction).
214+
`format` | string | `Docker` | Use `OCI` to build an [OCI container image](https://www.opencontainers.org/).
215+
209216
### Example
210217

211-
In this configuration, the image is:
212-
* Built from a base of `openjdk:alpine` (pulled from Docker Hub)
213-
* Pushed to `localhost:5000/my-image:built-with-jib`
218+
In this configuration, the image:
219+
* Is built from a base of `openjdk:alpine` (pulled from Docker Hub)
220+
* Is pushed to `localhost:5000/my-image:built-with-jib`
214221
* Runs by calling `java -Xms512m -Xdebug -Xmy:flag=jib-rules -cp app/libs/*:app/resources:app/classes mypackage.MyApp some args`
215-
* Reproducible
216-
* Built as OCI format
222+
* Exposes port 1000 for tcp (default), and ports 2000, 2001, 2002, and 2003 for udp
223+
* Is built as OCI format
217224

218225
```xml
219226
<configuration>
@@ -224,17 +231,23 @@ In this configuration, the image is:
224231
<image>localhost:5000/my-image:built-with-jib</image>
225232
<credHelper>osxkeychain</credHelper>
226233
</to>
227-
<jvmFlags>
228-
<jvmFlag>-Xms512m</jvmFlag>
229-
<jvmFlag>-Xdebug</jvmFlag>
230-
<jvmFlag>-Xmy:flag=jib-rules</jvmFlag>
231-
</jvmFlags>
232-
<args>
233-
<arg>some</arg>
234-
<arg>args</arg>
235-
</args>
236-
<mainClass>mypackage.MyApp</mainClass>
237-
<format>OCI</format>
234+
<container>
235+
<jvmFlags>
236+
<jvmFlag>-Xms512m</jvmFlag>
237+
<jvmFlag>-Xdebug</jvmFlag>
238+
<jvmFlag>-Xmy:flag=jib-rules</jvmFlag>
239+
</jvmFlags>
240+
<mainClass>mypackage.MyApp</mainClass>
241+
<args>
242+
<arg>some</arg>
243+
<arg>args</arg>
244+
</args>
245+
<ports>
246+
<port>1000</port>
247+
<port>2000-2003/udp</port>
248+
</ports>
249+
<format>OCI</format>
250+
</container>
238251
</configuration>
239252
```
240253

0 commit comments

Comments
 (0)