Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/softleader/jib-jvm-flags-extension-maven

Jib JVM Flags extension
https://github.com/softleader/jib-jvm-flags-extension-maven

containers docker docker-registry java jib jib-extension jvm-flags kubernetes maven maven-plugin microservices oci

Last synced: about 1 month ago
JSON representation

Jib JVM Flags extension

Awesome Lists containing this project

README

        

[![version](https://img.shields.io/github/v/release/softleader/jib-jvm-flags-extension-maven?color=brightgreen&sort=semver)](https://github.com/softleader/jib-jvm-flags-extension-maven/releases/latest)
[![Maven Central](https://img.shields.io/maven-central/v/tw.com.softleader.cloud.tools/jib-jvm-flags-extension-maven?color=orange)](https://central.sonatype.com/search?q=g%3Atw.com.softleader.cloud.tools&smo=true&namespace=tw.com.softleader.cloud.tools)
![GitHub tag checks state](https://img.shields.io/github/checks-status/softleader/jib-jvm-flags-extension-maven/main)
![GitHub issues](https://img.shields.io/github/issues-raw/softleader/jib-jvm-flags-extension-maven)

# Jib JVM Flags Extension

A [Jib](https://github.com/GoogleContainerTools/jib) [maven extension](https://github.com/GoogleContainerTools/jib-extensions) outputs the configured `jvmFlags` into the `/app/jib-jvm-flags-file` file, allowing a [custom entrypoint](https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin#custom-container-entrypoint) to access these flags.

When a custom entrypoint is used, Jib ignores the `jvmFlags` settings. This extension ensures that the configured `jvmFlags` are accessible even in such scenarios:

- For Java 11+:
```sh
java @/app/jib-jvm-flags-file -cp @/app/jib-classpath-file @/app/jib-main-class-file
```
- With shell:
```sh
java $(cat /app/jib-jvm-flags-file) -cp $(cat /app/jib-classpath-file) $(cat /app/jib-main-class-file)
```

> **Note:** Requires Java 11 or newer

## Usage

To use the Jib JVM Flags extension in your project, configure the `jib-maven-plugin` as follows:

```xml

com.google.cloud.tools
jib-maven-plugin
${jib-maven-plugin.version}



tw.com.softleader.cloud.tools.jib.maven.JvmFlagsExtension





tw.com.softleader.cloud.tools
jib-jvm-flags-extension-maven
${jib-jvm-flags-extension-maven.version}

```

### Customizing Entrypoint with Java Command

To customize the entrypoint using a direct Java command, for example:

```xml



-XshowSettings:vm
-Xdebug

java,@/app/jib-jvm-flags-file,-cp,@/app/jib-classpath-file,@/app/jib-main-class-file



tw.com.softleader.cloud.tools.jib.maven.JvmFlagsExtension

```

### Customizing Entrypoint Using a Shell Script

You can also use a shell script to launch your app:

```sh
#!/bin/bash
set -e

# Perform any necessary steps before starting the JVM,
# such as setting JVM options or preparing the environment
export JAVA_TOOL_OPTIONS="-Xmx1g"

exec java $(cat /app/jib-jvm-flags-file) \
-cp $(cat /app/jib-classpath-file) \
$(cat /app/jib-main-class-file) \
"$@"
```

And then configure the plugin to use this script:

```xml



-XshowSettings:vm
-Xdebug

sh,/entrypoint.sh




.
entrypoint.sh





tw.com.softleader.cloud.tools.jib.maven.JvmFlagsExtension

```

### Extension Properties

You can further customize the extension with the following properties:

```xml

tw.com.softleader.cloud.tools.jib.maven.JvmFlagsExtension


true

,

my-jvm-flags-file

666

```