@Mojo(name="build") public class BuildMojo extends AbstractDockerMojo
| Modifier and Type | Field and Description |
|---|---|
private String |
baseImage
The base image to use.
|
protected String |
buildDirectory
All resources will be copied to this directory before building the image.
|
private String |
cmd
The cmd command for the image.
|
private String |
defaultProfile |
private String |
dockerDirectory
Directory containing the Dockerfile.
|
private String |
entryPoint
The entry point of the image.
|
private Map<String,String> |
env |
private List<String> |
exposes |
private Set<String> |
exposesSet |
private org.apache.maven.plugin.PluginParameterExpressionEvaluator |
expressionEvaluator |
private boolean |
forceTags
Flag to use force option while tagging.
|
private String |
imageName
Built image will be given this name.
|
private List<String> |
imageTags
Additional tags to tag the image with.
|
private String |
maintainer
The maintainer of the image.
|
private org.apache.maven.project.MavenProject |
mavenProject |
private boolean |
noCache
Set to true to pass the `--no-cache` flag to the Docker daemon when building an image.
|
private String |
profile |
private boolean |
pullOnBuild
Flag to attempt to pull base images even if older images exists locally.
|
private boolean |
pushImage
Flag to push image after it is built.
|
private List<org.apache.maven.model.Resource> |
resources
Resources to include in the build.
|
private List<String> |
runList |
private List<String> |
runs
The run commands for the image.
|
private boolean |
skipDockerBuild
Flag to skip docker build, making build goal a no-op.
|
protected String |
tagInfoFile
Path to JSON file to write when tagging images.
|
private static char |
UNIX_SEPARATOR
The Unix separator character.
|
private boolean |
useGitCommitId
If specified as true, a tag will be generated consisting of the first 7 characters of the most
recent git commit ID, resulting in something like image:df8e8e6.
|
private String |
user
The user for the image.
|
private static char |
WINDOWS_SEPARATOR
The Windows separator character.
|
private String |
workdir
The workdir for the image.
|
execution, session| Constructor and Description |
|---|
BuildMojo() |
BuildMojo(String defaultProfile) |
| Modifier and Type | Method and Description |
|---|---|
private void |
buildImage(com.spotify.docker.client.DockerClient docker,
String buildDir,
com.spotify.docker.client.DockerClient.BuildParameter... buildParameters) |
private com.spotify.docker.client.DockerClient.BuildParameter[] |
buildParams() |
private List<String> |
copyResources(String destination) |
private void |
createDockerFile(String directory,
List<String> filesToAdd) |
private File |
createImageArtifact(org.apache.maven.artifact.Artifact mainArtifact,
DockerBuildInformation buildInfo) |
protected void |
execute(com.spotify.docker.client.DockerClient docker) |
private String |
expand(String raw) |
private String |
get(String override,
com.typesafe.config.Config config,
String path) |
private String |
getDestination() |
boolean |
getForceTags() |
String |
getImageName() |
boolean |
getPushImage() |
private void |
loadProfile() |
private String |
normalizeDest(String filePath) |
static String |
separatorsToUnix(String path)
Converts all separators to the Unix separator of forward slash.
|
private void |
tagImage(com.spotify.docker.client.DockerClient docker,
boolean forceTags) |
private void |
validateParameters() |
authConfig, execute, getBuilder, getRetryPushCount, getRetryPushTimeout, rawDockerHostprivate static final char UNIX_SEPARATOR
private static final char WINDOWS_SEPARATOR
@Parameter(property="dockerDirectory") private String dockerDirectory
@Parameter(property="skipDockerBuild",
defaultValue="false")
private boolean skipDockerBuild
@Parameter(property="pullOnBuild",
defaultValue="false")
private boolean pullOnBuild
@Parameter(property="noCache",
defaultValue="false")
private boolean noCache
@Parameter(property="pushImage",
defaultValue="false")
private boolean pushImage
@Parameter(property="forceTags",
defaultValue="false")
private boolean forceTags
@Parameter(property="dockerMaintainer") private String maintainer
@Parameter(property="dockerBaseImage") private String baseImage
@Parameter(property="dockerEntryPoint") private String entryPoint
@Parameter(property="dockerCmd") private String cmd
@Parameter(property="workdir") private String workdir
@Parameter(property="user") private String user
@Parameter(property="project.build.directory") protected String buildDirectory
@Parameter(property="dockerBuildProfile") private String profile
@Parameter(property="tagInfoFile",
defaultValue="${project.build.testOutputDirectory}/image_info.json")
protected String tagInfoFile
@Parameter(property="useGitCommitId",
defaultValue="false")
private boolean useGitCommitId
@Parameter(property="dockerResources") private List<org.apache.maven.model.Resource> resources
@Parameter(property="dockerImageName") private String imageName
@Parameter(property="dockerImageTags") private List<String> imageTags
@Parameter(property="dockerDefaultBuildProfile") private String defaultProfile
@Parameter(defaultValue="${project}")
private org.apache.maven.project.MavenProject mavenProject
private org.apache.maven.plugin.PluginParameterExpressionEvaluator expressionEvaluator
public BuildMojo()
public BuildMojo(String defaultProfile)
public String getImageName()
public boolean getPushImage()
public boolean getForceTags()
protected void execute(com.spotify.docker.client.DockerClient docker)
throws org.apache.maven.plugin.MojoExecutionException,
org.eclipse.jgit.api.errors.GitAPIException,
IOException,
com.spotify.docker.client.DockerException,
InterruptedException
execute in class AbstractDockerMojoorg.apache.maven.plugin.MojoExecutionExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionIOExceptioncom.spotify.docker.client.DockerExceptionInterruptedExceptionprivate String getDestination()
private File createImageArtifact(org.apache.maven.artifact.Artifact mainArtifact, DockerBuildInformation buildInfo) throws IOException
IOExceptionprivate void loadProfile()
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate String get(String override, com.typesafe.config.Config config, String path) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate String expand(String raw) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate void validateParameters()
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate void buildImage(com.spotify.docker.client.DockerClient docker,
String buildDir,
com.spotify.docker.client.DockerClient.BuildParameter... buildParameters)
throws org.apache.maven.plugin.MojoExecutionException,
com.spotify.docker.client.DockerException,
IOException,
InterruptedException
org.apache.maven.plugin.MojoExecutionExceptioncom.spotify.docker.client.DockerExceptionIOExceptionInterruptedExceptionprivate void tagImage(com.spotify.docker.client.DockerClient docker,
boolean forceTags)
throws com.spotify.docker.client.DockerException,
InterruptedException,
org.apache.maven.plugin.MojoExecutionException
com.spotify.docker.client.DockerExceptionInterruptedExceptionorg.apache.maven.plugin.MojoExecutionExceptionprivate void createDockerFile(String directory, List<String> filesToAdd) throws IOException
IOExceptionprivate List<String> copyResources(String destination) throws IOException
IOExceptionpublic static String separatorsToUnix(String path)
path - the path to be changed, null ignoredprivate com.spotify.docker.client.DockerClient.BuildParameter[] buildParams()
Copyright © 2015. All rights reserved.