{"id":15288353,"url":"https://github.com/jshiftio/buildah-java","last_synced_at":"2025-05-07T04:45:43.061Z","repository":{"id":50110344,"uuid":"194654807","full_name":"jshiftio/buildah-java","owner":"jshiftio","description":"A Java wrapper over the buildah cli (https://github.com/containers/buildah).","archived":false,"fork":false,"pushed_at":"2021-06-04T02:09:09.000Z","size":53,"stargazers_count":10,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T04:45:36.888Z","etag":null,"topics":["buildah","gradle","java","maven"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jshiftio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-01T10:51:59.000Z","updated_at":"2022-07-11T04:19:32.000Z","dependencies_parsed_at":"2022-08-24T03:30:31.148Z","dependency_job_id":null,"html_url":"https://github.com/jshiftio/buildah-java","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshiftio%2Fbuildah-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshiftio%2Fbuildah-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshiftio%2Fbuildah-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshiftio%2Fbuildah-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jshiftio","download_url":"https://codeload.github.com/jshiftio/buildah-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252816520,"owners_count":21808702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buildah","gradle","java","maven"],"created_at":"2024-09-30T15:47:51.751Z","updated_at":"2025-05-07T04:45:43.039Z","avatar_url":"https://github.com/jshiftio.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Buildah-java\n\n[![Circle CI](https://circleci.com/gh/jshiftio/buildah-java/tree/master.svg?style=shield)](https://circleci.com/gh/jshiftio/buildah-java/tree/master)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=jshiftio_buildah-java\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=jshiftio_buildah-java)\n[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=jshiftio_buildah-java\u0026metric=sqale_index)](https://sonarcloud.io/dashboard?id=jshiftio_buildah-java)\n\nThis library provides a wrapper for [Buildah](https://github.com/containers/buildah) which is a CLI tool for building OCI images.\n\n* **Buildah Java** \u003cbr/\u003e\n[![Maven Central](https://img.shields.io/maven-central/v/io.jshift/buildah-java.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.jshift%22%20AND%20a:%22buildah-java%22)\n* **Buildah Core** \u003cbr/\u003e\n[![Maven Central](https://img.shields.io/maven-central/v/io.jshift/buildah-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.jshift%22%20AND%20a:%22buildah-core%22)\n\nBuildah-java is composed of a `core` module which is the front interface to execute Buildah commands.\nAll integrators should use this interface as its base to call Buildah from Java.\n\n## Installation\n\n## Core\n\nCore module acts as an interface between Java and Buildah.\n\nTo install it you need to add next dependency:\n\n ```\n    \u003cdependency\u003e\n      \u003cgroupId\u003eio.jshift\u003c/groupId\u003e\n      \u003cartifactId\u003ebuildah-core\u003c/artifactId\u003e\n      \u003cversion\u003e${project.version}\u003c/version\u003e\n    \u003c/dependency\u003e\n ```\n\nBuildah-java does not assume where Buildah is installed, so you need to provide the location of Buildah home.\nBut you can skip this step if you add next dependency:\n\n ```\n    \u003cdependency\u003e\n      \u003cgroupId\u003eio.jshift\u003c/groupId\u003e\n      \u003cartifactId\u003ebuildah-binary\u003c/artifactId\u003e\n      \u003cversion\u003e${project.version}\u003c/version\u003e\n    \u003c/dependency\u003e`\n ```\n\nIf 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.\n\n## Usage\n\nAssuming that you have `buildah-binary` in classpath.\n\n* Create Buildah instance:\n\n`final Buildah buildah = new Buildah();`\n\nThis will create `BuildahConfiguration` object and the Buildah will be installed in `/tmp/.../` directory.\nBuildah can also be installed in the specified directory or projectDirectory:\n\n* Create BuildahConfiguration instance:\n\n`final BuildahConfiguration buildahConfiguration = new BuildahConfiguration();`\n\n* Setting the installation directory\n\n`buildahConfiguration.setInstallationDir(p);`\n\n* Creating Buildah Instance with BuildahConfiguration instance as parameter\n\n`final Buildah buildah = new Buildah(b);`\n\n* Creating Buildah Container\n\n`buildah.createContainer(\"java\").build().execute();`\n\nIf base image is not present locally, it will pull it and build a container.\n\n* Listing Buildah Containers\n\n`buildah.listContainers().build().execute();`\n\n* Listing Buildah Images\n\n`buildah.listImages().build().execute();`\n\n* Buildah Push\n\n`buildah.push(\"imageToBePushed\").creds(\"username:password\").registry(Registry).build().execute();`\n\n* Buildah Login\n\n`buildah.login(\"registryName\").username(\"username\").password(\"password\").build().execute();`\n\n* Buildah Logout\n\n`buildah.logout().registryName(\"registryName\").build().execute();`\n\n* Buildah Commit\n\n ```\nbuildah.commit(\"containerId or containerName\").contRemAfterCommit(true).withImageName(\"targetImageName\").build().execute();\n ```\n* Buildah Config\n\n ```\n buildah.config(\"containerName\").authorInfo(\"authorName\").volume(\"volume to be set\").workingDir(\"workingDir to be set\").annotation(List\u003cString\u003e).port(List\u003cString\u003e).label(List\u003cString\u003e).build().execute();\n ```\n\n* Buildah Add\n\n`buildah.add(\"containerName\",\"srcPath\").destination(\"destPath\").Build().execute();`\n\n* Buildah Copy\n\n`buildah.add(\"containerName\",\"srcPath\").destination(\"destPath\").Build().execute();`\n\n* Buildah Remove\n\n`buildah.rm().containerId(\"containerName\").build().execute();`\n\n* Buildah Remove All\n\n`buildah.rm().all(true).build().execute();`\n\n* Buildah Remove Image\n\n`buildah.rmi().image(\"imageId\").build().execute();`\n\n* Buildah Remove All Images\n\n`buildah.rmi().all(true).build().execute();`\n\n* Buildah Inspect Image\n\n`buildah.inspect().type(\"image\").image(\"imageId\").build().execute();`\n\n* Buildah Inspect Container\n\n`buildah.inspect().type(\"container\").container(\"containerId\").build().execute();`\n\n* Buildah build-using-dockerfile\n\n ```\n buildah.bud(\"context where dockerfile is located\").dockerfileList(dockerfileList).targetImage(\"targetImageName\").build().execute();\n ```\n\n* Buildah Run\n\n`buildah.run(\"containerName\", \"commandName\").commandOptions(commandOptionsList).build().execute();`\n\n* Buildah Pull\n\n`buildah.pull(\"ImageName\").build().execute();`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjshiftio%2Fbuildah-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjshiftio%2Fbuildah-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjshiftio%2Fbuildah-java/lists"}