Class: RatDeployer::Cli
- Inherits:
-
Thor
- Object
- Thor
- RatDeployer::Cli
- Includes:
- Command
- Defined in:
- lib/rat_deployer/cli.rb
Instance Method Summary collapse
- #compose(cmd, *cmd_flags, silent: false) ⇒ Object
- #deploy(*services) ⇒ Object
- #docker(cmd, *cmd_flags) ⇒ Object
Methods included from Command
#ask_for_confirmation, #colorize_warning, #do_run, #put_error, #put_heading, #put_warning, #run
Instance Method Details
#compose(cmd, *cmd_flags, silent: false) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rat_deployer/cli.rb', line 34 def compose(cmd, *cmd_flags, silent: false) 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 cmd = run "docker-compose #{flags.join(' ')} #{cmd} #{cmd_flags.join(" ")}", silent: silent cmd.fetch(:output) end |
#deploy(*services) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rat_deployer/cli.rb', line 11 def deploy(*services) RatDeployer::Notifier.notify_deploy_start if services.any? services_str = services.join(' ') RatDeployer::Cli.new.compose("pull #{services_str}") RatDeployer::Cli.new.compose("up -d --no-deps --force-recreate #{services_str}") else RatDeployer::Cli.new.compose('pull') RatDeployer::Cli.new.compose('up -d') end RatDeployer::Notifier.notify_deploy_end rescue Exception => e RatDeployer::Notifier.notify <<-STR Failed deploy on #{ENV.fetch('RAT_ENV')}" Reason: #{e.} STR raise e end |
#docker(cmd, *cmd_flags) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rat_deployer/cli.rb', line 53 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 cmd = run "docker #{flags.join(' ')} #{cmd} #{cmd_flags.join(" ")}" cmd.fetch(:output) end |