Class: RatDeployer::Cli

Inherits:
Thor
  • Object
show all
Includes:
Command
Defined in:
lib/rat_deployer/cli.rb

Instance Method Summary collapse

Methods included from Command

#ask_for_confirmation, #colorize_warning, #put_error, #put_heading, #put_warning, #run

Instance Method Details

#compose(cmd, *cmd_flags) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rat_deployer/cli.rb', line 27

def compose(cmd, *cmd_flags)
  env          = RatDeployer::Config.env
  project_name = RatDeployer::Config.all.fetch('project_name')

  flags = [
    "-f config/default.yml",
    "-f config/#{env}.yml",
    "-p #{project_name}_#{env}"
  ]

  if RatDeployer::Config.remote
    flags.unshift(RatDeployer::Config.remote_machine_flags)
  end

  run "docker-compose #{flags.join(' ')} #{cmd} #{cmd_flags.join(" ")}"
end

#deployObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rat_deployer/cli.rb', line 11

def deploy
  RatDeployer::Notifier.notify_deploy_start

  RatDeployer::Cli.new.compose('pull')
  RatDeployer::Cli.new.compose('up -d')

  RatDeployer::Notifier.notify_deploy_end
rescue Exception => e
  RatDeployer::Notifier.notify <<-STR
Failed deploy on #{ENV.fetch('RAT_ENV')}"
Reason:
  #{e.message}
  STR
end

#docker(cmd, *cmd_flags) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rat_deployer/cli.rb', line 45

def docker(cmd, *cmd_flags)
  env          = RatDeployer::Config.env
  project_name = RatDeployer::Config.all.fetch('project_name')

  flags = []

  if RatDeployer::Config.remote
    flags.unshift(RatDeployer::Config.remote_machine_flags)
  end

  run "docker #{flags.join(' ')} #{cmd} #{cmd_flags.join(" ")}"
end