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
eac_tools-0.60.3 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.60.2 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.60.1 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.60.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.59.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.58.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.57.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.56.1 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
avm-eac_generic_base0-0.12.0 lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.56.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.55.7 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.55.6 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
avm-eac_generic_base0-0.11.0 lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.55.5 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.55.4 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.55.3 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.55.2 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.55.1 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
eac_tools-0.55.0 sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb
avm-eac_generic_base0-0.10.0 lib/avm/eac_generic_base0/sources/docker/runner.rb