Class: Minke::Tasks::Shell

Inherits:
Task
  • Object
show all
Defined in:
lib/minke/tasks/shell.rb

Instance Method Summary collapse

Methods inherited from Task

#create_container_image, #create_working_directory, #initialize, #run_command_in_container, #run_with_block

Constructor Details

This class inherits a constructor from Minke::Tasks::Task

Instance Method Details



31
32
33
34
35
36
37
38
# File 'lib/minke/tasks/shell.rb', line 31

def create_list_of_links compose_services
  services = []
  compose_services.each do |k,v| 
    services.push(k) 
  end

  services
end

#run(args = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/minke/tasks/shell.rb', line 5

def run args = nil
  @logger.info "## Run shell" 
  @logger.info "## Run application with docker compose"

  compose_file = @config.compose_file_for(@task_name)
  compose_file = File.expand_path(compose_file)
  compose = @docker_compose_factory.create compose_file unless compose_file == nil

  run_with_block do |pre_tasks, post_tasks|
    begin
      services = create_list_of_links(compose.services)
      compose.up
      pre_tasks.call

      @logger.info "## Shell open to build container"
      run_command_in_container(['/bin/sh','-c','ls && /bin/sh'], true, services, @task_settings.ports)
    rescue SystemExit, Interrupt
      @logger.info "Stopping...."
      raise SystemExit
    ensure
      compose.down
      post_tasks.call
    end
  end
end