Image Configuration

The plugin’s configuration is centered around images.Images can be either configured individually, as part of a batch or a combination of both. When configured individually, each image is specified in the <images> element of the configuration with one <image> element per image to use.

The <image> element can contain the following sub elements:

Table 1. Image configuration options
Element Description

name

Each <image> configuration has a mandatory, unique container repository name. This name does not support placeholer characters, see Image Names.

NOTE: Currently image names cannot include registry and tag parts.

customImageNameForMultiStageContainerfile

A Containerfile can define multiple stages. When set to true, the result of each stage can have a different image name.

When set to false, but the Containerfile does define one or more stages, a warning will be logged and the value from the name property will be used.

stages

Defines a list of custom image names per stage listed in a Containerfile

build

Element that contains all the configuration aspects when doing a podman:build.

A <build> section must be present for each image configuration.

Listing 1. Example configuration
<configuration>
    ...
    <images>
        <image>
            <name>your-image-name</name>
            <customImageNameForMultiStageContainerfile>true</customImageNameForMultiStageContainerfile>
            <stages>...</stages>
            <build>...</build>
        </image>
    </images>
    ...
</configuration>

Batch Configuration

In some special cases it may be convenient to configure a series of images at once, e.g. if there are multiple Containerfiles in your project which all share the same configuration but only differ by name.

A batch configuraion can be configured within the <batch/> element of the configuration. It is possible to specify one batch configuration.

The <batch/> element supports the same elements as the <image/> element. An example configuration is provided below.

Resulting image names must be unique, otherwise one image may overwrite another.
Listing 2. Example batch configuration
<configuration>
    ...
    <batch>
        <name>your-image-name</name>
        <customImageNameForMultiStageContainerfile>true</customImageNameForMultiStageContainerfile>
        <stages>...</stages>
        <build>...</build>
    </batch>
</configuration>

Stage Configuration

The stages configuration section is useful when working with multi-stage Containerfiles.

Table 2. Stage configuration options
Element Description

name

The name of the stage in a Containerfile. A stage in a Containerfile is usually defined as: FROM <image> AS <stageName>.

imageName

The target name that the image, which was built in stage with <name>, should get.

Listing 3. Example configuration
<configuration>
    ...
    <images>
        <image>
            <stages>
                <stage>
                    <name>some_stage</name>
                    <imageName>my-fancy-image</imageName>
                </stage>
            </stages>
        </image>
    </images>
    ...
</configuration>

Image Names

When providing an image name in either the <image/> or <batch/> configuration with the <name> field, there are several placeholders available for use.These placeholders are replaced by this plugin at runtime, before each goal executes.In addition you can use regular Maven properties which are resolved by Maven itself.

These placeholders also work when using a custom image name per stage.
Table 3. Image name placeholders
Placeholder Description

%a

Sanitized version of the artifactId that can be used as part of a container image name.The artifactId is converted to lowercase as per container naming conventions.

%d

A sanitized version of the directory name where the Containerfile is located. E.g. /tmp/subFolder/Containerfile will be result in subFolder.

%g

The last part of the Maven groupId. Everything after the last . is used, i.e. com.example.sample will result in sample

%n

Returns a sequence number, which could be useful in e.g. a batch image configuration. An image named someImage-%n will be updated to someImage-0

%l

If the project version ends with -SNAPSHOT then this placeholder results in latest, otherwise the full Maven version is used (same as %v)

%t

Resolves to snapshot-<timestamp> where the timestamp is formatted as yyMMdd-HHmmss-SSSS

%v

The project version. See also: ${project.version}