buildah-java

Buildah integration in Java

License

License

http://www.apache.org/licenses/LICENSE-2.0.txt
Categories

Categories

Java Languages
GroupId

GroupId

io.jshift
ArtifactId

ArtifactId

buildah-java
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

pom
Description

Description

buildah-java
Buildah integration in Java
Project URL

Project URL

http://github.com/jshiftio/buildah-java

Download buildah-java

Filename Size
buildah-java-1.0.1.pom 6 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/io.jshift/buildah-java/ -->
<dependency>
    <groupId>io.jshift</groupId>
    <artifactId>buildah-java</artifactId>
    <version>1.0.1</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/io.jshift/buildah-java/
implementation 'io.jshift:buildah-java:1.0.1'
// https://jarcasting.com/artifacts/io.jshift/buildah-java/
implementation ("io.jshift:buildah-java:1.0.1")
'io.jshift:buildah-java:pom:1.0.1'
<dependency org="io.jshift" name="buildah-java" rev="1.0.1">
  <artifact name="buildah-java" type="pom" />
</dependency>
@Grapes(
@Grab(group='io.jshift', module='buildah-java', version='1.0.1')
)
libraryDependencies += "io.jshift" % "buildah-java" % "1.0.1"
[io.jshift/buildah-java "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • buildah-binary
  • buildah-core

Buildah-java

Circle CI Maintainability Rating Technical Debt

This library provides a wrapper for Buildah which is a CLI tool for building OCI images.

  • Buildah Java
    Maven Central
  • Buildah Core
    Maven Central

Buildah-java is composed of a core module which is the front interface to execute Buildah commands. All integrators should use this interface as its base to call Buildah from Java.

Installation

Core

Core module acts as an interface between Java and Buildah.

To install it you need to add next dependency:

   <dependency>
     <groupId>io.jshift</groupId>
     <artifactId>buildah-core</artifactId>
     <version>${project.version}</version>
   </dependency>

Buildah-java does not assume where Buildah is installed, so you need to provide the location of Buildah home. But you can skip this step if you add next dependency:

   <dependency>
     <groupId>io.jshift</groupId>
     <artifactId>buildah-binary</artifactId>
     <version>${project.version}</version>
   </dependency>`

If you do this, Buildah will be automatically installed and you'll be ready to use Buildah-java without having to install Buildah manually nor setting the Buildah home directory.

Usage

Assuming that you have buildah-binary in classpath.

  • Create Buildah instance:

final Buildah buildah = new Buildah();

This will create BuildahConfiguration object and the Buildah will be installed in /tmp/.../ directory. Buildah can also be installed in the specified directory or projectDirectory:

  • Create BuildahConfiguration instance:

final BuildahConfiguration buildahConfiguration = new BuildahConfiguration();

  • Setting the installation directory

buildahConfiguration.setInstallationDir(p);

  • Creating Buildah Instance with BuildahConfiguration instance as parameter

final Buildah buildah = new Buildah(b);

  • Creating Buildah Container

buildah.createContainer("java").build().execute();

If base image is not present locally, it will pull it and build a container.

  • Listing Buildah Containers

buildah.listContainers().build().execute();

  • Listing Buildah Images

buildah.listImages().build().execute();

  • Buildah Push

buildah.push("imageToBePushed").creds("username:password").registry(Registry).build().execute();

  • Buildah Login

buildah.login("registryName").username("username").password("password").build().execute();

  • Buildah Logout

buildah.logout().registryName("registryName").build().execute();

  • Buildah Commit
buildah.commit("containerId or containerName").contRemAfterCommit(true).withImageName("targetImageName").build().execute();
  • Buildah Config
buildah.config("containerName").authorInfo("authorName").volume("volume to be set").workingDir("workingDir to be set").annotation(List<String>).port(List<String>).label(List<String>).build().execute();
  • Buildah Add

buildah.add("containerName","srcPath").destination("destPath").Build().execute();

  • Buildah Copy

buildah.add("containerName","srcPath").destination("destPath").Build().execute();

  • Buildah Remove

buildah.rm().containerId("containerName").build().execute();

  • Buildah Remove All

buildah.rm().all(true).build().execute();

  • Buildah Remove Image

buildah.rmi().image("imageId").build().execute();

  • Buildah Remove All Images

buildah.rmi().all(true).build().execute();

  • Buildah Inspect Image

buildah.inspect().type("image").image("imageId").build().execute();

  • Buildah Inspect Container

buildah.inspect().type("container").container("containerId").build().execute();

  • Buildah build-using-dockerfile
buildah.bud("context where dockerfile is located").dockerfileList(dockerfileList).targetImage("targetImageName").build().execute();
  • Buildah Run

buildah.run("containerName", "commandName").commandOptions(commandOptionsList).build().execute();

  • Buildah Pull

buildah.pull("ImageName").build().execute();

io.jshift

Jshift

This Project has moved to Eclipse JKube: https://github.com/eclipse/jkube

Versions

Version
1.0.1
1.0.0