Class: Indocker::Launchers::ContainerRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/indocker/launchers/container_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ ContainerRunner

Returns a new instance of ContainerRunner.



2
3
4
# File 'lib/indocker/launchers/container_runner.rb', line 2

def initialize(logger)
  @logger = logger
end

Instance Method Details

#run(configuration:, container_name:, force_restart:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/indocker/launchers/container_runner.rb', line 6

def run(configuration:, container_name:, force_restart:)
  path = Indocker.container_files.fetch(container_name) do
    @logger.error("container #{container_name} was not found in configuration #{configuration.name}")
    exit 1
  end

  require path

  deploy_context = Indocker::DeployContext.new(
    logger: @logger,
    configuration: configuration
  )

  container = configuration.containers.detect { |c| c.name == container_name }
  deploy_context.deploy(container, force_restart)
end