Class: Docker::Rails::CLI::Main
- Inherits:
-
Thor
- Object
- Thor
- Docker::Rails::CLI::Main
- Defined in:
- lib/docker/rails/cli/main.rb
Instance Method Summary collapse
- #bash_connect(target, service_name) ⇒ Object
- #before(target) ⇒ Object
- #build(target) ⇒ Object
- #ci(target) ⇒ Object
- #cleanup(target) ⇒ Object
- #compose(target) ⇒ Object
- #exec(target, service_name, command) ⇒ Object
- #extract(target) ⇒ Object
- #ps(target) ⇒ Object
- #ps_all(build = nil, target = nil) ⇒ Object
- #rm_compose(build = nil, target = nil) ⇒ Object
- #rm_dangling(build = nil, target = nil) ⇒ Object
- #rm_volumes(target) ⇒ Object
- #stop(target) ⇒ Object
- #up(target) ⇒ Object
Instance Method Details
#bash_connect(target, service_name) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/docker/rails/cli/main.rb', line 142 def bash_connect(target, service_name) # init singleton with full options app = App.configured(target, ) invoke :compose, [target], [] container = app.bash_connect(service_name) # Automatically cleanup any remnants of a simple bash session. return if container.nil? container.stop container.remove(v: true, force: true) end |
#before(target) ⇒ Object
95 96 97 98 99 |
# File 'lib/docker/rails/cli/main.rb', line 95 def before(target) app = App.configured(target, ) invoke :compose, [target], [] app.before_command end |
#build(target) ⇒ Object
82 83 84 85 |
# File 'lib/docker/rails/cli/main.rb', line 82 def build(target) invoke :compose App.configured(target, ).compose_build end |
#ci(target) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/docker/rails/cli/main.rb', line 23 def ci(target) # init singleton with full options app = App.configured(target, ) invoke :before, [target], [] invoke :compose, [target], [] invoke CLI::GemsetVolume, :create, [target], begin invoke :build # on CI - always build to ensure dockerfile hasn't been altered - small price to pay for consistent CI. invoke :up ensure invoke :cleanup end exit app.exit_code end |
#cleanup(target) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/docker/rails/cli/main.rb', line 51 def cleanup(target) invoke :stop invoke :extract if [:extract] invoke :rm_volumes invoke :rm_compose invoke :rm_dangling invoke :ps_all end |
#compose(target) ⇒ Object
89 90 91 |
# File 'lib/docker/rails/cli/main.rb', line 89 def compose(target) App.configured(target, ).compose end |
#exec(target, service_name, command) ⇒ Object
158 159 160 161 162 163 164 165 166 |
# File 'lib/docker/rails/cli/main.rb', line 158 def exec(target, service_name, command) # init singleton with full options app = App.configured(target, ) invoke :compose, [target], [] invoke CLI::GemsetVolume, :create, [target], [] app.run_service_command(service_name, command) end |
#extract(target) ⇒ Object
42 43 44 45 46 |
# File 'lib/docker/rails/cli/main.rb', line 42 def extract(target) app = App.configured(target, ) invoke :compose, [target], [] app.extract_all end |
#ps(target) ⇒ Object
129 130 131 132 |
# File 'lib/docker/rails/cli/main.rb', line 129 def ps(target) invoke :compose App.configured(target, ).ps end |
#ps_all(build = nil, target = nil) ⇒ Object
136 137 138 |
# File 'lib/docker/rails/cli/main.rb', line 136 def ps_all(build = nil, target = nil) App.instance.ps_all end |
#rm_compose(build = nil, target = nil) ⇒ Object
117 118 119 |
# File 'lib/docker/rails/cli/main.rb', line 117 def rm_compose(build = nil, target = nil) App.instance.rm_compose end |
#rm_dangling(build = nil, target = nil) ⇒ Object
123 124 125 |
# File 'lib/docker/rails/cli/main.rb', line 123 def rm_dangling(build = nil, target = nil) App.instance.rm_dangling end |
#rm_volumes(target) ⇒ Object
110 111 112 113 |
# File 'lib/docker/rails/cli/main.rb', line 110 def rm_volumes(target) invoke :stop App.configured(target, ).rm_volumes end |
#stop(target) ⇒ Object
103 104 105 106 |
# File 'lib/docker/rails/cli/main.rb', line 103 def stop(target) invoke :compose App.configured(target, ).stop_all end |
#up(target) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/docker/rails/cli/main.rb', line 63 def up(target) # init singleton with full options app = App.configured(target, ) = .except(:detached) invoke :before, [target], invoke CLI::GemsetVolume, :create, [target], if [:detached] = '-d' else = '--abort-on-container-exit' end app.up() end |