diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/index.adoc b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/index.adoc index f5a0cfd841..4e11d45139 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/index.adoc +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/index.adoc @@ -17,6 +17,7 @@ It allows you to package executable jar or war archives, run Spring Boot applica include::getting-started.adoc[] include::packaging.adoc[] +include::packaging-oci-image.adoc[] include::running.adoc[] include::integration-tests.adoc[] include::build-info.adoc[] diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc new file mode 100644 index 0000000000..064eb52d84 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc @@ -0,0 +1,111 @@ +[[build-image]] +== Packaging OCI Images + +The plugin can create https://github.com/opencontainers/image-spec[OCI images] using a https://buildpacks.io/[buildpack]. +Images can be built using the `build-image` goal and a local Docker installation. + +It is possible to automate the creation of an image whenever the `package` phase is invoked, as shown in the following example: + +[source,xml,indent=0,subs="verbatim,attributes"] +---- + + + + org.springframework.boot + spring-boot-maven-plugin + {version} + + + + build-image + + + + + + +---- + +TIP: While the buildpack runs from an <>, it is not necessary to execute the `repackage` goal first as the executable archive is created automatically if necessary. +When the `build-image` repackages the application, it applies the same settings as the `repackage` goal would, i.e. dependencies can be excluded using one of the exclude options, and Devtools is automatically excluded by default (you can control that using the `excludeDevtools` property). + +By default, the image is built using the `cloudfoundry/cnb:0.0.43-bionic` builder and its name is deduced from the `artifactId` of the project. +Both these settings can be tuned via configuration, see <> and <>. + +include::goals/build-image.adoc[leveloffset=+1] + + +[[build-image-examples]] +=== Examples + +[[build-image-example-custom-image-builder]] +==== Custom Image Builder +If you need to customize the builder used to create the image, configure yours as shown in the following example: + +[source,xml,indent=0,subs="verbatim,attributes"] +---- + + + + + org.springframework.boot + spring-boot-maven-plugin + {version} + + + build-image + + build-image + + + + mine/java-cnb-builder + + + + + + + + +---- + +This configuration will use the `latest` version of the `mine/java-cnb-builder` builder. + + + +[[build-image-example-custom-image-name]] +==== Custom Image Name +By default, the image name is inferred from the `artifactId` and the `version` of the project, something like `docker.io/library/${project.artifactId}:{project.version}`. +You can take control over the name, as shown in the following example: + +[source,xml,indent=0,subs="verbatim,attributes"] +---- + + + + + org.springframework.boot + spring-boot-maven-plugin + {version} + + + build-image + + build-image + + + + example.com/library/${project.artifactId} + + + + + + + + +---- + +Note that this configuration does not provide an explicit version so `latest` is used. +It is possible to specify a version as well, either using `${project.version}`, any property available in the build or an hardcoded version. \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java index 9afa18a679..74fbe644cc 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java @@ -50,8 +50,7 @@ import org.springframework.boot.loader.tools.Libraries; import org.springframework.util.StringUtils; /** - * Package an application into a OCI image using a - * buildpack. + * Package an application into a OCI image using a buildpack. * * @author Phillip Webb * @since 2.3.0