Build

This goal will build all images which have a <build> configuration section. There must be a Containerfile present in order to build a container image.

Building a container image without a Containerfile, thus purely on configuration is currently not supported.

Build Configuration

This section covers all the possible options for the <build> tag.

Table 1. Build configuration options
Element Description

noCache

Do not use existing cached images for the container build. Build from the start with a new set of cached layers.

Default value is: false

pull

When the option is specified or set to “true”, pull the image. Raise an error if the image could not be pulled, even if the image is present locally.

If the option is disabled (with –pull=false) or not specified, pull the image from the registry only if the image is not present locally. Raise an error if the image is not found in the registries and is not present locally.

Default value is: true (note: deviates from Podman defaults)

See: https://docs.podman.io/en/latest/markdown/podman-build.1.html

pullAlways

Pull the image from the first registry it is found in as listed in registries.conf. Raise an error if not found in the registries, even if the image is present locally.

Default value is: false

See: https://docs.podman.io/en/latest/markdown/podman-build.1.html

tags

An array consisting of one or more tags to attach to the built container image. Tags will be appended at the end of the image name.

containerFile

The name of the Containerfile to build. If you are using a Dockerfile you should change this parameter.

Default value is: Containerfile

containerFileDir

Path of the directory where the Containerfile is located.

Default value is: Project base directory

labels

A collection of labels to add to this image. They are specified in the typical maven property format.

tagWithMavenProjectVersion

When set to true, the resulting container image will be tagged with the current version of the Maven project.

Default value is: true

createLatestTag

Specifies whether the resultig container image should be tagged with latest.

Default value is: false

format

Control the format for the built image’s manifest and configuration data.

Supported values are:

  • DOCKER (version 2, using schema format 2 for the manifest)

  • OCI (OCI image-spec v1.0, the default)

Default value is: OCI

Listing 1. Example configuration
<configuration>
    ...
    <images>
        <image>
            <name>your-image-name</name>
            <build>
                <pull>true</pull>
                <pullAlways>false</pullAlways>
                <tags>
                    <sampleTag>sampleTagValue</sampleTag>
                </tags>
                <createLatestTag>true</createLatestTag>
                <format>OCI</format>
            </build>
        </image>
    </images>
    ...
</configuration>

Batch Configuration

When using the <batch/> configuration option, some configuration options are interpreted slightly different, compared to the explanation in the table above. The table below lists all these configuration options that are interpreted differently.

Element Description

containerFileDir

The directory in which all Containerfile s should be found. Containerfile s are searched for recursively and do not need to be at this exact level.