donce 0.2.1 → 0.2.2
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/donce.gemspec +1 -1
- data/lib/donce.rb +30 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff61e01863f8590b3541ca6edecbf96c4a0ee9d5fe28fbe8e30b4a001c578101
|
4
|
+
data.tar.gz: 800c5ae24c1dd36a9484ec800b6c40217b9491e61b1d89f8d170faf1e4d58471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7164f6f5372ff0a0fd0fff126f11d48e7fd1db042404316fa5d430113a2cd8564a249ef7c6da02a489c627b218ab224cb0d0e4174f5cde3d7ef575945f7d607
|
7
|
+
data.tar.gz: 62e270b7eeee5e3e857c2ee64cdbf7c5aa9fd476ca6a7a0f1d3d011597414d2448a840ea2e0802d672a2197e9c113d670c4ea41135b3024d48dcf1150fb9aaf5
|
data/donce.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
10
10
|
s.required_ruby_version = '>=3.0'
|
11
11
|
s.name = 'donce'
|
12
|
-
s.version = '0.2.
|
12
|
+
s.version = '0.2.2'
|
13
13
|
s.license = 'MIT'
|
14
14
|
s.summary = 'Builds and starts temporary Docker containers'
|
15
15
|
s.description =
|
data/lib/donce.rb
CHANGED
@@ -73,6 +73,21 @@ module Kernel
|
|
73
73
|
raise 'Either use "image" or "home"' if home && image
|
74
74
|
raise 'Either "dockerfile", or "home", or "image" must be provided' if !dockerfile && !home && !image
|
75
75
|
raise 'The "timeout" must be an integer or nil' unless timeout.nil? || timeout.is_a?(Integer)
|
76
|
+
raise 'The "volumes" is nil' if volumes.nil?
|
77
|
+
raise 'The "volumes" must be a Hash' unless volumes.is_a?(Hash)
|
78
|
+
raise 'The "log" is nil' if log.nil?
|
79
|
+
raise 'The "args" is nil' if args.nil?
|
80
|
+
raise 'The "args" must be a String' unless args.is_a?(String)
|
81
|
+
raise 'The "env" is nil' if env.nil?
|
82
|
+
raise 'The "env" must be a Hash' unless env.is_a?(Hash)
|
83
|
+
raise 'The "command" is nil' if command.nil?
|
84
|
+
raise 'The "command" must be a String' unless command.is_a?(String)
|
85
|
+
raise 'The "timeout" is nil' if timeout.nil?
|
86
|
+
raise 'The "timeout" must be a number' unless timeout.is_a?(Integer) || timeout.is_a?(Float)
|
87
|
+
raise 'The "ports" is nil' if ports.nil?
|
88
|
+
raise 'The "ports" must be a Hash' unless ports.is_a?(Hash)
|
89
|
+
raise 'The "build_args" is nil' if build_args.nil?
|
90
|
+
raise 'The "build_args" must be a Hash' unless build_args.is_a?(Hash)
|
76
91
|
docker = ENV['DONCE_SUDO'] ? 'sudo docker' : 'docker'
|
77
92
|
img =
|
78
93
|
if image
|
@@ -97,22 +112,22 @@ module Kernel
|
|
97
112
|
i
|
98
113
|
end
|
99
114
|
container = "donce-#{SecureRandom.hex(6)}"
|
115
|
+
stdout = nil
|
116
|
+
code = 0
|
117
|
+
cmd = [
|
118
|
+
docker, 'run',
|
119
|
+
('--detach' if block_given?),
|
120
|
+
'--name', Shellwords.escape(container),
|
121
|
+
("--add-host #{donce_host}:host-gateway" if OS.linux?),
|
122
|
+
args,
|
123
|
+
env.map { |k, v| "--env #{Shellwords.escape("#{k}=#{v}")}" }.join(' '),
|
124
|
+
ports.map { |k, v| "--publish #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
|
125
|
+
volumes.map { |k, v| "--volume #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
|
126
|
+
("--user=#{Shellwords.escape("#{Process.uid}:#{Process.gid}")}" if root),
|
127
|
+
Shellwords.escape(img),
|
128
|
+
command
|
129
|
+
].compact.join(' ')
|
100
130
|
begin
|
101
|
-
stdout = nil
|
102
|
-
code = 0
|
103
|
-
cmd = [
|
104
|
-
docker, 'run',
|
105
|
-
('--detach' if block_given?),
|
106
|
-
'--name', Shellwords.escape(container),
|
107
|
-
("--add-host #{donce_host}:host-gateway" if OS.linux?),
|
108
|
-
args,
|
109
|
-
env.map { |k, v| "--env #{Shellwords.escape("#{k}=#{v}")}" }.join(' '),
|
110
|
-
ports.map { |k, v| "--publish #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
|
111
|
-
volumes.map { |k, v| "--volume #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
|
112
|
-
("--user=#{Shellwords.escape("#{Process.uid}:#{Process.gid}")}" if root),
|
113
|
-
Shellwords.escape(img),
|
114
|
-
command
|
115
|
-
].compact.join(' ')
|
116
131
|
begin
|
117
132
|
stdout, code =
|
118
133
|
Timeout.timeout(timeout) do
|