dockerun 0.1.14 → 0.1.16
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/.release_history.yml +4 -0
- data/Dockerfile.dockerun +17 -7
- data/Gemfile.lock +9 -10
- data/exe/dockerun +31 -8
- data/lib/dockerun/command/init.rb +5 -1
- data/lib/dockerun/template/template_engine.rb +7 -1
- data/lib/dockerun/template/template_writer.rb +33 -1
- data/lib/dockerun/version.rb +1 -1
- data/template/Dockerfile_general.erb +27 -7
- metadata +3 -6
- data/lib/dockerun/template/template_writter.rb +0 -58
- data/lib/dockerun/template_engine.rb +0 -14
- data/template/Dockerfile_jruby-9.4.0-jdk11.erb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dcb623a392a05026de03f0ed5269e571f61301b5e987b13fffdf07158925748
|
4
|
+
data.tar.gz: bb83b3023ebec5b7813edb7f33b92800e1cdc6f02bc10cd38f72ea3b8b64b5c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7d46fcc6424c9e50cd675f1396647f1f206997becd2d5594a71d060b58cf4d140a24ba20fec18663f9cd9f0465679ec78f42a33000af964dbbb66b7e1a8ede3
|
7
|
+
data.tar.gz: 3d714ad1eddba9e33793de52888b8f2389a7e2f1139ac37001aa1a010eb2f003ca73b503617adb9a017d25eccc2199e8d9c1590e5d2d6d6c83b231b7a0dd4b4f
|
data/.release_history.yml
CHANGED
data/Dockerfile.dockerun
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
|
2
|
-
FROM
|
3
|
-
LABEL version="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
|
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
|
-
|
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.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dockerun (0.1.
|
4
|
+
dockerun (0.1.15)
|
5
5
|
docker-cli
|
6
6
|
teLogger (~> 0.2.0)
|
7
7
|
toolrack (~> 0.19.1)
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
14
|
base58 (0.2.3)
|
15
|
-
devops_assist (0.3.
|
15
|
+
devops_assist (0.3.9)
|
16
16
|
git_cli
|
17
17
|
git_cli_prompt
|
18
18
|
gvcs
|
@@ -20,22 +20,21 @@ GEM
|
|
20
20
|
toolrack
|
21
21
|
tty-prompt
|
22
22
|
diff-lcs (1.5.0)
|
23
|
-
docker-cli (0.
|
23
|
+
docker-cli (0.2.0)
|
24
24
|
ptools
|
25
25
|
teLogger
|
26
|
-
toolrack
|
27
26
|
tty-command
|
28
27
|
tty-prompt
|
29
|
-
git_cli (0.
|
28
|
+
git_cli (0.11.2)
|
30
29
|
gvcs
|
31
30
|
ptools (~> 1.4.0)
|
32
31
|
teLogger
|
33
32
|
toolrack
|
34
|
-
git_cli_prompt (0.3.
|
33
|
+
git_cli_prompt (0.3.2)
|
35
34
|
teLogger
|
36
35
|
toolrack
|
37
36
|
tty-prompt
|
38
|
-
gvcs (0.1.
|
37
|
+
gvcs (0.1.1)
|
39
38
|
pastel (0.8.0)
|
40
39
|
tty-color (~> 0.5)
|
41
40
|
ptools (1.4.3)
|
@@ -44,12 +43,12 @@ GEM
|
|
44
43
|
rspec-core (~> 3.12.0)
|
45
44
|
rspec-expectations (~> 3.12.0)
|
46
45
|
rspec-mocks (~> 3.12.0)
|
47
|
-
rspec-core (3.12.
|
46
|
+
rspec-core (3.12.1)
|
48
47
|
rspec-support (~> 3.12.0)
|
49
|
-
rspec-expectations (3.12.
|
48
|
+
rspec-expectations (3.12.2)
|
50
49
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
50
|
rspec-support (~> 3.12.0)
|
52
|
-
rspec-mocks (3.12.
|
51
|
+
rspec-mocks (3.12.4)
|
53
52
|
diff-lcs (>= 1.2.0, < 2.0)
|
54
53
|
rspec-support (~> 3.12.0)
|
55
54
|
rspec-support (3.12.0)
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
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,6 +76,7 @@ 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
82
|
|
@@ -65,6 +86,7 @@ else
|
|
65
86
|
argv = ARGV[1..-1]
|
66
87
|
riCmd.parse(argv).run
|
67
88
|
rescue TTY::Reader::InputInterrupt
|
89
|
+
pmt.say "\n\n Aborted\n", color: :yellow
|
68
90
|
end
|
69
91
|
|
70
92
|
|
@@ -75,6 +97,7 @@ else
|
|
75
97
|
argv = ARGV[1..-1]
|
76
98
|
riCmd.parse(argv).run
|
77
99
|
rescue TTY::Reader::InputInterrupt
|
100
|
+
pmt.say "\n\n Aborted\n", color: :yellow
|
78
101
|
end
|
79
102
|
|
80
103
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
require 'tty/option'
|
3
3
|
|
4
|
-
require_relative '../template/
|
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|
|
@@ -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,
|
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|
|
data/lib/dockerun/version.rb
CHANGED
@@ -1,12 +1,32 @@
|
|
1
1
|
|
2
|
-
FROM <%= image %>
|
3
|
-
LABEL version="0.1"
|
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
|
-
|
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
|
-
|
8
|
-
|
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.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: toolrack
|
@@ -130,12 +130,9 @@ files:
|
|
130
130
|
- lib/dockerun/template/jruby_template_writer.rb
|
131
131
|
- lib/dockerun/template/template_engine.rb
|
132
132
|
- lib/dockerun/template/template_writer.rb
|
133
|
-
- lib/dockerun/template/template_writter.rb
|
134
|
-
- lib/dockerun/template_engine.rb
|
135
133
|
- lib/dockerun/user_info.rb
|
136
134
|
- lib/dockerun/version.rb
|
137
135
|
- template/Dockerfile_general.erb
|
138
|
-
- template/Dockerfile_jruby-9.4.0-jdk11.erb
|
139
136
|
homepage: ''
|
140
137
|
licenses: []
|
141
138
|
metadata: {}
|
@@ -154,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
151
|
- !ruby/object:Gem::Version
|
155
152
|
version: '0'
|
156
153
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
154
|
+
rubygems_version: 3.4.6
|
158
155
|
signing_key:
|
159
156
|
specification_version: 4
|
160
157
|
summary: ''
|
@@ -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,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" ]
|