Last year, we set out to make it easier for developers to containerize their Java applications. We had noticed that developers were having a hard time with the existing tools. Build times were slow. Dockerfiles were messy. The containers were too large.
We built Jib to change that. Jib is an open-source tool that containerizes your Java applications with minimal effort—no need to install Docker, run a Docker daemon, or even write a Dockerfile. Simply apply the plugin to your Maven or Gradle build, and run the build. Jib uses the build information to automatically containerize your applications quickly and efficiently. With Jib, building Java containers is now as easy as packaging a JAR.
We announced Jib beta last year, and since then, we’ve received feedback and contributions from our community that have helped us make the containerization experience even better. Today, we’re announcing the general availability of Jib 1.0.0, making it fully ready and stable for production use.
We’ll cover the major changes below, including support for WAR projects, integration with Skaffold, and Jib Core, a new container building library for Java.
What’s in Jib 1.0?
Dockerize WAR projects
Web applications in Java are often packaged as WAR files. Jib can now containerize WAR projects as well, with no extra configuration. Simply run:
$ mvn package jib:build
$ gradle jib
The default application server in the container is Jetty, but you can also use a different server like Tomcat by configuring the base image and
Integration with Skaffold for Java on Kubernetes development
Skaffold is a command-line tool for continuous development on Kubernetes. We integrated Skaffold with Jib to make developing on Kubernetes seamless. Jib is now available as a builder in Skaffold.
To start using Skaffold with your Java project, install Skaffold and add a skaffold.yaml to your project:
Make sure you have your Kubernetes manifests in a
k8s/ directory and that the image reference in a Container spec matches
gcr.io/my-project/my-java-image. See the Skaffold repository for an example.
Then, start Skaffold’s continuous development with:
$ skaffold dev --trigger notify
Skaffold eliminates the tedious steps involved in rebuilding and redeploying your application for every change you make. Skaffold does this by containerizing your application with Jib and deploying it to your Kubernetes cluster whenever it detects a change. You can now focus on what you really care about—writing code.
Jib Core: build Docker images in Java
Jib runs on our own general-purpose library for building container images, which we’ve released as Jib Core along with some API refinements. Now you can use Jib as more than just Maven and Gradle plugins—you can now build containers in Java without a Docker daemon, for any application.
Start using Jib Core by adding it to your project:
The following is an example that builds a simple Docker image. It starts with a base image, adds a single layer, sets the entrypoint, and pushes to a remote registry with just a few lines of code:
We welcome you to use Jib Core to build your own custom containerization solutions. Feel free to share with us any projects you’re using Jib Core with on our Gitter channel. Check out some other examples of how to use Jib Core, like from a Gradle build script.
All that, and the same simple containerization experience
Containerizing a Java application with Jib is still just as easy as before. If you are using Maven, add the plugin to your
To build and push the image to a container registry, use:
Or, to build to a Docker daemon, use:
You can now even containerize your application without touching your
pom.xml just by calling:
For more details, see the Jib Maven Quickstart.
When using Jib for Gradle, add the plugin to your
You can then containerize your application to a container registry with:
Or, containerize to a Docker daemon with:
For more details, see the Jib Gradle Quickstart.
Get started today
We want everyone to use Jib to simplify and accelerate their Java development. To get started with Jib, check out our samples and Codelabs for deploying a Spring Boot application to Kubernetes or deploying a Micronaut application to Kubernetes. Jib works with most Docker registry providers and hosted registries; try it out and let us know what you think at github.com/GoogleContainerTools/jib.
Feed Source: Google Cloud Platform
Article Source: Jib 1.0.0 is GA—building Java Docker images has never been easier