public async Task <BuildResult> CallAsync() { await pullAndCacheBaseImageLayersStep.GetFuture().ConfigureAwait(false); await buildAndCacheApplicationLayersStep.GetFuture().ConfigureAwait(false); await buildImageStep.GetFuture().ConfigureAwait(false); string description = string.Format( CultureInfo.CurrentCulture, Resources.WriteTarFileStepDescriptionFormat, outputPath.GetFileName()); buildConfiguration.GetEventHandlers().Dispatch(LogEvent.Progress(description)); using (progressEventDispatcherFactory.Create(description, this.Index)) { Image image = await buildImageStep.GetFuture().ConfigureAwait(false); // Builds the image to a tarball. Files.CreateDirectories(outputPath.GetParent()); using (Stream outputStream = new BufferedStream(FileOperations.NewLockingOutputStream(outputPath))) { await new ImageTarball(image, buildConfiguration.GetTargetImageConfiguration().GetImage()) .WriteToAsync(outputStream).ConfigureAwait(false); } return(await BuildResult.FromImageAsync(image, buildConfiguration.GetTargetFormat()).ConfigureAwait(false)); } }
public async Task <BuildResult> CallAsync() { await pullAndCacheBaseImageLayersStep.GetFuture().ConfigureAwait(false); await buildAndCacheApplicationLayersStep.GetFuture().ConfigureAwait(false); await buildImageStep.GetFuture().ConfigureAwait(false); buildConfiguration .GetEventHandlers() .Dispatch(LogEvent.Progress(Resources.LoadDockerStepDescription)); using (progressEventDispatcherFactory.Create(Resources.LoadDockerStepDescription, 1)) { Image image = await buildImageStep.GetFuture().ConfigureAwait(false); IImageReference targetImageReference = buildConfiguration.GetTargetImageConfiguration().GetImage(); // Load the image to docker daemon. buildConfiguration .GetEventHandlers() .Dispatch( LogEvent.Debug(await dockerClient.LoadAsync(new ImageTarball(image, targetImageReference)).ConfigureAwait(false))); // Tags the image with all the additional tags, skipping the one 'docker load' already loaded. foreach (string tag in buildConfiguration.GetAllTargetImageTags()) { if (tag.Equals(targetImageReference.GetTag(), StringComparison.Ordinal)) { continue; } ImageReference taggedImageReference = targetImageReference.WithTag(tag); await dockerClient.TagAsync(targetImageReference, taggedImageReference).ConfigureAwait(false); } return(await BuildResult.FromImageAsync(image, buildConfiguration.GetTargetFormat()).ConfigureAwait(false)); } }