Class AbstractDockerMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
io.micronaut.maven.AbstractMicronautMojo
io.micronaut.maven.AbstractDockerMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
DockerCracMojo, DockerfileMojo, DockerMojo, DockerNativeMojo, DockerPushMojo

public abstract class AbstractDockerMojo extends AbstractMicronautMojo
Abstract base class for mojos related to Docker files and builds.
Since:
1.1
Author:
Álvaro Sánchez-Mariscal, Iván López
  • Field Details

    • LATEST_TAG

      public static final String LATEST_TAG
      See Also:
    • DEFAULT_BASE_IMAGE_GRAALVM_RUN

      public static final String DEFAULT_BASE_IMAGE_GRAALVM_RUN
      See Also:
    • MOSTLY_STATIC_NATIVE_IMAGE_GRAALVM_FLAG

      public static final String MOSTLY_STATIC_NATIVE_IMAGE_GRAALVM_FLAG
      See Also:
    • ARM_ARCH

      public static final String ARM_ARCH
      See Also:
    • X86_64_ARCH

      public static final String X86_64_ARCH
      See Also:
    • DEFAULT_ORACLE_LINUX_VERSION

      public static final String DEFAULT_ORACLE_LINUX_VERSION
      See Also:
    • mavenProject

      protected final org.apache.maven.project.MavenProject mavenProject
    • jibConfigurationService

      protected final JibConfigurationService jibConfigurationService
    • applicationConfigurationService

      protected final ApplicationConfigurationService applicationConfigurationService
    • dockerService

      protected final DockerService dockerService
    • expressionEvaluator

      protected final org.apache.maven.plugin.PluginParameterExpressionEvaluator expressionEvaluator
    • nativeImageBuildArgs

      @Parameter(property="micronaut.native-image.args") protected List<String> nativeImageBuildArgs
      Additional arguments that will be passed to the native-image executable. Note that this will only be used when using a packaging of type docker-native. For native-image packaging you should use the Native Image Maven Plugin configuration options.
    • appArguments

      @Parameter(property="mn.appArgs") protected List<String> appArguments
      List of additional arguments that will be passed to the application.
    • mainClass

      @Parameter(defaultValue="${exec.mainClass}", required=true) protected String mainClass
      The main class of the application, as defined in the Exec Maven Plugin.
    • staticNativeImage

      @Parameter(defaultValue="false", property="micronaut.native-image.static") protected Boolean staticNativeImage
      Whether to produce a static native image when using docker-native packaging.
    • micronautRuntime

      @Parameter(property="micronaut.runtime", defaultValue="NONE") protected String micronautRuntime
      The target runtime of the application.
    • baseImageRun

      @Parameter(property="micronaut.native-image.base-image-run", defaultValue="cgr.dev/chainguard/wolfi-base:latest") protected String baseImageRun
      The Docker image used to run the native image.
      Since:
      1.2
    • oracleLinuxVersion

      @Parameter(property="micronaut.native-image.ol.version", defaultValue="ol9") protected String oracleLinuxVersion
      The version of Oracle Linux to use as a native-compile base when building a native image inside a Docker container.
    • networkMode

      @Parameter(property="docker.networkMode") protected String networkMode
      Networking mode for the RUN instructions during build.
      Since:
      4.0.0
  • Constructor Details

    • AbstractDockerMojo

      protected AbstractDockerMojo(org.apache.maven.project.MavenProject mavenProject, JibConfigurationService jibConfigurationService, ApplicationConfigurationService applicationConfigurationService, DockerService dockerService, org.apache.maven.execution.MavenSession mavenSession, org.apache.maven.plugin.MojoExecution mojoExecution)
  • Method Details

    • javaVersion

      protected org.apache.maven.artifact.versioning.ArtifactVersion javaVersion()
      Returns:
      the Java version from either the maven.compiler.target property or the java.version property.
    • graalVmVersion

      protected String graalVmVersion()
      Returns:
      the GraalVM version from the graalvm.version property, which is expected to come from the Micronaut Parent POM.
    • graalVmJvmVersion

      protected String graalVmJvmVersion()
      Returns:
      the JVM version to use for GraalVM.
    • graalVmArch

      protected String graalVmArch()
      Returns:
      the OS architecture to use for GraalVM depending on the os.arch system property.
    • getFrom

      protected String getFrom()
      Returns:
      the base FROM image for the native image.
    • isArm

      protected boolean isArm()
      Check os.arch against known ARM architecture identifiers.
      Returns:
      true if we think we're running on an arm JDK
    • getFromImage

      protected Optional<String> getFromImage()
      Returns:
      the base image from the jib configuration (if any).
    • getTags

      protected Set<String> getTags()
      Returns:
      the Docker image tags by looking at the Jib plugin configuration.
    • getPort

      protected String getPort()
      Returns:
      the application port to expose by looking at the application configuration.
    • copyDependencies

      protected void copyDependencies() throws IOException
      Copy project dependencies to a target/dependency directory.
      Throws:
      IOException
    • getCmd

      protected String getCmd()
      Returns:
      the Docker CMD command.
    • getNetworkMode

      protected Optional<String> getNetworkMode()
      Returns:
      Networking mode for the RUN instructions during build (if any).
    • getBaseImage

      protected String getBaseImage()
      Returns:
      the base image to use for the Dockerfile.