Sha256: 927aabf187d0765316865206e487f9550ff20d9f42aaba725d3ab7e4dee2c2f4

Contents?: true

Size: 1.46 KB

Versions: 62

Compression:

Stored size: 1.46 KB

Contents

require "digest/md5"

require "log4r"

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

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

          # If we're not building a Dockerfile, ignore
          return @app.call(env) if !build_dir

          # If we're building a docker file, expand the directory
          build_dir = File.expand_path(build_dir, env[:machine].env.root_path)
          env[:build_dir] = build_dir

          # If we're not on a host VM, we're done
          return @app.call(env) if !machine.provider.host_vm?

          # We're on a host VM, so we need to move our build dir to
          # that machine. We do this by putting the synced folder on
          # ourself and letting HostMachineSyncFolders handle it.
          new_build_dir = "/var/lib/docker/docker_build_#{Digest::MD5.hexdigest(build_dir)}"
          options       = {
            docker__ignore: true,
            docker__exact: true,
          }.merge(machine.provider_config.host_vm_build_dir_options || {})
          machine.config.vm.synced_folder(build_dir, new_build_dir, options)

          # Set the build dir to be the correct one
          env[:build_dir] = new_build_dir

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

Version data entries

62 entries across 55 versions & 7 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/providers/docker/action/host_machine_build_dir.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.3.3.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.3.2.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.19.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.18.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.16.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.14.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.10.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.9.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.8.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.7.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.6.2 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.6.1 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.6.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.5.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.4.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.3.0 plugins/providers/docker/action/host_machine_build_dir.rb
vagrant-unbundled-2.2.2.0 plugins/providers/docker/action/host_machine_build_dir.rb