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
153 154 155 156 157 |
# File 'lib/dockit/cli.rb', line 153 def build(service=nil) exec(service) do |s| s.build() end end |
#cleanup ⇒ Object
119 120 121 122 123 124 125 126 |
# File 'lib/dockit/cli.rb', line 119 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
129 130 131 132 133 |
# File 'lib/dockit/cli.rb', line 129 def config(service=nil) exec(service) do |s| say s.config.instance_variable_get('@config').to_yaml end end |
#git_build(service = nil) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/dockit/cli.rb', line 162 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} #{.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
146 147 148 149 150 |
# File 'lib/dockit/cli.rb', line 146 def pull(registry, service=nil) exec(service) do |s| s.pull(registry, [:tag], [:force]) end end |
#push(registry, service = nil) ⇒ Object
137 138 139 140 141 |
# File 'lib/dockit/cli.rb', line 137 def push(registry, service=nil) exec(service) do |s| s.push(registry, [:tag], [:force]) end end |
#sh(service = nil, *cmd) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/dockit/cli.rb', line 92 def sh(service=nil, *cmd) exec(service) do |s| cmd = %w[bash -l] if cmd.length < 1 # in case image has an entrypoint, use the cmd as the entrypoint (entrypoint, *cmd) = cmd s.start( transient: true, verbose: .verbose, create: { Entrypoint: [entrypoint], Cmd: cmd, name: 'sh', 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 |
# File 'lib/dockit/cli.rb', line 84 def start(service=nil, *cmd) opts = cmd.length > 0 ? .merge(create: {Cmd: cmd}) : 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 |