Sha256: eeb597188e3ff415216a6f323f89be7efa04db2e3925cfe8b225ec4871f40ebf

Contents?: true

Size: 1.52 KB

Versions: 126

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require 'eac_cli/core_ext'

module Avm
  module EacGenericBase0
    module Sources
      module Docker
        class Runner
          CONTAINER_SOURCE_PATH = '/app'

          enable_abstract_methods
          abstract_methods :docker_image

          runner_with :help do
            desc 'Run a Docker container with source mapped.'
            arg_opt '-c', '--command-arg', 'Arguments for [COMMAND] [ARG...].', optional: true,
                                                                                repeat: true
          end

          def run
            start_banner
            docker_container.run_command.system!
          end

          def start_banner
            infov 'Image', docker_image
            infov 'Command', ::Shellwords.join(command_args)
          end

          def bash_command_args
            %w[/bin/bash]
          end

          def command_args
            if parsed.command_arg.any?
              parsed.command_arg
            else
              default_command_args
            end
          end

          def default_command_args
            bash_command_args
          end

          def docker_container
            docker_image.container
              .volume(runner_context.call(:subject).path, CONTAINER_SOURCE_PATH)
              .interactive(true).tty(true).command_args(command_args)
          end

          # @return [EacDocker::Images::Base]
          def docker_image
            raise_abstract_method __method__
          end
        end
      end
    end
  end
end

Version data entries

126 entries across 126 versions & 2 rubygems

Version Path
avm-eac_generic_base0-0.13.0 lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.87.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.84.2 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
avm-eac_generic_base0-0.12.2 lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.84.1 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.84.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.83.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.82.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.81.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.80.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.79.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.78.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.77.1 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
avm-eac_generic_base0-0.12.1 lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.77.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.76.1 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.76.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.75.2 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.75.1 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.75.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb