Class: Shippy::Cli::App
Instance Method Summary collapse
- #compile ⇒ Object
- #deploy ⇒ Object
-
#initialize ⇒ App
constructor
A new instance of App.
- #logs ⇒ Object
- #refresh ⇒ Object
- #restart ⇒ Object
- #rollback ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Methods inherited from Base
Constructor Details
Instance Method Details
#compile ⇒ Object
58 59 60 61 62 |
# File 'lib/shippy/cli/app.rb', line 58 def compile say "Compiling #{app_name}...", :magenta app_config = Shippy::Repo.load_app(app_name) Shippy::Builder.new(app_config).compile end |
#deploy ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/shippy/cli/app.rb', line 11 def deploy Shippy::Deployer.new( app_name: app_name, host: SHIPPY.host, ui: self ).deploy end |
#logs ⇒ Object
48 49 50 |
# File 'lib/shippy/cli/app.rb', line 48 def logs @docker.logs(@remote_app.current_path, follow: [:follow]) end |
#refresh ⇒ Object
20 21 22 23 |
# File 'lib/shippy/cli/app.rb', line 20 def refresh say "Pulling images...", :magenta @docker.compose_pull(@remote_app.current_path, stream: true) end |
#restart ⇒ Object
34 35 36 37 38 |
# File 'lib/shippy/cli/app.rb', line 34 def restart say "Restarting...", :magenta services = [:service] ? [[:service]] : [] @docker.compose_restart(@remote_app.current_path, services) end |
#rollback ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/shippy/cli/app.rb', line 66 def rollback steps = [:step] backups = @remote_app.list_backups if backups.empty? error "No backups found." exit(1) end target_index = steps - 1 if target_index < 0 || target_index >= backups.length error "Cannot rollback #{steps} steps. Only #{backups.length} backups available." exit(1) end target_ts = backups[target_index] say "Rolling back #{steps} step(s) to: #{target_ts}", :yellow @docker.compose_down(@remote_app.current_path) say "Restoring files...", :blue @remote_app.restore_backup(target_ts) say "Starting restored application...", :green app_config = Shippy::Repo.load_app(app_name) @docker.compose_up(@remote_app.current_path, flags: app_config&.deploy_flags) rescue => e error "Rollback failed: #{e.}" exit(1) end |
#start ⇒ Object
26 27 28 29 30 |
# File 'lib/shippy/cli/app.rb', line 26 def start say "Starting...", :magenta app_config = Shippy::Repo.load_app(app_name) @docker.compose_up(@remote_app.current_path, flags: app_config&.deploy_flags) end |
#status ⇒ Object
53 54 55 |
# File 'lib/shippy/cli/app.rb', line 53 def status @docker.status(@remote_app.current_path) end |
#stop ⇒ Object
41 42 43 44 |
# File 'lib/shippy/cli/app.rb', line 41 def stop say "Stopping...", :magenta @docker.compose_down(@remote_app.current_path) end |