Class: Kuby::Docker::Spec
- Inherits:
-
Object
- Object
- Kuby::Docker::Spec
- Defined in:
- lib/kuby/docker/spec.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
Instance Method Summary collapse
- #assets_phase ⇒ Object
- #base_image(image_url) ⇒ Object
- #bundler_phase ⇒ Object
- #bundler_version(version) ⇒ Object
- #cli ⇒ Object
- #copy_phase ⇒ Object
- #credentials(&block) ⇒ Object
- #delete(*args) ⇒ Object
- #distro(distro_name) ⇒ Object
- #distro_spec ⇒ Object
- #files(path) ⇒ Object
- #gemfile(path) ⇒ Object
- #image_url(url) ⇒ Object
-
#initialize(definition) ⇒ Spec
constructor
A new instance of Spec.
- #insert(*args) ⇒ Object
- #metadata ⇒ Object
- #package(pkg) ⇒ Object
- #package_phase ⇒ Object
- #port(port) ⇒ Object
- #rails_env(env) ⇒ Object
- #remote_client ⇒ Object
- #setup_phase ⇒ Object
- #tags ⇒ Object
- #to_dockerfile ⇒ Object
- #use(*args) ⇒ Object
- #webserver_phase ⇒ Object
- #working_dir(dir) ⇒ Object
- #yarn_phase ⇒ Object
Constructor Details
#initialize(definition) ⇒ Spec
Returns a new instance of Spec.
8 9 10 |
# File 'lib/kuby/docker/spec.rb', line 8 def initialize(definition) @definition = definition end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
6 7 8 |
# File 'lib/kuby/docker/spec.rb', line 6 def definition @definition end |
Instance Method Details
#assets_phase ⇒ Object
97 98 99 |
# File 'lib/kuby/docker/spec.rb', line 97 def assets_phase @assets_phase ||= AssetsPhase.new(definition) end |
#base_image(image_url) ⇒ Object
12 13 14 |
# File 'lib/kuby/docker/spec.rb', line 12 def base_image(image_url) setup_phase.base_image = image_url end |
#bundler_phase ⇒ Object
85 86 87 |
# File 'lib/kuby/docker/spec.rb', line 85 def bundler_phase @bundler_phase ||= BundlerPhase.new(definition) end |
#bundler_version(version) ⇒ Object
24 25 26 |
# File 'lib/kuby/docker/spec.rb', line 24 def bundler_version(version) bundler_phase.bundler_version = version end |
#cli ⇒ Object
113 114 115 |
# File 'lib/kuby/docker/spec.rb', line 113 def cli @cli ||= Docker::CLI.new end |
#copy_phase ⇒ Object
93 94 95 |
# File 'lib/kuby/docker/spec.rb', line 93 def copy_phase @copy_phase ||= CopyPhase.new(definition) end |
#credentials(&block) ⇒ Object
65 66 67 68 69 |
# File 'lib/kuby/docker/spec.rb', line 65 def credentials(&block) @credentials ||= Credentials.new @credentials.instance_eval(&block) if block @credentials end |
#delete(*args) ⇒ Object
61 62 63 |
# File 'lib/kuby/docker/spec.rb', line 61 def delete(*args) layer_stack.delete(*args) end |
#distro(distro_name) ⇒ Object
36 37 38 39 |
# File 'lib/kuby/docker/spec.rb', line 36 def distro(distro_name) .distro = distro_name @distro_spec = nil end |
#distro_spec ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/kuby/docker/spec.rb', line 124 def distro_spec @distro_spec ||= if distro_klass = Kuby.distros[.distro] distro_klass.new(self) else raise MissingDistroError, "distro '#{.distro}' hasn't been registered" end end |
#files(path) ⇒ Object
41 42 43 |
# File 'lib/kuby/docker/spec.rb', line 41 def files(path) copy_phase << path end |
#gemfile(path) ⇒ Object
28 29 30 |
# File 'lib/kuby/docker/spec.rb', line 28 def gemfile(path) bundler_phase.gemfile = path end |
#image_url(url) ⇒ Object
49 50 51 |
# File 'lib/kuby/docker/spec.rb', line 49 def image_url(url) .image_url = url end |
#insert(*args) ⇒ Object
57 58 59 |
# File 'lib/kuby/docker/spec.rb', line 57 def insert(*args) layer_stack.insert(*args) end |
#metadata ⇒ Object
105 106 107 |
# File 'lib/kuby/docker/spec.rb', line 105 def @metadata ||= Metadata.new(definition) end |
#package(pkg) ⇒ Object
32 33 34 |
# File 'lib/kuby/docker/spec.rb', line 32 def package(pkg) package_phase << pkg end |
#package_phase ⇒ Object
81 82 83 |
# File 'lib/kuby/docker/spec.rb', line 81 def package_phase @package_phase ||= PackagePhase.new(definition) end |
#port(port) ⇒ Object
45 46 47 |
# File 'lib/kuby/docker/spec.rb', line 45 def port(port) webserver_phase.port = port end |
#rails_env(env) ⇒ Object
20 21 22 |
# File 'lib/kuby/docker/spec.rb', line 20 def rails_env(env) setup_phase.rails_env = env end |
#remote_client ⇒ Object
117 118 119 120 121 122 |
# File 'lib/kuby/docker/spec.rb', line 117 def remote_client @remote_client ||= ::Docker::Remote::Client.new( .image_host, .image_repo, credentials.username, credentials.password, ) end |
#setup_phase ⇒ Object
77 78 79 |
# File 'lib/kuby/docker/spec.rb', line 77 def setup_phase @setup_phase ||= SetupPhase.new(definition) end |
#tags ⇒ Object
109 110 111 |
# File 'lib/kuby/docker/spec.rb', line 109 def @tags ||= Tags.new(cli, remote_client, ) end |
#to_dockerfile ⇒ Object
71 72 73 74 75 |
# File 'lib/kuby/docker/spec.rb', line 71 def to_dockerfile Dockerfile.new.tap do |df| layer_stack.each { |layer| layer.apply_to(df) } end end |
#use(*args) ⇒ Object
53 54 55 |
# File 'lib/kuby/docker/spec.rb', line 53 def use(*args) layer_stack.use(*args) end |
#webserver_phase ⇒ Object
101 102 103 |
# File 'lib/kuby/docker/spec.rb', line 101 def webserver_phase @webserver_phase ||= WebserverPhase.new(definition) end |
#working_dir(dir) ⇒ Object
16 17 18 |
# File 'lib/kuby/docker/spec.rb', line 16 def working_dir(dir) setup_phase.working_dir = dir end |