lib/avm/docker/runner.rb in avm-tools-0.22.0 vs lib/avm/docker/runner.rb in avm-tools-0.23.0
- old
+ new
@@ -12,19 +12,20 @@
DOC = <<~DOCOPT
Manipulate Docker images.
Usage:
- __PROGRAM__ [options] [-B <build-arg>...]
+ __PROGRAM__ [options] [-B <build-arg>...] [-E <run-arg>...]
__PROGRAM__ -h | --help
Options:
-h --help Show this help.
-n --registry-name=<registry-name> Docker registry's name.
-p --push Push the image to Docker registry.
-r --run Run or start a container with builded image.
-B --build-arg=<build-arg> Argument for "docker build".
+ -E --entrypoint-arg=<run-arg> Argument for entrypoint on "docker run"
-c --clear Remove container if exist before run.
DOCOPT
def run
setup
@@ -42,25 +43,35 @@
def banner
infov 'Registry name', registry
infov 'Image name', instance.docker_image.tag
infov 'Build arguments', build_args
+ infov 'Entrypoint arguments', entrypoint_args
end
def build
instance.docker_image.build(build_args)
end
def build_args
options.fetch('--build-arg')
end
+ def entrypoint_args
+ options.fetch('--entrypoint-arg')
+ end
+
def push
instance.docker_image.push if options.fetch('--push')
end
def container_run
- instance.docker_container.run(clear: options.fetch('--clear')) if options.fetch('--run')
+ return unless options.fetch('--run')
+
+ instance.docker_container.run(
+ entrypoint_args: entrypoint_args,
+ clear: options.fetch('--clear')
+ )
end
def registry_uncached
options.fetch('--registry-name').if_present(::Avm::Docker::Registry.default) do |v|
::Avm::Docker::Registry.new(v)