use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class LogOutputSpecFactory method addPrefix.
private void addPrefix(LogOutputSpec.Builder builder, String logPrefix, ImageConfiguration imageConfig, String containerId) {
String prefixFormat = logPrefix;
if (prefixFormat == null) {
prefixFormat = DEFAULT_PREFIX_FORMAT;
}
FormatParameterReplacer formatParameterReplacer = new FormatParameterReplacer(getPrefixFormatParameterLookups(imageConfig, containerId));
builder.prefix(formatParameterReplacer.replace(prefixFormat));
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class LogOutputSpecFactory method createSpec.
// ================================================================================================
public LogOutputSpec createSpec(String containerId, ImageConfiguration imageConfiguration) {
LogOutputSpec.Builder builder = new LogOutputSpec.Builder();
LogConfiguration logConfig = extractLogConfiguration(imageConfiguration);
addLogFormat(builder, logConfig);
addPrefix(builder, logConfig.getPrefix(), imageConfiguration, containerId);
builder.file(logConfig.getFileLocation()).useColor(useColor).logStdout(logStdout).color(logConfig.getColor());
return builder.build();
}
use of io.fabric8.maven.docker.config.ImageConfiguration 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.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class WaitService method prepareWaitCheckers.
private List<WaitChecker> prepareWaitCheckers(ImageConfiguration imageConfig, Properties projectProperties, String containerId) throws MojoExecutionException {
WaitConfiguration wait = getWaitConfiguration(imageConfig);
if (wait == null) {
return Collections.emptyList();
}
List<WaitChecker> checkers = new ArrayList<>();
if (wait.getUrl() != null) {
checkers.add(getUrlWaitChecker(imageConfig.getDescription(), projectProperties, wait));
}
if (wait.getLog() != null) {
log.debug("LogWaitChecker: Waiting on %s", wait.getLog());
checkers.add(new LogWaitChecker(wait.getLog(), dockerAccess, containerId, log));
}
if (wait.getTcp() != null) {
try {
Container container = queryService.getMandatoryContainer(containerId);
checkers.add(getTcpWaitChecker(container, imageConfig.getDescription(), projectProperties, wait.getTcp()));
} catch (DockerAccessException e) {
throw new MojoExecutionException("Unable to access container.", e);
}
}
if (wait.getHealthy() == Boolean.TRUE) {
checkers.add(new HealthCheckChecker(dockerAccess, containerId, imageConfig.getDescription(), log));
}
if (wait.getExit() != null) {
checkers.add(new ExitCodeChecker(wait.getExit(), queryService, containerId));
}
return checkers;
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class WatchService method createCopyWatchTask.
private Runnable createCopyWatchTask(final ImageWatcher watcher, final MojoParameters mojoParameters, final String containerBaseDir) throws MojoExecutionException {
final ImageConfiguration imageConfig = watcher.getImageConfiguration();
final AssemblyFiles files = archiveService.getAssemblyFiles(imageConfig, mojoParameters);
return new Runnable() {
@Override
public void run() {
List<AssemblyFiles.Entry> entries = files.getUpdatedEntriesAndRefresh();
if (entries != null && entries.size() > 0) {
try {
log.info("%s: Assembly changed. Copying changed files to container ...", imageConfig.getDescription());
File changedFilesArchive = archiveService.createChangedFilesArchive(entries, files.getAssemblyDirectory(), imageConfig.getName(), mojoParameters);
dockerAccess.copyArchive(watcher.getContainerId(), changedFilesArchive, containerBaseDir);
callPostExec(watcher);
} catch (MojoExecutionException | IOException | ExecException e) {
log.error("%s: Error when copying files to container %s: %s", imageConfig.getDescription(), watcher.getContainerId(), e.getMessage());
}
}
}
};
}
Aggregations