use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class PropertyConfigHandlerTest method resolveExternalImageConfig.
private ImageConfiguration resolveExternalImageConfig(String[] testData) {
Map<String, String> external = new HashMap<>();
external.put("type", "props");
ImageConfiguration config = new ImageConfiguration.Builder().name("image").alias("alias").externalConfig(external).build();
List<ImageConfiguration> resolvedImageConfigs = resolveImage(config, props(testData));
assertEquals(1, resolvedImageConfigs.size());
return resolvedImageConfigs.get(0);
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class PropertyConfigHandlerTest method testFilter.
@Test
public void testFilter() {
String filter = "@";
String[] testData = new String[] { k(ConfigKey.NAME), "image", k(ConfigKey.FROM), "base", k(ConfigKey.FILTER), filter };
ImageConfiguration config = resolveExternalImageConfig(testData);
assertEquals(filter, config.getBuildConfiguration().getFilter());
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class PropertyConfigHandlerTest method testRunCommands.
@Test
public void testRunCommands() {
List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.from", "base", "docker.name", "demo", "docker.run.1", "foo", "docker.run.2", "bar", "docker.run.3", "wibble"));
assertEquals(1, configs.size());
BuildImageConfiguration buildConfig = configs.get(0).getBuildConfiguration();
String[] runCommands = new ArrayList<>(buildConfig.getRunCmds()).toArray(new String[buildConfig.getRunCmds().size()]);
assertArrayEquals(new String[] { "foo", "bar", "wibble" }, runCommands);
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class BuildMojo method buildAndTag.
@Override
protected void buildAndTag(ServiceHub hub, ImageConfiguration imageConfig) throws MojoExecutionException, DockerAccessException {
try {
// TODO need to refactor d-m-p to avoid this call
EnvUtil.storeTimestamp(this.getBuildTimestampFile(), this.getBuildTimestamp());
fabric8ServiceHub.getBuildService().build(imageConfig);
} catch (Exception ex) {
throw new MojoExecutionException("Failed to execute the build", ex);
}
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class WebAppGenerator method customize.
@Override
public List<ImageConfiguration> customize(List<ImageConfiguration> configs, boolean prePackagePhase) {
if (getContext().getMode() == PlatformMode.openshift && getContext().getStrategy() == OpenShiftBuildStrategy.s2i) {
throw new IllegalArgumentException("S2I not yet supported for the webapp-generator. Use -Dfabric8.mode=kubernetes or " + "-Dfabric8.build.strategy=docker for OpenShift mode. Please refer to the reference manual at " + "https://maven.fabric8.io for details about build modes.");
}
// Late initialization to avoid unnecessary directory scanning
AppServerHandler handler = getAppServerHandler(getContext());
log.info("Using %s as base image for webapp", handler.getFrom());
ImageConfiguration.Builder imageBuilder = new ImageConfiguration.Builder();
BuildImageConfiguration.Builder buildBuilder = new BuildImageConfiguration.Builder().from(getFrom(handler)).ports(handler.exposedPorts()).cmd(getDockerRunCommand(handler)).env(getEnv(handler));
if (!prePackagePhase) {
buildBuilder.assembly(createAssembly(handler));
}
addLatestTagIfSnapshot(buildBuilder);
imageBuilder.name(getImageName()).alias(getAlias()).buildConfig(buildBuilder.build());
configs.add(imageBuilder.build());
return configs;
}
Aggregations