dockerun 0.3.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -11
- data/Rakefile +0 -2
- data/Rakefile.bak +8 -0
- data/dockerspec.sample +104 -0
- data/{dockerun.gemspec → dockerun.gemspec.bak} +20 -22
- data/exe/dockerun +8 -115
- data/lib/dockerun/cli/command.rb +133 -0
- data/lib/dockerun/cli/command_factory.rb +313 -0
- data/lib/dockerun/cli/command_result.rb +67 -0
- data/lib/dockerun/cli/delete_container.rb +55 -0
- data/lib/dockerun/cli/delete_image.rb +99 -0
- data/lib/dockerun/cli/run.rb +39 -0
- data/lib/dockerun/cli/user_info.rb +39 -0
- data/lib/dockerun/cli_engine.rb +104 -0
- data/lib/dockerun/config.rb +40 -70
- data/lib/dockerun/context/rubygems.rb +142 -0
- data/lib/dockerun/dfile.rb +204 -0
- data/lib/dockerun/docker_cli.rb +124 -0
- data/lib/dockerun/dsl.rb +291 -0
- data/lib/dockerun/version.rb +1 -1
- data/lib/dockerun.rb +31 -24
- data/sig/dockerun.rbs +4 -0
- metadata +62 -73
- data/.release_history.yml +0 -56
- data/Dockerfile.dockerun +0 -38
- data/Gemfile +0 -15
- data/Gemfile.lock +0 -94
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/lib/dockerun/bundler_helper.rb +0 -25
- data/lib/dockerun/cli_prompt.rb +0 -18
- data/lib/dockerun/command/dockerun.rb +0 -30
- data/lib/dockerun/command/init.rb +0 -79
- data/lib/dockerun/command/remove_container.rb +0 -99
- data/lib/dockerun/command/reset_image.rb +0 -107
- data/lib/dockerun/command/run.rb +0 -221
- data/lib/dockerun/command/run_new_container.rb +0 -94
- data/lib/dockerun/command/run_new_image.rb +0 -89
- data/lib/dockerun/command/stop_container.rb +0 -90
- data/lib/dockerun/docker_command_factory_helper.rb +0 -19
- data/lib/dockerun/docker_container_helper.rb +0 -204
- data/lib/dockerun/docker_image_helper.rb +0 -381
- data/lib/dockerun/template/general_template_writer.rb +0 -14
- data/lib/dockerun/template/jruby_template_writer.rb +0 -24
- data/lib/dockerun/template/template_engine.rb +0 -27
- data/lib/dockerun/template/template_writer.rb +0 -102
- data/lib/dockerun/user_info.rb +0 -37
- data/template/Dockerfile_general.erb +0 -41
- data/template/setup_ruby_devenv.rb.erb +0 -22
data/Dockerfile.dockerun
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
|
2
|
-
FROM ruby:2.7.6
|
3
|
-
LABEL version="0.1"
|
4
|
-
LABEL maintainer="chris"
|
5
|
-
LABEL description="Dockerfile generated by dockerun"
|
6
|
-
LABEL dockerun-info="https://github.com/chrisliaw/dockerun"
|
7
|
-
|
8
|
-
|
9
|
-
RUN apt-get update && apt-get install -y sudo git curl build-essential vim
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
RUN groupadd -f -g 1000 chris && \
|
15
|
-
useradd -u 1000 -g 1000 -m chris && \
|
16
|
-
usermod -aG sudo chris && \
|
17
|
-
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
18
|
-
|
19
|
-
USER chris
|
20
|
-
|
21
|
-
# from this point onwards, sudo is required for privileaged operation
|
22
|
-
#RUN sudo apt-get install -y curl build-essential
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
COPY on_docker_config /tmp/docker_init.rb
|
28
|
-
RUN ruby /tmp/docker_init.rb
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
WORKDIR /opt
|
33
|
-
|
34
|
-
|
35
|
-
# other Dockerfile entries starts here
|
36
|
-
|
37
|
-
CMD [ "/bin/bash", "--login" ]
|
38
|
-
|
data/Gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in dockerun.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem "rake", "~> 13.0"
|
9
|
-
|
10
|
-
gem "rspec", "~> 3.0"
|
11
|
-
|
12
|
-
#gem 'git_cli', git: "git_cli", branch: "master"
|
13
|
-
#gem 'docker-cli', git: "docker-cli", branch: "master"
|
14
|
-
|
15
|
-
|
data/Gemfile.lock
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
dockerun (0.3.5)
|
5
|
-
colorize
|
6
|
-
docker-cli (>= 0.3.1)
|
7
|
-
teLogger
|
8
|
-
toolrack
|
9
|
-
tty-command
|
10
|
-
tty-option
|
11
|
-
|
12
|
-
GEM
|
13
|
-
remote: https://rubygems.org/
|
14
|
-
specs:
|
15
|
-
colorize (0.8.1)
|
16
|
-
devops_assist (0.3.11)
|
17
|
-
git_cli
|
18
|
-
git_cli_prompt (~> 0.3.3)
|
19
|
-
gvcs
|
20
|
-
teLogger
|
21
|
-
toolrack
|
22
|
-
tty-prompt
|
23
|
-
diff-lcs (1.5.0)
|
24
|
-
docker-cli (0.3.1)
|
25
|
-
ptools
|
26
|
-
teLogger
|
27
|
-
toolrack
|
28
|
-
tty-command
|
29
|
-
tty-prompt
|
30
|
-
git_cli (0.11.4)
|
31
|
-
gvcs
|
32
|
-
ptools (~> 1.4.0)
|
33
|
-
teLogger
|
34
|
-
toolrack
|
35
|
-
git_cli_prompt (0.3.4)
|
36
|
-
teLogger
|
37
|
-
toolrack
|
38
|
-
tty-prompt
|
39
|
-
gvcs (0.1.2)
|
40
|
-
pastel (0.8.0)
|
41
|
-
tty-color (~> 0.5)
|
42
|
-
ptools (1.4.3)
|
43
|
-
rake (13.0.6)
|
44
|
-
release-gem (0.1.18)
|
45
|
-
colorize
|
46
|
-
git_cli
|
47
|
-
gvcs
|
48
|
-
teLogger
|
49
|
-
toolrack
|
50
|
-
tty-command
|
51
|
-
tty-prompt
|
52
|
-
rspec (3.12.0)
|
53
|
-
rspec-core (~> 3.12.0)
|
54
|
-
rspec-expectations (~> 3.12.0)
|
55
|
-
rspec-mocks (~> 3.12.0)
|
56
|
-
rspec-core (3.12.1)
|
57
|
-
rspec-support (~> 3.12.0)
|
58
|
-
rspec-expectations (3.12.2)
|
59
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
60
|
-
rspec-support (~> 3.12.0)
|
61
|
-
rspec-mocks (3.12.5)
|
62
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
63
|
-
rspec-support (~> 3.12.0)
|
64
|
-
rspec-support (3.12.0)
|
65
|
-
teLogger (0.2.2)
|
66
|
-
toolrack (0.22.1)
|
67
|
-
tty-color (0.6.0)
|
68
|
-
tty-command (0.10.1)
|
69
|
-
pastel (~> 0.8)
|
70
|
-
tty-cursor (0.7.1)
|
71
|
-
tty-option (0.2.0)
|
72
|
-
tty-prompt (0.23.1)
|
73
|
-
pastel (~> 0.8)
|
74
|
-
tty-reader (~> 0.8)
|
75
|
-
tty-reader (0.9.0)
|
76
|
-
tty-cursor (~> 0.7)
|
77
|
-
tty-screen (~> 0.8)
|
78
|
-
wisper (~> 2.0)
|
79
|
-
tty-screen (0.8.1)
|
80
|
-
wisper (2.0.1)
|
81
|
-
|
82
|
-
PLATFORMS
|
83
|
-
x86_64-darwin-21
|
84
|
-
x86_64-linux
|
85
|
-
|
86
|
-
DEPENDENCIES
|
87
|
-
devops_assist
|
88
|
-
dockerun!
|
89
|
-
rake (~> 13.0)
|
90
|
-
release-gem
|
91
|
-
rspec (~> 3.0)
|
92
|
-
|
93
|
-
BUNDLED WITH
|
94
|
-
2.4.10
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "dockerun"
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'bundler'
|
3
|
-
|
4
|
-
module Dockerun
|
5
|
-
module CommandHelper
|
6
|
-
module BundlerHelper
|
7
|
-
|
8
|
-
def find_local_dev_gems
|
9
|
-
|
10
|
-
res = {}
|
11
|
-
Bundler.load.dependencies.each do |d|
|
12
|
-
if not d.source.nil?
|
13
|
-
src = d.source
|
14
|
-
if src.path.to_s != "."
|
15
|
-
res[d.name] = src.path.to_s
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
res
|
20
|
-
|
21
|
-
end # find_local_dev_gem
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/dockerun/cli_prompt.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'tty/option'
|
3
|
-
|
4
|
-
module Dockerun
|
5
|
-
module Command
|
6
|
-
|
7
|
-
class Dockerun
|
8
|
-
include TTY::Option
|
9
|
-
|
10
|
-
usage do
|
11
|
-
program "dockerun"
|
12
|
-
no_command
|
13
|
-
end
|
14
|
-
|
15
|
-
argument :command do
|
16
|
-
required
|
17
|
-
desc "Command for the dockerun operations. Supported: init, run (r), stop (s), run-new-container (rnc), run-new-image (rni), remove-image (rmi), remove-container (rmc)"
|
18
|
-
end
|
19
|
-
|
20
|
-
def run
|
21
|
-
if params[:help]
|
22
|
-
print help
|
23
|
-
exit
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'tty/option'
|
3
|
-
|
4
|
-
require_relative '../template/template_writer'
|
5
|
-
|
6
|
-
module Dockerun
|
7
|
-
module Command
|
8
|
-
|
9
|
-
class Init
|
10
|
-
include TTY::Option
|
11
|
-
include TR::CondUtils
|
12
|
-
|
13
|
-
class MultipleTemplateDetected < StandardError; end
|
14
|
-
|
15
|
-
usage do
|
16
|
-
program "dockerun"
|
17
|
-
command "init"
|
18
|
-
desc "Initialize a Dockerfile template in given location"
|
19
|
-
end
|
20
|
-
|
21
|
-
argument :location do
|
22
|
-
required
|
23
|
-
desc "Location where the Dockerfile template shall be written"
|
24
|
-
end
|
25
|
-
|
26
|
-
def run(&block)
|
27
|
-
if params[:help]
|
28
|
-
print help
|
29
|
-
exit
|
30
|
-
|
31
|
-
else
|
32
|
-
init_dockerfile(&block)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def init_dockerfile(&block)
|
37
|
-
|
38
|
-
loc = "."
|
39
|
-
loc = params[:location] if not_empty?(params[:location])
|
40
|
-
|
41
|
-
loc = File.expand_path(loc)
|
42
|
-
out = nil
|
43
|
-
if File.directory?(loc)
|
44
|
-
out = File.join(loc, "Dockerfile.dockerun")
|
45
|
-
else
|
46
|
-
out = File.join(File.dirname(loc), "Dockerfile.dockerun")
|
47
|
-
end
|
48
|
-
|
49
|
-
avail = ::Dockerun::Template::TemplateEngine.available_templates
|
50
|
-
selTemp = nil
|
51
|
-
if avail.length > 1
|
52
|
-
if block
|
53
|
-
selTemp = block.call(:multiple_templates_detected, avail)
|
54
|
-
else
|
55
|
-
raise MultipleTemplateDetected, "Multiple template is available but no selected is given."
|
56
|
-
end
|
57
|
-
else
|
58
|
-
selTemp = avail.first
|
59
|
-
end
|
60
|
-
|
61
|
-
tw = ::Dockerun::Template::TemplateWriter.new(selTemp)
|
62
|
-
userFields = tw.user_configurables
|
63
|
-
if block
|
64
|
-
tw.user_configurables = block.call(:prompt_user_configurables, { template: selTemp, userFields: userFields })
|
65
|
-
end
|
66
|
-
res = tw.compile
|
67
|
-
|
68
|
-
File.open(out, "w") do |f|
|
69
|
-
f.write res
|
70
|
-
end
|
71
|
-
|
72
|
-
out
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
end # class Init
|
77
|
-
|
78
|
-
end # module Command
|
79
|
-
end # module Dockerun
|
@@ -1,99 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'tty/prompt'
|
3
|
-
require 'docker/cli'
|
4
|
-
|
5
|
-
require_relative '../config'
|
6
|
-
require_relative '../docker_command_factory_helper'
|
7
|
-
require_relative '../cli_prompt'
|
8
|
-
|
9
|
-
|
10
|
-
module Dockerun
|
11
|
-
module Command
|
12
|
-
class RemoveContainer
|
13
|
-
include TTY::Option
|
14
|
-
include TR::CondUtils
|
15
|
-
|
16
|
-
include DockerCommandFactoryHelper
|
17
|
-
include CliHelper::CliPrompt
|
18
|
-
|
19
|
-
usage do
|
20
|
-
program "dockerun"
|
21
|
-
command "rmc"
|
22
|
-
desc "Remove container"
|
23
|
-
end
|
24
|
-
|
25
|
-
def run
|
26
|
-
if params[:help]
|
27
|
-
print help
|
28
|
-
exit(0)
|
29
|
-
|
30
|
-
else
|
31
|
-
|
32
|
-
config = ::Dockerun::Config.from_storage
|
33
|
-
|
34
|
-
imageName = nil
|
35
|
-
if is_empty?(config.image_names)
|
36
|
-
raise Error, "No image found"
|
37
|
-
elsif config.image_names.length == 1
|
38
|
-
imageName = config.image_names.first
|
39
|
-
else
|
40
|
-
imageName = cli.select("Please select one of the image below to start : ") do |m|
|
41
|
-
config.image_names.each do |n|
|
42
|
-
m.choice n,n
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end # find imageName
|
46
|
-
|
47
|
-
if is_empty?(config.container_names(imageName))
|
48
|
-
STDOUT.puts "There is no container registered under image '#{imageName}'"
|
49
|
-
else
|
50
|
-
|
51
|
-
loop do
|
52
|
-
|
53
|
-
sel = cli.select("Please select the container that would like to be removed : ") do |m|
|
54
|
-
config.container_names(imageName).each do |n|
|
55
|
-
m.choice n,n
|
56
|
-
end
|
57
|
-
|
58
|
-
m.choice "Quit", :quit
|
59
|
-
end
|
60
|
-
|
61
|
-
case sel
|
62
|
-
when :quit
|
63
|
-
break
|
64
|
-
else
|
65
|
-
dcFact.stop_container(sel).run
|
66
|
-
res = dcFact.delete_container(sel).run
|
67
|
-
if res.failed?
|
68
|
-
if res.err_stream =~ /No such container/
|
69
|
-
remove = cli.yes?("It seems the container already deleted. Do you want to remove it from the list?")
|
70
|
-
if remove
|
71
|
-
config.remove_container(imageName, sel)
|
72
|
-
config.to_storage
|
73
|
-
break if is_empty?(config.container_names(imageName))
|
74
|
-
end
|
75
|
-
else
|
76
|
-
STDERR.puts "Failed to delete container '#{sel}'. Error was : #{res.err_stream}"
|
77
|
-
end
|
78
|
-
else
|
79
|
-
|
80
|
-
config.remove_container(imageName, sel)
|
81
|
-
config.to_storage
|
82
|
-
|
83
|
-
break if is_empty?(config.container_names(imageName))
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'tty/prompt'
|
4
|
-
|
5
|
-
require 'docker/cli'
|
6
|
-
|
7
|
-
require_relative '../config'
|
8
|
-
|
9
|
-
require_relative '../docker_command_factory_helper'
|
10
|
-
require_relative '../cli_prompt'
|
11
|
-
|
12
|
-
module Dockerun
|
13
|
-
module Command
|
14
|
-
class ResetImage
|
15
|
-
include TTY::Option
|
16
|
-
include TR::CondUtils
|
17
|
-
|
18
|
-
include DockerCommandFactoryHelper
|
19
|
-
include CliHelper::CliPrompt
|
20
|
-
|
21
|
-
usage do
|
22
|
-
program "dockerun"
|
23
|
-
command "reset-image"
|
24
|
-
desc "Delete images (and its containers) and start again"
|
25
|
-
end
|
26
|
-
|
27
|
-
def run(&block)
|
28
|
-
|
29
|
-
if params[:help]
|
30
|
-
print help
|
31
|
-
exit(0)
|
32
|
-
|
33
|
-
else
|
34
|
-
|
35
|
-
config = ::Dockerun::Config.from_storage
|
36
|
-
|
37
|
-
if config.isConfigFileAvail?
|
38
|
-
|
39
|
-
skip = cli.no?("Reset docker image (together with the relative container) ? ")
|
40
|
-
if not skip
|
41
|
-
|
42
|
-
selImg = nil
|
43
|
-
if is_empty?(config.image_names)
|
44
|
-
STDOUT.puts "No image found"
|
45
|
-
|
46
|
-
elsif config.image_names.length == 1
|
47
|
-
selImg = config.image_names.first
|
48
|
-
else
|
49
|
-
|
50
|
-
selImg = cli.select("Please select which image you want to reset : ") do |m|
|
51
|
-
config.image_names.each do |n|
|
52
|
-
m.choice n,n
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
if not selImg.nil?
|
59
|
-
|
60
|
-
# start from container first
|
61
|
-
config.container_names(selImg).each do |cn|
|
62
|
-
dcFact.stop_container(cn).run
|
63
|
-
dcFact.delete_container(cn).run
|
64
|
-
end
|
65
|
-
|
66
|
-
STDOUT.puts "#{config.container_names(selImg).length} container(s) from image '#{selImg}' deleted"
|
67
|
-
|
68
|
-
res = dcFact.delete_image(selImg).run
|
69
|
-
if not res.failed?
|
70
|
-
STDOUT.puts "Image '#{selImg}' successfully deleted."
|
71
|
-
config.remove_image(selImg)
|
72
|
-
config.to_storage
|
73
|
-
STDOUT.puts "Image '#{selImg}' removed from history file"
|
74
|
-
else
|
75
|
-
STDERR.puts "Image '#{selImg}' deletion failed. Error was : #{res.err_stream}"
|
76
|
-
removeFromHist = cli.yes?("Image '#{selImg}' failed. Do you want to remove from the history file?")
|
77
|
-
if removeFromHist
|
78
|
-
config.remove_image(selImg)
|
79
|
-
config.to_storage
|
80
|
-
STDOUT.puts "Image '#{selImg}' removed from history file"
|
81
|
-
else
|
82
|
-
STDOUT.puts "Image '#{selImg}' shall remain in the history file"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
if is_empty?(config.image_names)
|
90
|
-
::Dockerun::Config.remove
|
91
|
-
STDOUT.puts "Dockerun workspace config removed"
|
92
|
-
end
|
93
|
-
|
94
|
-
else
|
95
|
-
STDOUT.puts "Reset docker image operation aborted"
|
96
|
-
end
|
97
|
-
|
98
|
-
else
|
99
|
-
STDOUT.puts "Not a dockerun workspace"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|