Class: Deployku::DockerEngine
Instance Method Summary
collapse
Methods included from Engine
engines, find_engine, method_missing
Methods inherited from Plugin
<<, command_description, filter_plugins, find_plugin, help, inherited, instance, #packages, run
Instance Method Details
#ip(app_hash) ⇒ Object
39
40
41
42
43
|
# File 'lib/deployku/plugins/docker.rb', line 39
def ip(app_hash)
stat = JSON.parse(`docker inspect #{app_hash}`).first
return stat['NetworkSettings']['IPAddress'] if stat && stat['NetworkSettings']
nil
end
|
#logs(app_hash) ⇒ Object
25
26
27
|
# File 'lib/deployku/plugins/docker.rb', line 25
def logs(app_hash)
system "docker logs #{app_hash}"
end
|
#rebuild(app_name, dir) ⇒ Object
29
30
31
|
# File 'lib/deployku/plugins/docker.rb', line 29
def rebuild(app_name, dir)
system "docker build -t #{app_name}:latest #{dir}"
end
|
#run(app_name, app_dir, *cmd) ⇒ Object
16
17
18
19
|
# File 'lib/deployku/plugins/docker.rb', line 16
def run(app_name, app_dir, *cmd)
args = build_args(app_name, app_dir)
system "docker run -t -i --rm --entrypoint=/bin/bash #{args.join(' ')} #{app_name}:latest -c \"#{cmd.join(' ')}\""
end
|
#running?(app_hash) ⇒ Boolean
33
34
35
36
37
|
# File 'lib/deployku/plugins/docker.rb', line 33
def running?(app_hash)
stat = JSON.parse(`docker inspect #{app_hash}`).first
return stat['State']['Running'] if stat && stat['State']
nil
end
|
#start(app_name, app_dir = nil, name = nil) ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/deployku/plugins/docker.rb', line 7
def start(app_name, app_dir=nil, name=nil)
args = build_args(app_name, app_dir, name)
hash = `docker run -d -P #{args.join(' ')} #{app_name}:latest`.chomp
if $?.exitstatus != 0 && name
hash = `docker start '#{name}'`.chomp
end
hash
end
|
#stop(app_hash) ⇒ Object
21
22
23
|
# File 'lib/deployku/plugins/docker.rb', line 21
def stop(app_hash)
system "docker stop #{app_hash}"
end
|