Class AbstractImageBuildConfiguration

    • Field Detail

      • MULTISTAGE_CONTAINERFILE_REGEX

        protected static final Pattern MULTISTAGE_CONTAINERFILE_REGEX
        This is the regular expression to be used to determine a multistage Containerfile. For now we only support named stages.
      • DEFAULT_CONTAINERFILE

        protected static final String DEFAULT_CONTAINERFILE
        The default name of the Containerfile to build.
        See Also:
        Constant Field Values
      • contextDir

        @Parameter
        protected String contextDir
        The context directory to use
      • containerFileDir

        @Parameter
        protected File containerFileDir
        Directory containing the Containerfile
      • noCache

        @Parameter
        protected boolean noCache
        Configures whether caching should be used to build images.
      • pullPolicy

        @Parameter
        protected PullPolicy pullPolicy
        Configures whether from-images should be pulled so that the image will always be build on the latest base.
      • tags

        @Parameter
        protected String[] tags
        Array consisting of one or more tags to attach to a container image. Tags will be appended at the end of the image name
      • containerFile

        @Parameter
        protected String containerFile
        Name of the Containerfile to use. Defaults to Containerfile
      • labels

        @Parameter
        protected Map<String,​String> labels
        Specify any labels to be applied to the image
      • tagWithMavenProjectVersion

        @Parameter
        protected boolean tagWithMavenProjectVersion
        Specifies whether a version of the container image should be based on the version of this Maven project. Defaults to true. When set to false, 'podman.image.tag.version' must be specified.
      • mavenProjectVersion

        protected String mavenProjectVersion
        The Maven project version to use (only when useMavenProjectVersion is set to true)
      • createLatestTag

        @Parameter
        protected boolean createLatestTag
        Specified whether a container image should *ALSO* be tagged 'latest'. This defaults to false.
      • format

        @Parameter
        protected ContainerFormat format
        Specifies the format of the Container image to use
      • squash

        @Parameter
        protected Boolean squash
        Squash all of the image’s new layers into a single new layer; any preexisting layers are not squashed.

        See Also:
        "http://docs.podman.io/en/latest/markdown/podman-build.1.html"
      • squashAll

        @Parameter
        protected Boolean squashAll
        Squash all of the new image’s layers (including those inherited from a base image) into a single new layer.

        See Also:
        "http://docs.podman.io/en/latest/markdown/podman-build.1.html"
      • layers

        @Parameter
        protected Boolean layers
        Cache intermediate images during the build process (Default is true).

        Note: You can also override the default value of layers by setting the BUILDAH_LAYERS environment variable. export BUILDAH_LAYERS=true

        See Also:
        "http://docs.podman.io/en/latest/markdown/podman-build.1.html"
      • platform

        @Parameter
        protected String platform
        Specify the resulting image platform by being passed to the "--platform" option of podman.

        See Also:
        "https://docs.podman.io/en/latest/markdown/podman-build.1.html"
      • targetStage

        @Parameter
        protected String targetStage
        Specify the final target stage to build. It is passed to the "--target" option of podman.

        See Also:
        "https://docs.podman.io/en/latest/markdown/podman-build.1.html"
      • outputDirectory

        protected File outputDirectory
        Will be set when this class is validated using the #initAndValidate() method
      • valid

        protected boolean valid
        Represents the validity of this configuration
    • Constructor Detail

      • AbstractImageBuildConfiguration

        public AbstractImageBuildConfiguration()
    • Method Detail

      • isNoCache

        public boolean isNoCache()
        Returns which value should be used for the --no-cache property
        Returns:
        When set to true, podman will run with --no-cache=true
      • getPullPolicy

        public Optional<PullPolicy> getPullPolicy()
        Returns if the --pull property should be used
        Returns:
        When set to true, podman will build with --pull
      • validate

        public void validate​(org.apache.maven.project.MavenProject project)
      • getAllTags

        public List<String> getAllTags()
        Returns the tags to be applied for this image
        Returns:
        The tags to be applied
      • getContextDir

        public Optional<String> getContextDir()
        Returns the context directory path
        Returns:
        Returns the context directory path
      • getTargetContainerFile

        public Path getTargetContainerFile()
        Returns the path to the target Containerfile
        Returns:
        Returns a path to the target Containerfile
      • getLabels

        public Map<String,​String> getLabels()

        Returns the labels to be applied to the container image

        All specified labels will be added to the Containerfile after filtering.

        Returns:
        All labels to be added to the Containerfile
      • getOutputDirectory

        public File getOutputDirectory()
        Returns the project's output directory
        Returns:
        The configured output directory
      • getFormat

        public ContainerFormat getFormat()
        Returns the format for the built image's manifest and configuration data.
        Returns:
        The format for the built image's manifest and configuration data
      • isMultistageContainerFile

        public boolean isMultistageContainerFile()
        Returns true when the Containerfile is a multistage Containerfile
        Returns:
        true when a multistage Containerfile is used
      • getMultistageContainerfilePattern

        public Pattern getMultistageContainerfilePattern()
        Returns the Pattern that is used to determine if a line matches a multi-stage Containerfile
        Returns:
        The pattern to determine if a line matches the expected pattern for a multi-stage Containerfile.
      • getSquash

        public Boolean getSquash()
        Returns true when all of the image’s new layers should be squashed into a single new layer; any preexisting layers are not squashed.
        Returns:
        true when all of the images's new layers should be squashed into a new layer. False otherwise.
      • getSquashAll

        public Boolean getSquashAll()
        Returns true when all of the image’s new layers, including those inherited from a base image, into a single new layer.
        Returns:
        true when all of the images's new layers should be squashed into a new layer. False otherwise.
      • getLayers

        public Boolean getLayers()
        Returns true if intermediate layers should be cached during a Podman build.
        Returns:
        true, when intermediate layers should be cached. False otherwise.
      • getPlatform

        public Optional<String> getPlatform()
        Returns the platform that Podman should be told to build for.
        Returns:
        When set, a string in the format of GO OS/GO ARCH (because GO is the language of Podman) for example: linux/arm64
      • getTargetStage

        public Optional<String> getTargetStage()
        Returns the final target stage to build.
        Returns:
        if set, the final target stage to build defined in Containerfile.
      • isValid

        public boolean isValid()
        Returns a boolean indicating whether this configuration is valid
        Returns:
        true if this configuration is valid. False otherwise.
      • isCreateLatestTag

        public boolean isCreateLatestTag()
        Returns true when a latest tag should be created
        Returns:
        true if an image should be tagged 'latest'
      • isContainerFileEmpty

        protected boolean isContainerFileEmpty​(org.apache.maven.plugin.logging.Log log,
                                               Path fullContainerFilePath)
                                        throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • determineBuildStages

        protected void determineBuildStages​(org.apache.maven.plugin.logging.Log log,
                                            Path fullContainerFilePath)
                                     throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • setLayers

        public void setLayers​(Boolean layers)
        Configures whether to cache intermediate images during the build process.
        Parameters:
        layers - The value to set
      • setPlatform

        public void setPlatform​(String platform)
        Used to set the platform to be passed to Podman when building the image.
        Parameters:
        platform - String in the format of GO OS/GO ARCH (because GO is the language of Podman) for example: linux/arm64
      • setNoCache

        public void setNoCache​(boolean noCache)
        Sets the noCache option. Allows configuring whether caching should be used to cache images
        Parameters:
        noCache - Sets the noCache option on and off.
      • setPullPolicy

        public void setPullPolicy​(PullPolicy pullPolicy)
        Configures whether from-images should be pulled so that the image will always be build on the latest base.
        Parameters:
        pullPolicy - The value to set
      • setSquash

        public void setSquash​(Boolean squash)
        Configures whether to squash all newly created layers into one layer.
        Parameters:
        squash - The value to set
      • setSquashAll

        public void setSquashAll​(Boolean squashAll)
        Configures whether to squash all layers into one layer, this includes the base layer(s).
        Parameters:
        squashAll - The value to set
      • setTags

        public void setTags​(String[] tags)
        Sets the tags that should be used for this image
        Parameters:
        tags - The tags this image should receive
      • setContainerFile

        public void setContainerFile​(String containerFile)
        Sets the name of the Containerfile (defaults to Containerfile)
        Parameters:
        containerFile - The name of the Containerfile to set
      • setLabels

        public void setLabels​(Map<String,​String> labels)
        Sets the labels to add to the container image.
        Parameters:
        labels - The labels to set.
      • setTagWithMavenProjectVersion

        public void setTagWithMavenProjectVersion​(boolean tagWithMavenProjectVersion)
        Specifies whether the image should be tagged with the Maven Project version
        Parameters:
        tagWithMavenProjectVersion - whether the image should be tagged with the Maven project version
      • setCreateLatestTag

        public void setCreateLatestTag​(boolean createLatestTag)
        Specifies whether a latest tag should be created
        Parameters:
        createLatestTag - If true, the image will receive the tag 'latest'
      • setFormat

        public void setFormat​(ContainerFormat format)
        The format of the container image to use.
        Parameters:
        format - The format to use
      • setContextDir

        public void setContextDir​(String contextDir)
        Sets the context directory to use
        Parameters:
        contextDir - The directory to set
      • setContainerFileDir

        public void setContainerFileDir​(File containerFileDir)
        Sets the directory where the Containerfile is located (copied from BatchImageBuildCOnfiguration).
        Parameters:
        containerFileDir - The directory to set
      • setTargetStage

        public void setTargetStage​(String targetStage)
        Sets the final target stage to build.
        Parameters:
        targetStage - The final target stage to build.
      • getArgs

        public Map<String,​String> getArgs()
        Retrieves a collection of build arguments to provide to podman build using --build-arg
        Returns:
        A collection of build arguments to provide to podman build
      • setArgs

        public void setArgs​(Map<String,​String> args)
        The build arguments to set for use during Podman build
        Parameters:
        args - The arguments to set
      • getUlimits

        public Map<String,​String> getUlimits()
        Retrieves a collection of user limtis to provide to podman build using --ulimits
        Returns:
        A collection of user limits to provide to podman build
      • setUlimits

        public void setUlimits​(Map<String,​String> ulimits)
        The user limits to set for use during Podman build
        Parameters:
        ulimits - The arguments to set