Class: Cyclid::API::Plugins::Docker
- Includes:
- Helpers::Docker
- Defined in:
- app/cyclid/plugins/builder/docker.rb
Overview
Docker builder, uses the Docker API to create a build host container
Class Method Summary collapse
-
.metadata ⇒ Object
Plugin metadata.
Instance Method Summary collapse
-
#get(args = {}) ⇒ Object
Create and return a build host.
-
#initialize ⇒ Docker
constructor
A new instance of Docker.
-
#release(_transport, buildhost) ⇒ Object
Destroy the container when done.
Methods included from Helpers::Docker
#create_container, #get_container, #load_docker_config
Methods inherited from Builder
Methods inherited from Base
author, config?, config_schema, default_config, get_config, homepage, human_name, license, register_plugin, set_config, update_config, version
Constructor Details
Class Method Details
Instance Method Details
#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 |
#release(_transport, buildhost) ⇒ Object
Destroy the container when done
82 83 84 85 |
# File 'app/cyclid/plugins/builder/docker.rb', line 82 def release(_transport, buildhost) container = get_container(buildhost[:host]) container.delete(force: true) end |