use of io.fabric8.maven.docker.config.BuildImageConfiguration in project docker-maven-plugin by fabric8io.
the class BuildService method autoPullBaseImage.
private void autoPullBaseImage(ImageConfiguration imageConfig, ImagePullManager imagePullManager, BuildContext buildContext) throws DockerAccessException, MojoExecutionException {
BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
if (buildConfig.getDockerArchive() != null) {
// No auto pull needed in archive mode
return;
}
String fromImage;
if (buildConfig.isDockerFileMode()) {
fromImage = extractBaseFromDockerfile(buildConfig, buildContext);
} else {
fromImage = extractBaseFromConfiguration(buildConfig);
}
if (fromImage != null && !DockerAssemblyManager.SCRATCH_IMAGE.equals(fromImage)) {
registryService.pullImageWithPolicy(fromImage, imagePullManager, buildContext.getRegistryConfig(), queryService.hasImage(fromImage));
}
}
use of io.fabric8.maven.docker.config.BuildImageConfiguration in project docker-maven-plugin by fabric8io.
the class DockerAssemblyManagerTest method testNoAssembly.
@Test
public void testNoAssembly() {
BuildImageConfiguration buildConfig = new BuildImageConfiguration();
AssemblyConfiguration assemblyConfig = buildConfig.getAssemblyConfiguration();
DockerFileBuilder builder = assemblyManager.createDockerFileBuilder(buildConfig, assemblyConfig);
String content = builder.content();
assertFalse(content.contains("COPY"));
assertFalse(content.contains("VOLUME"));
}
use of io.fabric8.maven.docker.config.BuildImageConfiguration in project docker-maven-plugin by fabric8io.
the class DockerAssemblyManagerTest method testCopyValidVerifyGivenDockerfile.
@Test
public void testCopyValidVerifyGivenDockerfile(@Injectable final Logger logger) throws IOException {
BuildImageConfiguration buildConfig = createBuildConfig();
assemblyManager.verifyGivenDockerfile(new File(getClass().getResource("/docker/Dockerfile_assembly_verify_copy_valid.test").getPath()), buildConfig, createInterpolator(buildConfig), logger);
new Verifications() {
{
logger.warn(anyString, (Object[]) any);
times = 0;
}
};
}
use of io.fabric8.maven.docker.config.BuildImageConfiguration in project docker-maven-plugin by fabric8io.
the class DockerAssemblyManagerTest method testCopyInvalidVerifyGivenDockerfile.
@Test
public void testCopyInvalidVerifyGivenDockerfile(@Injectable final Logger logger) throws IOException {
BuildImageConfiguration buildConfig = createBuildConfig();
assemblyManager.verifyGivenDockerfile(new File(getClass().getResource("/docker/Dockerfile_assembly_verify_copy_invalid.test").getPath()), buildConfig, createInterpolator(buildConfig), logger);
new Verifications() {
{
logger.warn(anyString, (Object[]) any);
times = 1;
}
};
}
use of io.fabric8.maven.docker.config.BuildImageConfiguration in project docker-maven-plugin by fabric8io.
the class SourceMojo method executeInternal.
@Override
protected void executeInternal(ServiceHub hub) throws DockerAccessException, MojoExecutionException {
MojoParameters params = createMojoParameters();
List<ImageConfiguration> imageConfigs = new ArrayList<>();
for (ImageConfiguration imageConfig : getResolvedImages()) {
BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
if (buildConfig != null) {
if (buildConfig.skip()) {
log.info("%s: Skipped creating source", imageConfig.getDescription());
} else {
imageConfigs.add(imageConfig);
}
}
}
if (sourceMode == BuildImageSelectMode.first && imageConfigs.size() > 0) {
ImageConfiguration imageConfig = imageConfigs.get(0);
File dockerTar = hub.getArchiveService().createDockerBuildArchive(imageConfig, params);
projectHelper.attachArtifact(project, getArchiveType(imageConfig), getClassifier(null), dockerTar);
} else {
for (ImageConfiguration imageConfig : imageConfigs) {
File dockerTar = hub.getArchiveService().createDockerBuildArchive(imageConfig, params);
String alias = imageConfig.getAlias();
if (alias == null) {
throw new IllegalArgumentException("Image " + imageConfig.getDescription() + " must have an 'alias' configured to be " + "used as a classifier for attaching a docker build tar as source to the maven build");
}
projectHelper.attachArtifact(project, getArchiveType(imageConfig), getClassifier(alias), dockerTar);
}
}
}
Aggregations