Class: Default
- Inherits:
-
Thor
- Object
- Thor
- Default
- Defined in:
- lib/dockit/cli.rb
Constant Summary collapse
- DOCKIT_FILE =
'./Dockit.yaml'.freeze
- @@root_echoed =
false
Instance Method Summary collapse
- #build(service = nil) ⇒ Object
- #cleanup ⇒ Object
- #config(service = nil) ⇒ Object
- #git_build(service = nil) ⇒ Object
- #help(*args) ⇒ Object
-
#initialize(*args) ⇒ Default
constructor
A new instance of Default.
- #list ⇒ Object
- #pull(registry, service = nil) ⇒ Object
- #push(registry, service = nil) ⇒ Object
- #sh(service = nil, *cmd) ⇒ Object
- #start(service = nil, *cmd) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(*args) ⇒ Default
Returns a new instance of Default.
46 47 48 49 50 51 52 53 |
# File 'lib/dockit/cli.rb', line 46 def initialize(*args) super ENV['DOCKER_HOST'] = .host unless @@root_echoed puts "Project root: #{dockit.root}" @@root_echoed=true end end |
Instance Method Details
#build(service = nil) ⇒ Object
156 157 158 159 160 |
# File 'lib/dockit/cli.rb', line 156 def build(service=nil) exec(service) do |s| s.build() end end |
#cleanup ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/dockit/cli.rb', line 122 def cleanup if [:containers] Dockit::Container.clean(force: [:force]) if ask_force('containers') end if [:images] Dockit::Image.clean(force: [:force]) if ask_force('images') end end |
#config(service = nil) ⇒ Object
132 133 134 135 136 |
# File 'lib/dockit/cli.rb', line 132 def config(service=nil) exec(service) do |s| say s.config.instance_variable_get('@config').to_yaml end end |
#git_build(service = nil) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/dockit/cli.rb', line 165 def git_build(service=nil) exec(service) do |s| unless repos = s.config.get(:repos) say "'repos' not defined in config file. Exiting",:red exit 1 end say "Exporting in #{Dir.pwd}", :green say "<- #{repos} #{options.branch}", :green if .gem # grab the Gemfiles separately for the bundler Dockerfile hack say "-> Gemfiles", :green export(repos, 'gemfile.tar.gz', 'Gemfile*') end say "-> repos.tar.gz", :green export(repos, 'repos.tar.gz') s.build end end |
#help(*args) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/dockit/cli.rb', line 61 def help(*args) super if args.count < 1 say "Run 'dockit list' to see the complete list of SERVICEs." say "Run 'dockit help COMMAND' to see command specific options." end end |
#list ⇒ Object
76 77 78 79 |
# File 'lib/dockit/cli.rb', line 76 def list _list :modules _list :services end |
#pull(registry, service = nil) ⇒ Object
149 150 151 152 153 |
# File 'lib/dockit/cli.rb', line 149 def pull(registry, service=nil) exec(service) do |s| s.pull(registry, [:tag], [:force]) end end |
#push(registry, service = nil) ⇒ Object
140 141 142 143 144 |
# File 'lib/dockit/cli.rb', line 140 def push(registry, service=nil) exec(service) do |s| s.push(registry, [:tag], [:force]) end end |
#sh(service = nil, *cmd) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/dockit/cli.rb', line 93 def sh(service=nil, *cmd) exec(service) do |s| cmd = %w[bash -l] if cmd.length < 1 name = "sh-#{s.name}" # in case image has an entrypoint, use the cmd as the entrypoint (entrypoint, *cmd) = cmd say "Starting #{name} with #{entrypoint} #{cmd}", :green s.start( transient: true, verbose: .verbose, create: { Entrypoint: [entrypoint], Cmd: cmd, name: "sh-#{name}", Tty: true, AttachStdin: true, AttachStdout: true, AttachStderr: true, OpenStdin: true, StdinOnce: true, }) end end |
#start(service = nil, *cmd) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/dockit/cli.rb', line 84 def start(service=nil, *cmd) opts = .merge(create: {tty: [:transient]}) opts[:create][:Cmd] = cmd if cmd.length > 0 exec(service) do |s| s.start(opts) end end |
#version ⇒ Object
70 71 72 |
# File 'lib/dockit/cli.rb', line 70 def version say "Dockit version #{Dockit::VERSION}" end |