@Override
  public Integer call() {
    commonCliOptions.validate();
    Path buildFile = getBuildFile();
    SingleThreadedExecutor executor = new SingleThreadedExecutor();
    ConsoleLogger logger =
        CliLogger.newLogger(
            commonCliOptions.getVerbosity(),
            commonCliOptions.getHttpTrace(),
            commonCliOptions.getConsoleOutput(),
            spec.commandLine().getOut(),
            spec.commandLine().getErr(),
            executor);
    Future<Optional<String>> updateCheckFuture = Futures.immediateFuture(Optional.empty());
    try {
      JibCli.configureHttpLogging(commonCliOptions.getHttpTrace().toJulLevel());
      GlobalConfig globalConfig = GlobalConfig.readConfig();
      updateCheckFuture =
          JibCli.newUpdateChecker(
              globalConfig,
              commonCliOptions.getVerbosity(),
              logEvent -> logger.log(logEvent.getLevel(), logEvent.getMessage()));
      if (!Files.isReadable(buildFile)) {
        logger.log(
            LogEvent.Level.ERROR,
            "The Build File YAML either does not exist or cannot be opened for reading: "
                + buildFile);
        return 1;
      }
      if (!Files.isRegularFile(buildFile)) {
        logger.log(LogEvent.Level.ERROR, "Build File YAML path is a not a file: " + buildFile);
        return 1;
      }

      CacheDirectories cacheDirectories = CacheDirectories.from(commonCliOptions, contextRoot);
      Containerizer containerizer = Containerizers.from(commonCliOptions, logger, cacheDirectories);

      JibContainerBuilder containerBuilder =
          BuildFiles.toJibContainerBuilder(contextRoot, buildFile, this, commonCliOptions, logger);

      // Enable registry mirrors
      Multimaps.asMap(globalConfig.getRegistryMirrors()).forEach(containerizer::addRegistryMirrors);

      JibContainer jibContainer = containerBuilder.containerize(containerizer);
      JibCli.writeImageJson(commonCliOptions.getImageJsonPath(), jibContainer);
    } catch (InterruptedException ex) {
      JibCli.logTerminatingException(logger, ex, commonCliOptions.isStacktrace());
      Thread.currentThread().interrupt();
      return 1;
    } catch (Exception ex) {
      JibCli.logTerminatingException(logger, ex, commonCliOptions.isStacktrace());
      return 1;
    } finally {
      JibCli.finishUpdateChecker(logger, updateCheckFuture);
      executor.shutDownAndAwaitTermination(Duration.ofSeconds(3));
    }
    return 0;
  }
Returns a user configured Path to a buildfile and if none is configured returns jib.yaml in
{@link #contextRoot}.

@return a path to a buildfile
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Build.java