SpringBoot Demo for using Jib
Please contribute if you have good suggestion/contribute if you have suggested edits .
- Login docker registry with password
hellojib:
docker login -u hellojib
- Modify configuration:
Modify credHelper to match your platform .
- Build the image:
Run gradle jib or mvn compile jib:build under project dictionary .
- Run container:
Run docker run --name hellojib -p 8080:8080 hellojib/hellojib:jib .
- Access application:
Run curl localhost:8080 and it will return "Hello Jib" .
You will need to add custom configuration (examples below). See the configuration reference for Gradle or Maven for more details:
- Gradle
build.gradle
jib {
from {
image = 'registry.hub.docker.com/openjdk:8-jdk-alpine'
credHelper = 'osxkeychain'
}
to {
image = 'CUSTOM_REGISTRY_URL/YOUR_USER_NAME//hellojib:jib'
credHelper = 'osxkeychain'
// Or use auth like below if you are not login
// Defined in gradle.properties
//auth {
// username = dockerUsername
// password = dockerPassword
//}
}
container {
jvmFlags = ['-Djava.security.egd=file:/dev/./urandom', '-Duser.timezone=GMT+08', '-Xdebug']
mainClass = 'com.example.jib.JibApplication'
args = ['some args']
ports = ['8080']
}
}gradle.properties
dockerUsername=YOUR_USERNAME
dockerPassword=YOUR_PASSWORD- Maven
pom.xml
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>${jib-maven-plugin.version}</version>
<configuration>
<from>
<image>registry.hub.docker.com/openjdk:8-jdk-alpine</image>
<credHelper>osxkeychain</credHelper>
</from>
<to>
<image>CUSTOM_REGISTRY_URL/YOUR_USER_NAME/hellojib:jib</image>
<credHelper>osxkeychain</credHelper>
</to>
<container>
<jvmFlags>
<jvmFlag>-Djava.security.egd=file:/dev/./urandom</jvmFlag>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-Duser.timezone=GMT+08</jvmFlag>
</jvmFlags>
<mainClass>com.example.jib.JibApplication</mainClass>
<args>
<arg>some args</arg>
</args>
<ports>
<port>8080</port>
</ports>
</container>
</configuration>
</plugin>
</plugins>
</build>settings.xml(${MAVEN_HOME}/conf/settings.xml)(You should config this is you are not login)
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>CUSTOM_REGISTRY_URL</id>
<username>YOUR_USERNAME</username>
<password>YOUR_PASSWORD</password>
</server>
</servers>
</settings>