liveBook · Manning

Build-image goal

As explained in Spring in Action, Sixth Edition

The build-image goal is the Spring Boot Maven plugin goal that builds a container image from a Spring Boot application.

The build-image goal builds a container image directly from a Spring Boot application through the Spring Boot Maven plugin. Spring Boot 2.3.0 and later can do this without extra dependencies, configuration files, or project changes. section 18.3

Build and run an image

Run ./mvnw spring-boot:build-image with Docker installed. The goal creates a default image tag from the project artifactId and version, such as library/tacocloud:0.0.19-SNAPSHOT. Start it with docker run -p8080:8080 library/tacocloud:0.0.19-SNAPSHOT. section 18.3

$ mvnw spring-boot:build-image \
    -Dspring-boot.build-image.imageName=tacocloud/tacocloud:0.0.19-SNAPSHOT

Use a custom image name when the image must reference an organization’s registry repository instead of the default library prefix. section 18.3

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains invocation, Docker requirements, default tags, custom tags, and running the resulting image.
Examples
Uses Taco Cloud image tags, Maven wrapper commands, Docker run port mapping, and a custom DockerHub repository name.
What it assumes
Assumes a Maven-built Spring Boot project and requires the Docker runtime on the build machine.
What you can do after
Build it from a Spring Boot Maven project and run the image with Docker on host port 8080.
How it connects
Connects the Spring Boot Maven plugin with Maven, Docker, container images, image tags, and image registries.

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.