<commit_before>require "log4r"

module VagrantPlugins
  module DockerProvider
    module Action
      class Build
        def initialize(app, env)
          @app = app
          @logger = Log4r::Logger.new("vagrant::docker::build")
        end

        def call(env)
          machine   = env[:machine]
          build_dir = env[:build_dir]
          build_dir ||= machine.provider_config.build_dir

          # If we're not building a container, then just skip this step
          return @app.call(env) if !build_dir

          # Try to read the image ID from the cache file if we've
          # already built it.
          image_file = machine.data_dir.join("docker_build_image")
          image      = nil
          if image_file.file?
            image = image_file.read.chomp
          end

          # If we have no image or we're rebuilding, we rebuild
          if !image || env[:build_rebuild]
            # Build it
            machine.ui.output(I18n.t("docker_provider.building"))
            image = machine.provider.driver.build(build_dir)

            # Store the image ID
            image_file.open("w") do |f|
              f.binmode
              f.write("#{image}\n")
            end
          else
            machine.ui.output(I18n.t("docker_provider.already_built"))
          end

          # Set the image for creation
          env[:create_image] = image

          @app.call(env)
        end
      end
    end
  end
end
<commit_msg>providers/docker: when building from Dockerfile, show image ID<commit_after>require "log4r"

module VagrantPlugins
  module DockerProvider
    module Action
      class Build
        def initialize(app, env)
          @app = app
          @logger = Log4r::Logger.new("vagrant::docker::build")
        end

        def call(env)
          machine   = env[:machine]
          build_dir = env[:build_dir]
          build_dir ||= machine.provider_config.build_dir

          # If we're not building a container, then just skip this step
          return @app.call(env) if !build_dir

          # Try to read the image ID from the cache file if we've
          # already built it.
          image_file = machine.data_dir.join("docker_build_image")
          image      = nil
          if image_file.file?
            image = image_file.read.chomp
          end

          # If we have no image or we're rebuilding, we rebuild
          if !image || env[:build_rebuild]
            # Build it
            machine.ui.output(I18n.t("docker_provider.building"))
            image = machine.provider.driver.build(build_dir)
            machine.ui.detail("Image: #{image}")

            # Store the image ID
            image_file.open("w") do |f|
              f.binmode
              f.write("#{image}\n")
            end
          else
            machine.ui.output(I18n.t("docker_provider.already_built"))
          end

          # Set the image for creation
          env[:create_image] = image

          @app.call(env)
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08792302587923026, 'fraction_numerical': 0.003981420039814201, 'mean_word_length': 1.6895628902765387, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2965603', 'n_tokens_mistral': 873, 'n_tokens_neox': 831, 'n_words': 227}