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
Abstract base class for mojos related to Docker files and builds.
- Since:
- 1.1
- Author:
- Álvaro Sánchez-Mariscal, Iván López
-
Field Summary
FieldsModifier and TypeFieldDescriptionList of additional arguments that will be passed to the application.protected final ApplicationConfigurationServicestatic final Stringprotected StringThe builder-stage base image used to build the native image for docker-native packaging variants.protected StringThe Docker image used to run the native image.static final Stringstatic final Stringprotected final DockerServiceprotected final org.apache.maven.plugin.PluginParameterExpressionEvaluatorstatic final Stringprotected StringJib goal used to build Docker images fordockerpackaging.protected final JibConfigurationServicestatic final StringAdditional arguments that will be appended to the generated AWS Lambda native bootstrap command.static final Stringprotected StringThe main class of the application, as defined in the Exec Maven Plugin.protected final org.apache.maven.project.MavenProjectprotected final org.apache.maven.execution.MavenSessionprotected StringThe target runtime of the application.static final StringAdditional arguments that will be passed to thenative-imageexecutable.protected StringNetworking mode for the RUN instructions during build.static final Stringprotected StringThe version of Oracle Linux to use as a native-compile base when building a native image inside a Docker container.protected BooleanWhether to produce a static native image when usingdocker-nativepackaging.static final StringFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDockerMojo(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 Summary
Modifier and TypeMethodDescriptionprotected voidCopy project dependencies to atarget/dependencydirectory.protected static StringescapeJsonString(String source, String value) protected static StringescapeShellDoubleQuoted(String source, String value) protected Stringprotected StringgetCmd()protected StringgetFrom()protected Stringprotected StringgetPorts()getTags()protected Stringprotected Stringprotected Stringprotected StringgraalVmTag(String graalVmJvmVersion, Boolean staticNativeImage, String oracleLinuxVersion) protected booleanisArm()Check os.arch against known ARM architecture identifiers.protected org.apache.maven.artifact.versioning.ArtifactVersionprotected static StringjsonStringLiteral(String source, String value) protected voidlambdaBootstrapCommand(File dockerfile) Applies the generated AWS Lambda bootstrap script to a dockerfile template.protected voidoracleCloudFunctionCmd(File dockerfile) Adds cmd to docker oracle cloud function file.protected static StringshellLiteral(String source, String value) protected static StringvalidateDockerfileValue(String source, String value) protected static StringvalidateDownloadUrl(String source, String value) protected static StringvalidateExposedPorts(String source, String value) protected static StringvalidateImageReference(String source, String value) Methods inherited from class AbstractMicronautMojo
setLogMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setPluginContextMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.maven.plugin.Mojo
execute
-
Field Details
-
LATEST_TAG
- See Also:
-
DEFAULT_BASE_IMAGE_GRAALVM_RUN
- See Also:
-
DEFAULT_BASE_IMAGE_GRAALVM_BUILD
- See Also:
-
MOSTLY_STATIC_NATIVE_IMAGE_GRAALVM_FLAG
- See Also:
-
ARM_ARCH
-
X86_64_ARCH
- See Also:
-
ORACLE_CLOUD_FUNCTION_DEFAULT_CMD
- See Also:
-
GDS_DOWNLOAD_URL
- See Also:
-
LAMBDA_BOOTSTRAP_DOCKER_COMMAND_PLACEHOLDER
- See Also:
-
mavenProject
-
mavenSession
-
jibConfigurationService
-
applicationConfigurationService
-
dockerService
-
expressionEvaluator
-
nativeImageBuildArgs
Additional arguments that will be passed to thenative-imageexecutable. Note that this will only be used when using a packaging of typedocker-native. Fornative-imagepackaging you should use the Native Image Maven Plugin configuration options. -
appArguments
List of additional arguments that will be passed to the application. -
lambdaBootstrapArguments
@Parameter(property="micronaut.lambda.bootstrap.args") protected List<String> lambdaBootstrapArgumentsAdditional arguments that will be appended to the generated AWS Lambda native bootstrap command.- Since:
- 5.0.0
-
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 staticNativeImageWhether to produce a static native image when usingdocker-nativepackaging. -
micronautRuntime
The target runtime of the application. -
baseImageRun
@Parameter(property="micronaut.native-image.base-image-run", defaultValue="cgr.dev/chainguard/wolfi-base@sha256:52e71f61c6afd1f8d2625cff4465d8ecee156668ca665f7e9c582d1cc914eb6a") protected String baseImageRunThe Docker image used to run the native image.- Since:
- 1.2
-
baseImage
-
oracleLinuxVersion
@Parameter(property="micronaut.native-image.ol.version", defaultValue="ol9") protected String oracleLinuxVersionThe version of Oracle Linux to use as a native-compile base when building a native image inside a Docker container. -
networkMode
Networking mode for the RUN instructions during build.- Since:
- 4.0.0
-
jibBuildGoal
Jib goal used to build Docker images for
dockerpackaging.Defaults to
dockerBuild. Set it tobuildTarorbuildto avoid talking to a local Docker daemon duringpackage.- Since:
- 5.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
- Returns:
- the Java version from either the
maven.compiler.targetproperty or thejava.versionproperty.
-
graalVmJvmVersion
- Returns:
- the JVM version to use for GraalVM.
-
graalVmDownloadUrl
- Returns:
- the GraalVM download URL depending on the Java version.
-
graalVmArch
- Returns:
- the OS architecture to use for GraalVM depending on the
os.archsystem property.
-
getFrom
-
graalVmTag
protected String graalVmTag(String graalVmJvmVersion, Boolean staticNativeImage, String oracleLinuxVersion) - Parameters:
graalVmJvmVersion- the JVM version stringstaticNativeImage- whether to produce a static native imageoracleLinuxVersion- the Oracle Linux version to use- Returns:
- the GraalVM Docker image tag based on the provided parameters
-
isArm
Check os.arch against known ARM architecture identifiers.- Returns:
- true if we think we're running on an arm JDK
-
getFromImage
- Returns:
- the base image from the jib configuration (if any).
-
getJibFromImageSystemProperty
- Returns:
- the base image from the Jib system property override, if any.
-
getTags
-
getPorts
-
copyDependencies
Copy project dependencies to atarget/dependencydirectory.- Throws:
IOException
-
getCmd
-
getLambdaBootstrapCommand
- Returns:
- the generated AWS Lambda bootstrap command.
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
lambdaBootstrapCommand
protected void lambdaBootstrapCommand(File dockerfile) throws IOException, org.apache.maven.plugin.MojoExecutionException Applies the generated AWS Lambda bootstrap script to a dockerfile template.- Parameters:
dockerfile- the docker file- Throws:
IOExceptionorg.apache.maven.plugin.MojoExecutionException
-
validateDockerfileValue
protected static String validateDockerfileValue(String source, String value) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
validateImageReference
protected static String validateImageReference(String source, String value) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
validateExposedPorts
protected static String validateExposedPorts(String source, String value) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
validateDownloadUrl
protected static String validateDownloadUrl(String source, String value) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
jsonStringLiteral
protected static String jsonStringLiteral(String source, String value) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
escapeJsonString
protected static String escapeJsonString(String source, String value) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
shellLiteral
protected static String shellLiteral(String source, String value) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
escapeShellDoubleQuoted
protected static String escapeShellDoubleQuoted(String source, String value) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
getNetworkMode
- Returns:
- Networking mode for the RUN instructions during build (if any).
-
getProxyBuildArgs
- Returns:
- Map of proxy-related build arguments for Docker builds.
-
getBaseImage
- Returns:
- the base image to use for the Dockerfile.
-
oracleCloudFunctionCmd
protected void oracleCloudFunctionCmd(File dockerfile) throws IOException, org.apache.maven.plugin.MojoExecutionException Adds cmd to docker oracle cloud function file.- Parameters:
dockerfile- the docker file- Throws:
IOExceptionorg.apache.maven.plugin.MojoExecutionException
-