Class: ComposeManager
- Inherits:
-
Object
- Object
- ComposeManager
- Includes:
- Thor::Shell
- Defined in:
- lib/docker-sync/compose.rb
Instance Method Summary collapse
- #clean ⇒ Object
-
#initialize(global_options) ⇒ ComposeManager
constructor
A new instance of ComposeManager.
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(global_options) ⇒ ComposeManager
Returns a new instance of ComposeManager.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/docker-sync/compose.rb', line 8 def initialize() @global_options = ### production docker-compose.yml compose_files = [File.('docker-compose.yml')] if @global_options.key?('compose-file-path') compose_files = [] # replace apply_path_settings(compose_files, @global_options['compose-file-path'], 'compose-file-path') end ### development docker-compose-dev.yml if @global_options.key?('compose-dev-file-path') # explicit path given apply_path_settings(compose_files, @global_options['compose-dev-file-path'], 'compose-dev-file-path') say_status 'ok',"Found explicit docker-compose-dev.yml and using it from #{@global_options['compose-dev-file-path']}", :green else # try to find docker-compose-dev.yml e = compose_files.to_enum production_compose_file = File.(e.peek) working_dir = File.dirname(production_compose_file) compose_dev_path = "#{working_dir}/docker-compose-dev.yml" if File.exist?(compose_dev_path) say_status 'ok',"Found implicit docker-compose-dev.yml and using it from #{compose_dev_path}", :green compose_files.push compose_dev_path end end @compose_session = DockerSync::DockerComposeSession.new(dir: './', files: compose_files) end |
Instance Method Details
#clean ⇒ Object
50 51 52 |
# File 'lib/docker-sync/compose.rb', line 50 def clean @compose_session.down end |
#run ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/docker-sync/compose.rb', line 37 def run say_status 'ok','starting compose',:green = Hash.new if @global_options['compose-force-build'] [:build] = true end @compose_session.up(**) end |
#stop ⇒ Object
46 47 48 |
# File 'lib/docker-sync/compose.rb', line 46 def stop @compose_session.stop end |