Reputation: 261
I am currently create a GitHub Actions with that build a container automatically.
And I'm wondering if it's possible to create a GitHub action that automatically builds the container without adding JIB in the project's pom.xml
?
If we can t do this, can you show me how?
Upvotes: 3
Views: 3039
Reputation: 1689
Yes you can, whit this code on your GitHub workflows:
name: JIB container publish
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: JIB container build and publish
uses: MathieuSoysal/[email protected]
with:
PASSWORD: ${{ secrets.GITHUB_TOKEN }}
For more details you can go in: https://github.com/MathieuSoysal/jib-container-publish.yml
Upvotes: 4
Reputation: 4306
In Maven, you can run a goal of a plugin without adding the plugin to pom.xml
. For example,
mvn compile com.google.cloud.tools:jib-maven-plugin:3.2.0:build -Djib.to.image=foo
For Gradle, one can use a trick to use initscript:
# Adds Gradle init script that applies the Jib Gradle plugin.
echo "initscript {
repositories { maven { url 'https://plugins.gradle.org/m2' } }
dependencies { classpath 'gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:3.2.0' }
}
rootProject {
afterEvaluate {
if (!project.plugins.hasPlugin('com.google.cloud.tools.jib')) {
project.apply plugin: com.google.cloud.tools.jib.gradle.JibPlugin
}
}
}" > "$HOME"/init-script.gradle
# Runs the Gradle Jib build.
gradle jib \
--init-script="$HOME"/init-script.gradle \
-Djib.to.image=foo
You can find an example here.
Another option that may be applicable to you is Jib CLI, which has a feature to build a container from an existing JAR.
jib jar --target=my-registry.example.com/jar-app myapp.jar
There's also a Java library called Jib Core with which you can write a Java program to build a container. Jib Maven and Gradle plugins and Jib CLI are based on Jib Core.
Upvotes: 4
Reputation: 33
We are obliged to configure the pom.xml
, we cannot do otherwise.
You can go here: https://github.com/GoogleContainerTools/jib to get more information about JIB.
Upvotes: 0