dockerun 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74a44fad6328874a4a1fb7bbb2016251289612c04e13b33f0a379322f6fa6483
4
- data.tar.gz: 21e4031445056b0a7bf6eed50b7f973aac2a2d11fc39cbdac9d024331551d049
3
+ metadata.gz: 8dcb623a392a05026de03f0ed5269e571f61301b5e987b13fffdf07158925748
4
+ data.tar.gz: bb83b3023ebec5b7813edb7f33b92800e1cdc6f02bc10cd38f72ea3b8b64b5c7
5
5
  SHA512:
6
- metadata.gz: 582c0c2f22cf71e7d5f0b51a8dae93eca93bc86e0a5cc8e050ab6aca5402d35c5a7e4eaee144477f15c10498ab47b317610d8bc61565682413ed4f97fa713a33
7
- data.tar.gz: 0441c11a017bedb1ccee6ba3f4497e9a24eeca22d519ac4c72e61cbdd5164b2a0dc4ea5b1aebaaea6a24873bfbc9856d94de023028303681a251bbaa88b1f2fa
6
+ metadata.gz: c7d46fcc6424c9e50cd675f1396647f1f206997becd2d5594a71d060b58cf4d140a24ba20fec18663f9cd9f0465679ec78f42a33000af964dbbb66b7e1a8ede3
7
+ data.tar.gz: 3d714ad1eddba9e33793de52888b8f2389a7e2f1139ac37001aa1a010eb2f003ca73b503617adb9a017d25eccc2199e8d9c1590e5d2d6d6c83b231b7a0dd4b4f
data/.release_history.yml CHANGED
@@ -30,3 +30,5 @@ dockerun:
30
30
  :timestamp: 1670649972.645625
31
31
  - :version: 0.1.14
32
32
  :timestamp: 1670677180.3442845
33
+ - :version: 0.1.15
34
+ :timestamp: 1679980468.4161575
data/Dockerfile.dockerun CHANGED
@@ -1,9 +1,15 @@
1
1
 
2
- FROM jruby:9.4.0-jdk11
3
- LABEL version="0.1" description="Dockerfile generated by dockerun" maintainer="chris"
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
10
+
11
+
4
12
 
5
- # Dockerfile entries here
6
- RUN apt-get update && apt-get install -y sudo
7
13
 
8
14
  RUN groupadd -f -g 1000 chris && \
9
15
  useradd -u 1000 -g 1000 -m chris && \
@@ -12,8 +18,12 @@ RUN groupadd -f -g 1000 chris && \
12
18
 
13
19
  USER chris
14
20
 
15
- RUN sudo apt-get install -y curl git
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
+ # other Dockerfile entries starts here
16
27
 
17
- # ENTRYPOINT [ "/bin/bash" ]
18
- # CMD [ "/bin/bash", "--login" ]
19
28
  CMD [ "/bin/bash", "--login" ]
29
+
data/Gemfile CHANGED
@@ -9,7 +9,5 @@ gem "rake", "~> 13.0"
9
9
 
10
10
  gem "rspec", "~> 3.0"
11
11
 
12
- #gem 'git_cli', git: "git_cli", branch: "master"
13
12
  #gem 'docker-cli', git: "docker-cli", branch: "master"
14
13
 
15
-
data/Gemfile.lock CHANGED
@@ -2,10 +2,9 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  dockerun (0.1.15)
5
- colorize (~> 0.8.0)
6
- docker-cli (~> 0.2.1)
5
+ docker-cli
7
6
  teLogger (~> 0.2.0)
8
- toolrack (~> 0.20.1)
7
+ toolrack (~> 0.19.1)
9
8
  tty-command (~> 0.10.1)
10
9
  tty-option (~> 0.2.0)
11
10
 
@@ -13,8 +12,7 @@ GEM
13
12
  remote: https://rubygems.org/
14
13
  specs:
15
14
  base58 (0.2.3)
16
- colorize (0.8.1)
17
- devops_assist (0.3.3)
15
+ devops_assist (0.3.9)
18
16
  git_cli
19
17
  git_cli_prompt
20
18
  gvcs
@@ -22,18 +20,17 @@ GEM
22
20
  toolrack
23
21
  tty-prompt
24
22
  diff-lcs (1.5.0)
25
- docker-cli (0.2.1)
26
- ptools (~> 1.4.3)
27
- teLogger (~> 0.2.2)
28
- toolrack (~> 0.20.1)
29
- tty-command (~> 0.10.1)
30
- tty-prompt (~> 0.23.1)
23
+ docker-cli (0.2.0)
24
+ ptools
25
+ teLogger
26
+ tty-command
27
+ tty-prompt
31
28
  git_cli (0.11.2)
32
29
  gvcs
33
30
  ptools (~> 1.4.0)
34
31
  teLogger
35
32
  toolrack
36
- git_cli_prompt (0.3.1)
33
+ git_cli_prompt (0.3.2)
37
34
  teLogger
38
35
  toolrack
39
36
  tty-prompt
@@ -56,7 +53,7 @@ GEM
56
53
  rspec-support (~> 3.12.0)
57
54
  rspec-support (3.12.0)
58
55
  teLogger (0.2.2)
59
- toolrack (0.20.1)
56
+ toolrack (0.19.1)
60
57
  base58
61
58
  tty-color (0.6.0)
62
59
  tty-command (0.10.1)
@@ -74,7 +71,7 @@ GEM
74
71
  wisper (2.0.1)
75
72
 
76
73
  PLATFORMS
77
- x86_64-darwin-21
74
+ x86_64-linux
78
75
 
79
76
  DEPENDENCIES
80
77
  devops_assist
@@ -83,4 +80,4 @@ DEPENDENCIES
83
80
  rspec (~> 3.0)
84
81
 
85
82
  BUNDLED WITH
86
- 2.4.6
83
+ 2.2.28
data/dockerun.gemspec CHANGED
@@ -30,14 +30,13 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_dependency 'toolrack', '~> 0.20.1'
33
+ spec.add_dependency 'toolrack', '~> 0.19.1'
34
34
  spec.add_dependency 'teLogger', '~> 0.2.0'
35
35
 
36
36
  spec.add_dependency 'tty-command', "~> 0.10.1"
37
37
  spec.add_dependency 'tty-option', "~> 0.2.0"
38
- spec.add_dependency 'colorize', "~> 0.8.0"
39
38
 
40
- spec.add_dependency 'docker-cli', "~> 0.2.1"
39
+ spec.add_dependency 'docker-cli'
41
40
 
42
41
  spec.add_development_dependency 'devops_assist'
43
42
 
data/exe/dockerun CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'toolrack'
4
+ include TR::CondUtils
5
+
3
6
  require 'tty/prompt'
4
7
  require_relative '../lib/dockerun'
5
8
 
@@ -16,18 +19,33 @@ else
16
19
  when "init"
17
20
  initCmd = Dockerun::Command::Init.new
18
21
  argv = ARGV[1..-1]
19
- res2 = initCmd.parse(argv).run do |ops, val|
20
- case ops
21
- when :multiple_templates_detected
22
- pmt.select("There are multiple templates available. Please select one of the template : ") do |m|
23
- val.each do |v|
24
- m.choice v, v
22
+ begin
23
+ res2 = initCmd.parse(argv).run do |ops, val|
24
+ case ops
25
+ when :multiple_templates_detected
26
+ pmt.select("There are multiple templates available. Please select one of the template : ") do |m|
27
+ val.each do |v|
28
+ m.choice v, v
29
+ end
30
+ end
31
+
32
+ when :prompt_user_configurables
33
+ pmt.say "\n The following are the configurable items for the template '#{val[:template]}' : \n", color: :yellow
34
+ res = { }
35
+ val[:userFields].each do |k,v|
36
+ res[k] = pmt.ask("#{k.to_s.capitalize} : ") do |s|
37
+ s.required v[:required] if not_empty?(v[:required]) and is_bool?(v[:required])
38
+ s.value v[:default].to_s if not_empty?(v[:default])
39
+ end
25
40
  end
41
+ res
26
42
  end
27
43
  end
28
- end
29
44
 
30
- STDOUT.puts "\nDockerfile written to '#{res2}'\n\n"
45
+ STDOUT.puts "\nDockerfile written to '#{res2}'\n\n"
46
+ rescue TTY::Reader::InputInterrupt
47
+ pmt.say "\n\n Aborted\n", color: :yellow
48
+ end
31
49
 
32
50
  when "run", "r"
33
51
 
@@ -36,6 +54,7 @@ else
36
54
  argv = ARGV[1..-1]
37
55
  runCmd.parse(argv).run
38
56
  rescue TTY::Reader::InputInterrupt
57
+ pmt.say "\n\n Aborted\n", color: :yellow
39
58
  end
40
59
 
41
60
 
@@ -46,6 +65,7 @@ else
46
65
  argv = ARGV[1..-1]
47
66
  runCmd.parse(argv).run
48
67
  rescue TTY::Reader::InputInterrupt
68
+ pmt.say "\n\n Aborted\n", color: :yellow
49
69
  end
50
70
 
51
71
 
@@ -56,19 +76,9 @@ else
56
76
  argv = ARGV[1..-1]
57
77
  runCmd.parse(argv).run
58
78
  rescue TTY::Reader::InputInterrupt
79
+ pmt.say "\n\n Aborted\n", color: :yellow
59
80
  end
60
81
 
61
- when "stop", "s"
62
-
63
- begin
64
- runCmd = Dockerun::Command::StopContainer.new
65
- argv = ARGV[1..-1]
66
- runCmd.parse(argv).run
67
- rescue TTY::Reader::InputInterrupt
68
- end
69
-
70
-
71
-
72
82
 
73
83
  when "rmi", "remove-image"
74
84
  begin
@@ -76,6 +86,7 @@ else
76
86
  argv = ARGV[1..-1]
77
87
  riCmd.parse(argv).run
78
88
  rescue TTY::Reader::InputInterrupt
89
+ pmt.say "\n\n Aborted\n", color: :yellow
79
90
  end
80
91
 
81
92
 
@@ -86,6 +97,7 @@ else
86
97
  argv = ARGV[1..-1]
87
98
  riCmd.parse(argv).run
88
99
  rescue TTY::Reader::InputInterrupt
100
+ pmt.say "\n\n Aborted\n", color: :yellow
89
101
  end
90
102
 
91
103
 
@@ -1,5 +1,4 @@
1
1
 
2
- require 'colorize'
3
2
  require 'tty/prompt'
4
3
 
5
4
  module Dockerun
@@ -14,7 +14,7 @@ module Dockerun
14
14
 
15
15
  argument :command do
16
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)"
17
+ desc "Command for the dockerun operations. Supported: init, run (r), run-new-container (rnc), run-new-image (rni), remove-image (rmi), remove-container (rmc)"
18
18
  end
19
19
 
20
20
  def run
@@ -1,7 +1,7 @@
1
1
 
2
2
  require 'tty/option'
3
3
 
4
- require_relative '../template/template_writter'
4
+ require_relative '../template/template_writer'
5
5
 
6
6
  module Dockerun
7
7
  module Command
@@ -59,6 +59,10 @@ module Dockerun
59
59
  end
60
60
 
61
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
62
66
  res = tw.compile
63
67
 
64
68
  File.open(out, "w") do |f|
@@ -16,7 +16,6 @@ module Dockerun
16
16
  include CommandHelper::DockerContainerHelper
17
17
  include DockerCommandFactoryHelper
18
18
  include CommandHelper::DockerImageHelper
19
- include CliHelper::CliPrompt
20
19
 
21
20
  usage do
22
21
  program "dockerun"
@@ -106,33 +105,20 @@ module Dockerun
106
105
  case ops
107
106
  when :new_container_name
108
107
  cli.ask("Please provide a new container name : ", required: true)
109
-
110
108
  when :container_name_exist
111
109
  cli.yes?("Container name '#{args.first}' already exist. Proceed with existing?")
112
-
113
110
  when :volume_mapping_required?
114
- cli.say "\nCurrent configured mount point(s) : \n"
115
- config.container_mount_points(imageName, selContName).each do |mp|
116
- cli.say " * (Local) #{mp.keys[0]} ==> (Container) #{mp.values[0]}"
117
- end
118
- cli.yes?("\nIs there any volume mapping required? ")
119
-
120
- when :existing_volume_mapping
121
- config.container_mount_points(imageName, selContName)
122
-
111
+ cli.yes?("Is there any volume mapping required? ")
123
112
  when :source_prompt
124
113
  cli.ask("Directory to share with docker : ", required: true)
125
-
126
114
  when :destination_prompt
127
115
  src = args.first
128
116
  srcDir = File.basename(src)
129
117
  cli.ask("Directory to show inside docker : ", required: true, value: "/opt/#{srcDir}")
130
118
  when :add_mount_to_container
131
119
  config.add_mount_to_container(imageName, *args)
132
-
133
120
  when :add_more_volume_mapping?
134
121
  cli.yes?("Add more volume mapping?")
135
-
136
122
  end
137
123
  end
138
124
 
@@ -28,9 +28,9 @@ module Dockerun
28
28
 
29
29
  def initialize(configHash = { }, configFileAvail = false)
30
30
  @config = configHash
31
- @images = @config[:images] || { }
31
+ @images = @config[:images]
32
32
  @confFileAvail = configFileAvail
33
- #@images = { } if @images.nil?
33
+ @images = { } if @images.nil?
34
34
  end
35
35
 
36
36
  def isConfigFileAvail?
@@ -74,8 +74,8 @@ module Dockerun
74
74
  @images[imageName][container][:mount] << mount
75
75
  end
76
76
 
77
- def container_mount_points(imageName, container)
78
- res = @images[imageName][container]
77
+ def mount_of_container(container)
78
+ res = @containers[container]
79
79
  if is_empty?(res) or is_empty?(res[:mount])
80
80
  []
81
81
  else
@@ -2,10 +2,6 @@
2
2
  require 'docker/cli'
3
3
 
4
4
  module Dockerun
5
-
6
- #
7
- # Link to CommandFactory
8
- #
9
5
  module DockerCommandFactoryHelper
10
6
 
11
7
  def dcFact
@@ -3,28 +3,20 @@ require_relative 'docker_command_factory_helper'
3
3
 
4
4
  module Dockerun
5
5
  module CommandHelper
6
-
7
- #
8
- # Common functions for docker container management
9
- #
10
6
  module DockerContainerHelper
11
7
  include DockerCommandFactoryHelper
12
8
 
13
9
  class DockerContainerBuildFailed < StandardError; end
14
10
  class DockerContainerStartFailed < StandardError; end
15
- class DockerContainerStopFailed < StandardError; end
16
11
 
17
12
  def run_docker_container(image_name, container_name, &block)
18
13
 
19
14
  raise DockerContainerBuildFailed, "block is required" if not block
20
15
  raise DockerContainerBuildFailed, "Image name is required" if is_empty?(image_name)
21
16
 
22
- Dockerun.udebug("Running image '#{image_name}', container '#{container_name}'")
23
-
24
17
  reuse = nil
25
18
 
26
19
  if is_empty?(container_name)
27
- Dockerun.udebug "Container name empty. Creating new container"
28
20
  container_name = block.call(:new_container_name)
29
21
  loop do
30
22
  st, _ = is_container_exist?(container_name)
@@ -38,23 +30,19 @@ module Dockerun
38
30
  end
39
31
 
40
32
  else
41
- reuse, _ = is_container_exist?(container_name)
42
- Dockerun.udebug "Container name not empty. Is container exist? : #{reuse}"
43
- #if st
44
- # reuse = true
45
- #else
46
- # # if not found shall drop into the next block's else clause
47
- #end
33
+ st, _ = is_container_exist?(container_name)
34
+ if st
35
+ reuse = true
36
+ else
37
+ # if not found shall drop into the next block's else clause
38
+ end
48
39
  end
49
40
 
50
41
  if reuse == true
51
-
52
- Dockerun.udebug "Find out of container '#{container_name}' is running..."
53
- #res = dcFact.find_running_container(container_name).run
54
- #if not res.failed? and res.is_out_stream_empty?
55
- if not is_container_running?(container_name)
42
+
43
+ res = dcFact.find_running_container(container_name).run
44
+ if not res.failed? and res.is_out_stream_empty?
56
45
  # not running
57
- Dockerun.udebug "Container '#{container_name}' does not seems to be running. Starting container."
58
46
  ress = dcFact.start_container(container_name).run
59
47
  raise DockerContainerStartFailed, "Failed to start container '#{container_name}'. Error was : #{ress.err_stream}" if ress.failed?
60
48
  end
@@ -68,10 +56,8 @@ module Dockerun
68
56
 
69
57
  else
70
58
 
71
- Dockerun.udebug "Container '#{container_name}' doesn't exist. Proceed to create new container."
72
59
  reqVolMap = block.call(:volume_mapping_required?)
73
- mount = block.call(:existing_volume_mapping) || []
74
- #mount = []
60
+ mount = []
75
61
  if reqVolMap
76
62
 
77
63
  loop do
@@ -119,20 +105,6 @@ module Dockerun
119
105
 
120
106
  end
121
107
 
122
- def is_container_running?(name)
123
- if not_empty?(name)
124
- res = dcFact.find_running_container(name).run
125
- not res.failed? and not res.is_out_stream_empty?
126
- else
127
- false
128
- end
129
- end
130
-
131
- def stop_container(name)
132
- res = dcFact.stop_container(name).run
133
- raise DockerContainerStopFailed, "Failed to stop docker container '#{name}'. Error was : #{res.err_stream}" if res.failed?
134
- end
135
-
136
108
 
137
109
  end
138
110
  end
@@ -4,10 +4,6 @@ require_relative 'docker_command_factory_helper'
4
4
 
5
5
  module Dockerun
6
6
  module CommandHelper
7
-
8
- #
9
- # common functions for docker image management
10
- #
11
7
  module DockerImageHelper
12
8
  include CliHelper::CliPrompt
13
9
  include DockerCommandFactoryHelper
@@ -10,8 +10,14 @@ module Dockerun
10
10
 
11
11
  def self.available_templates
12
12
  avail = Dir.glob(File.join(template_root,"Dockerfile_*.erb"))
13
+
14
+ #userDir = File.join(Dir.home,".dockerun","template")
15
+ #if File.exist?(userDir)
16
+ # avail += Dir.glob(userDir,"*.erb")
17
+ #end
18
+
13
19
  avail.map! { |f|
14
- name = File.basename(f,".erb")
20
+ name = File.basename(f,File.extname(f))
15
21
  name.gsub("Dockerfile_","")
16
22
  }
17
23
  end
@@ -11,7 +11,8 @@ module Dockerun
11
11
 
12
12
  class TemplateNotFound < StandardError; end
13
13
 
14
- attr_accessor :image, :user_group_id, :user_group_name, :user_id, :user_login
14
+ attr_accessor :image, :user_group_id, :user_group_name, :user_id, :user_login, :maintainer, :image_base
15
+ attr_writer :user_configurables
15
16
 
16
17
  def self.instance(template)
17
18
  tmp = template.to_s.downcase
@@ -32,9 +33,40 @@ module Dockerun
32
33
  @user_group_name = group[:group_name]
33
34
  @user_id = user[:user_id]
34
35
  @user_login = user[:login]
36
+ @image_base = :ubuntu
37
+ end
38
+
39
+ def user_configurables
40
+ fields = {
41
+ image: { desc: "Image name of the docker based on", required: true },
42
+ image_base: { desc: "Image is based on which OS? Assumption with be on Debian based. ", default: :ubuntu },
43
+ maintainer: { desc: "Maintainer of the Dockerfile", default: @maintainer }
44
+ }
45
+
46
+ if TR::RTUtils.on_linux?
47
+ f2 = {
48
+ user_group_id: { desc: "User group ID that shall be created in docker. Default to current running user's ID", default: @user_group_id.to_s },
49
+ user_group_name: { desc: "User group name that shall be created in docker. Default to current running user's group", default: @user_group_name },
50
+ user_id: { desc: "User ID that shall be created in docker. Default to current running user ID", default: @user_id.to_s },
51
+ user_login: { desc: "User login name that shall be created in docker. Default to current running user's login", default: @user_login }
52
+ }
53
+ fields.merge!(f2)
54
+ end
55
+ fields
35
56
  end
36
57
 
37
58
  def compile(&block)
59
+
60
+ if not_empty?(@user_configurables)
61
+ @user_configurables.each do |k,v|
62
+ begin
63
+ self.send("#{k}=", v)
64
+ rescue Exception => ex
65
+ STDERR.puts "Setting value exception : #{ex}"
66
+ end
67
+ end
68
+ end
69
+
38
70
  tmp = find_template
39
71
  cont = nil
40
72
  File.open(tmp,"r") do |f|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dockerun
4
- VERSION = "0.1.15"
4
+ VERSION = "0.1.16"
5
5
  end
data/lib/dockerun.rb CHANGED
@@ -12,7 +12,6 @@ require_relative 'dockerun/command/reset_image'
12
12
  require_relative 'dockerun/command/run_new_container'
13
13
  require_relative 'dockerun/command/remove_container'
14
14
  require_relative 'dockerun/command/run_new_image'
15
- require_relative 'dockerun/command/stop_container'
16
15
 
17
16
  require_relative 'dockerun/template/template_writer'
18
17
  require_relative 'dockerun/template/template_engine'
@@ -20,21 +19,4 @@ require_relative 'dockerun/template/template_engine'
20
19
  module Dockerun
21
20
  class Error < StandardError; end
22
21
  # Your code goes here...
23
-
24
- def self.udebug(msg)
25
- logger.tdebug(:dockerun, msg) if is_user_debug_on?
26
- end
27
-
28
- def self.logger
29
- if @_logger.nil?
30
- @_logger = TeLogger::Tlogger.new
31
- end
32
- @_logger
33
- end
34
-
35
- def self.is_user_debug_on?
36
- val = ENV["DOCKERUN_DEBUG"]
37
- (not val.nil? and val == "true")
38
- end
39
-
40
22
  end
@@ -1,12 +1,32 @@
1
1
 
2
- FROM <%= image %>
3
- LABEL version="0.1" description="Dockerfile generated by dockerun" maintainer="<%= @maintainer %>"
2
+ FROM <%= @image %>
3
+ LABEL version="0.1"
4
+ LABEL maintainer="<%= @maintainer %>"
5
+ LABEL description="Dockerfile generated by dockerun"
6
+ LABEL dockerun-info="https://github.com/chrisliaw/dockerun"
4
7
 
5
- # Dockerfile entries here
8
+ <% case @image_base.to_sym
9
+ when :fedora %>
10
+ RUN dnf update && dnf install sudo git curl
11
+ <% else %>
12
+ RUN apt-get update && apt-get install -y sudo git curl build-essential
13
+ <% end %>
6
14
 
7
- RUN groupadd -f -g <%= @user_group_id %> <%= @user_group_name %> && useradd -u <%= @user_id %> -g <%= @user_group_id %> -m <%= @user_login %>
8
- USER <%= @user_login %>:<%= @user_group_name %>
15
+ <% if TR::RTUtils.on_linux? %>
16
+
17
+ RUN groupadd -f -g <%= @user_group_id %> <%= @user_group_name %> && \
18
+ useradd -u <%= @user_id %> -g <%= @user_group_id %> -m <%= @user_login %> && \
19
+ usermod -aG sudo <%= @user_login %> && \
20
+ echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
21
+
22
+ USER <%= @user_login %>
23
+
24
+ # from this point onwards, sudo is required for privileaged operation
25
+ #RUN sudo apt-get install -y curl build-essential
26
+
27
+ <% end %>
28
+
29
+ # other Dockerfile entries starts here
9
30
 
10
- # ENTRYPOINT [ "/bin/bash" ]
11
- # CMD [ "/bin/bash", "--login" ]
12
31
  CMD [ "/bin/bash", "--login" ]
32
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockerun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-23 00:00:00.000000000 Z
11
+ date: 2023-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toolrack
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.20.1
19
+ version: 0.19.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.20.1
26
+ version: 0.19.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: teLogger
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,34 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.2.0
69
- - !ruby/object:Gem::Dependency
70
- name: colorize
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.8.0
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 0.8.0
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: docker-cli
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - "~>"
73
+ - - ">="
88
74
  - !ruby/object:Gem::Version
89
- version: 0.2.1
75
+ version: '0'
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - "~>"
80
+ - - ">="
95
81
  - !ruby/object:Gem::Version
96
- version: 0.2.1
82
+ version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: devops_assist
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +122,6 @@ files:
136
122
  - lib/dockerun/command/run.rb
137
123
  - lib/dockerun/command/run_new_container.rb
138
124
  - lib/dockerun/command/run_new_image.rb
139
- - lib/dockerun/command/stop_container.rb
140
125
  - lib/dockerun/config.rb
141
126
  - lib/dockerun/docker_command_factory_helper.rb
142
127
  - lib/dockerun/docker_container_helper.rb
@@ -145,16 +130,13 @@ files:
145
130
  - lib/dockerun/template/jruby_template_writer.rb
146
131
  - lib/dockerun/template/template_engine.rb
147
132
  - lib/dockerun/template/template_writer.rb
148
- - lib/dockerun/template/template_writter.rb
149
- - lib/dockerun/template_engine.rb
150
133
  - lib/dockerun/user_info.rb
151
134
  - lib/dockerun/version.rb
152
135
  - template/Dockerfile_general.erb
153
- - template/Dockerfile_jruby-9.4.0-jdk11.erb
154
136
  homepage: ''
155
137
  licenses: []
156
138
  metadata: {}
157
- post_install_message:
139
+ post_install_message:
158
140
  rdoc_options: []
159
141
  require_paths:
160
142
  - lib
@@ -170,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
152
  version: '0'
171
153
  requirements: []
172
154
  rubygems_version: 3.4.6
173
- signing_key:
155
+ signing_key:
174
156
  specification_version: 4
175
157
  summary: ''
176
158
  test_files: []
@@ -1,90 +0,0 @@
1
-
2
- require_relative '../cli_prompt'
3
- require_relative '../config'
4
- require_relative '../docker_container_helper'
5
-
6
- module Dockerun
7
- module Command
8
-
9
- class StopContainer
10
-
11
- include TTY::Option
12
- include TR::CondUtils
13
- include CommandHelper::DockerContainerHelper
14
- include DockerCommandFactoryHelper
15
- include CliHelper::CliPrompt
16
-
17
- usage do
18
- program "dockerun"
19
- command "stop"
20
- desc "Stop a running container"
21
- end
22
-
23
- def run(&block)
24
- if params[:help]
25
- print help
26
- exit(0)
27
-
28
- else
29
-
30
- # find history file
31
- config = ::Dockerun::Config.from_storage
32
-
33
- res = []
34
- opts = []
35
- config.image_names.each do |im|
36
- config.container_names(im).each do |cn|
37
- if is_container_exist?(cn)
38
- if is_container_running?(cn)
39
- res << "#{im} : #{cn} (Running)"
40
- opts << cn
41
- else
42
- res << "#{im} : #{cn} (Not Running)"
43
- end
44
- else
45
- res << "#{im} : #{cn} (Not Exist)"
46
- end
47
- end
48
- end
49
-
50
- if not opts.empty?
51
- cli.puts "\n Running status of container(s) : ".yellow
52
- res.sort.each do |r|
53
- cli.puts " * #{r}".yellow
54
- end
55
-
56
- cli.puts
57
- selConts = cli.multi_select("Please select which container to stop : ") do |m|
58
- opts.each do |o|
59
- m.choice o,o
60
- end
61
-
62
- m.choice "Abort", :quit
63
- end
64
-
65
- if selConts.include?(:quit)
66
- cli.puts " * Abort was one of the selected option. Command aborted.".red
67
- else
68
- selConts.each do |sc|
69
- begin
70
- stop_container(sc)
71
- cli.puts " Container '#{sc}' stopped successfully.".green
72
- rescue DockerContainerStopFailed => ex
73
- cli.puts " Container '#{sc}' failed to be stopped".red
74
- end
75
- end
76
- end
77
-
78
- else
79
- cli.say " * There is no container found to be running * ".yellow
80
- end
81
-
82
- cli.puts "\n Stop container command completed successfully \n\n".yellow
83
-
84
- end
85
- end
86
-
87
- end
88
-
89
- end
90
- end
@@ -1,58 +0,0 @@
1
-
2
- require 'erb'
3
-
4
- require_relative '../user_info'
5
-
6
- module Dockerun
7
- module Template
8
-
9
- class TemplateWritter
10
- include UserInfo
11
-
12
- class TemplateNotFound < StandardError; end
13
-
14
- attr_accessor :image, :user_group_id, :user_group_name, :user_id, :user_login
15
-
16
- def self.instance(template)
17
-
18
- end
19
-
20
- def initialize(template = :general)
21
- @template = template
22
- @image = "<Replace me>"
23
- user = user_info
24
- group = group_info
25
- @maintainer = user[:login]
26
- @user_group_id = group[:group_id]
27
- @user_group_name = group[:group_name]
28
- @user_id = user[:user_id]
29
- @user_login = user[:login]
30
- end
31
-
32
- def compile(&block)
33
- tmp = find_template
34
- cont = nil
35
- File.open(tmp,"r") do |f|
36
- cont = f.read
37
- end
38
-
39
- b = binding
40
-
41
- res = ERB.new(cont)
42
- res.result(b)
43
- end
44
-
45
- private
46
- def find_template
47
- @template = :general if is_empty?(@template)
48
-
49
- root = TemplateEngine.template_root
50
- templateFile = File.join(root,"Dockerfile_#{@template}.erb")
51
- raise TemplateNotFound, "Given template '#{@template}' could not be found" if not File.exist?(templateFile)
52
-
53
- templateFile
54
- end
55
-
56
- end
57
- end
58
- end
@@ -1,14 +0,0 @@
1
-
2
-
3
- module Dockerun
4
- module Template
5
- class TemplateEngine
6
-
7
- def self.available_templates
8
- path = File.join(File.dirname(__FILE__),"..","..","..","template")
9
-
10
- end
11
-
12
- end
13
- end
14
- end
@@ -1,21 +0,0 @@
1
-
2
- FROM jruby:9.4.0-jdk11
3
- LABEL version="0.1" description="Dockerfile generated by dockerun" maintainer="<%= @maintainer %>"
4
-
5
- RUN apt-get update && apt-get install -y sudo
6
-
7
- RUN groupadd -f -g <%= @user_group_id %> <%= @user_group_name %> && \
8
- useradd -u <%= @user_id %> -g <%= @user_group_id %> -m <%= @user_login %> && \
9
- usermod -aG sudo <%= @user_login %> && \
10
- echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
11
-
12
- USER <%= @user_login %>
13
-
14
- # from this point onwards, sudo is required for privileaged operation
15
- RUN sudo apt-get install -y curl
16
-
17
- # other Dockerfile entries starts here
18
-
19
- # ENTRYPOINT [ "/bin/bash" ]
20
- # CMD [ "/bin/bash", "--login" ]
21
- CMD [ "/bin/bash", "--login" ]