@VisibleForTesting
  BuildContext toBuildContext(Containerizer containerizer) throws CacheDirectoryCreationException {
    return buildContextBuilder
        .setTargetImageConfiguration(containerizer.getImageConfiguration())
        .setAdditionalTargetImageTags(containerizer.getAdditionalTags())
        .setBaseImageLayersCacheDirectory(containerizer.getBaseImageLayersCacheDirectory())
        .setApplicationLayersCacheDirectory(containerizer.getApplicationLayersCacheDirectory())
        .setContainerConfiguration(containerConfigurationBuilder.build())
        .setLayerConfigurations(layerConfigurations)
        .setAllowInsecureRegistries(containerizer.getAllowInsecureRegistries())
        .setOffline(containerizer.isOfflineMode())
        .setToolName(containerizer.getToolName())
        .setToolVersion(containerizer.getToolVersion())
        .setExecutorService(containerizer.getExecutorService().orElse(null))
        .setEventHandlers(containerizer.buildEventHandlers())
        .setAlwaysCacheBaseImage(containerizer.getAlwaysCacheBaseImage())
        .setRegistryMirrors(containerizer.getRegistryMirrors())
        .build();
  }
Builds a {@link BuildContext} using this and a {@link Containerizer}.

@param containerizer the {@link Containerizer}
@return the {@link BuildContext}
@throws CacheDirectoryCreationException if a cache directory could not be created
jib-core/src/main/java/com/google/cloud/tools/jib/api/JibContainerBuilder.java