Method: Cyclid::API::Plugins::Docker#get

Defined in:
app/cyclid/plugins/builder/docker.rb

#get(args = {}) ⇒ Object

Create and return a build host



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'app/cyclid/plugins/builder/docker.rb', line 43

def get(args = {})
  args.symbolize_keys!

  Cyclid.logger.debug "docker: args=#{args}"

  # If there is one, split the 'os' into a 'distro' and 'release'
  if args.key? :os
    match = args[:os].match(/\A(\w*)_(.*)\Z/)
    distro = match[1] if match
    release = match[2] if match
  else
    # No OS was specified; use the default
    # XXX Defaults should be configurable
    distro = 'ubuntu'
    release = 'trusty'
  end

  # Find the image for the given distribution & release
  image_alias = "#{distro}:#{release}"
  Cyclid.logger.debug "image_alias=#{image_alias}"

  # Create a new instance
  name = create_name
  container = create_container(name, image_alias)

  Cyclid.logger.debug "container=#{container}"

  # Create a buildhost from the container details
  DockerHost.new(
    host: container.id,
    name: name,
    username: 'root',
    workspace: '/root',
    distro: distro,
    release: release
  )
end