12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/docker/stack/rake_task.rb', line 12
def load_tasks(force_env: nil, cleanup: false)
desc 'Clean up the development stack'
task :clean do
Controller.new(env: force_env, cleanup: true).down
end
desc 'Run the stack in the background'
task :daemon do
Controller.new(env: force_env, daemon: true).start
end
desc 'Bring down the stack'
task :down do
Controller.new(env: force_env, cleanup: cleanup).down
end
desc 'Show the server logs'
task :logs do
services = ENV['SERVICES'].to_s.split(/[\s,;]+/)
Controller.new(env: force_env).logs(*services)
end
desc 'Remove containers, volumes, and images'
task :reset do
Controller.new(env: force_env).reset! do |result|
results = JSON.parse(result)
results.each do |result_hash|
result_hash.each_pair do |action, target|
puts "#{action} #{target}"
end
end
end
end
desc 'Show server status'
task :status do
status = Controller.new(env: force_env).status
puts '%-20s %-16s %-20s' % ['SERVICE', 'STATUS', 'UPTIME']
puts '-' * 56
status.each do |s|
puts '%-20s %-16s %-20s' % s.values_at(:service, :status, :running)
end
end
desc 'Run the stack in the foreground'
task :up do
Controller.new(env: force_env, cleanup: cleanup).start
end
end
|