donce 0.2.0 → 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/.rubocop.yml +0 -1
- data/Gemfile +0 -1
- data/Gemfile.lock +4 -8
- data/README.md +16 -16
- data/Rakefile +0 -1
- data/donce.gemspec +1 -1
- data/lib/donce.rb +31 -16
- metadata +2 -2
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/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -15,7 +15,6 @@ gem 'rubocop', '~>1.75', require: false
|
|
15
15
|
gem 'rubocop-minitest', '>0', require: false
|
16
16
|
gem 'rubocop-performance', '>0', require: false
|
17
17
|
gem 'rubocop-rake', '>0', require: false
|
18
|
-
gem 'rubocop-rspec', '>0', require: false
|
19
18
|
gem 'simplecov', '~>0.22', require: false
|
20
19
|
gem 'simplecov-cobertura', '~>2.1', require: false
|
21
20
|
gem 'yard', '~>0.9', require: false
|
data/Gemfile.lock
CHANGED
@@ -30,8 +30,8 @@ GEM
|
|
30
30
|
minitest-retry (0.2.5)
|
31
31
|
minitest (>= 5.0)
|
32
32
|
os (1.1.4)
|
33
|
-
parallel (1.
|
34
|
-
parser (3.3.
|
33
|
+
parallel (1.27.0)
|
34
|
+
parser (3.3.8.0)
|
35
35
|
ast (~> 2.4.1)
|
36
36
|
racc
|
37
37
|
prism (1.4.0)
|
@@ -45,7 +45,7 @@ GEM
|
|
45
45
|
rake (13.2.1)
|
46
46
|
regexp_parser (2.10.0)
|
47
47
|
rexml (3.4.1)
|
48
|
-
rubocop (1.75.
|
48
|
+
rubocop (1.75.3)
|
49
49
|
json (~> 2.3)
|
50
50
|
language_server-protocol (~> 3.17.0.2)
|
51
51
|
lint_roller (~> 1.1.0)
|
@@ -56,7 +56,7 @@ GEM
|
|
56
56
|
rubocop-ast (>= 1.44.0, < 2.0)
|
57
57
|
ruby-progressbar (~> 1.7)
|
58
58
|
unicode-display_width (>= 2.4.0, < 4.0)
|
59
|
-
rubocop-ast (1.44.
|
59
|
+
rubocop-ast (1.44.1)
|
60
60
|
parser (>= 3.3.7.2)
|
61
61
|
prism (~> 1.4)
|
62
62
|
rubocop-minitest (0.38.0)
|
@@ -70,9 +70,6 @@ GEM
|
|
70
70
|
rubocop-rake (0.7.1)
|
71
71
|
lint_roller (~> 1.1)
|
72
72
|
rubocop (>= 1.72.1)
|
73
|
-
rubocop-rspec (3.5.0)
|
74
|
-
lint_roller (~> 1.1)
|
75
|
-
rubocop (~> 1.72, >= 1.72.1)
|
76
73
|
ruby-progressbar (1.13.0)
|
77
74
|
simplecov (0.22.0)
|
78
75
|
docile (~> 1.1)
|
@@ -106,7 +103,6 @@ DEPENDENCIES
|
|
106
103
|
rubocop-minitest (> 0)
|
107
104
|
rubocop-performance (> 0)
|
108
105
|
rubocop-rake (> 0)
|
109
|
-
rubocop-rspec (> 0)
|
110
106
|
simplecov (~> 0.22)
|
111
107
|
simplecov-cobertura (~> 2.1)
|
112
108
|
yard (~> 0.9)
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Builds Docker image, runs it, and kills
|
2
2
|
|
3
|
-
[](https://www.rultor.com/p/yegor256/donce)
|
4
4
|
[](https://www.jetbrains.com/ruby/)
|
5
5
|
|
6
6
|
[](https://github.com/yegor256/donce/actions/workflows/rake.yml)
|
7
|
-
[](
|
7
|
+
[](https://www.0pdd.com/p?name=yegor256/donce)
|
8
|
+
[](https://badge.fury.io/rb/donce)
|
9
9
|
[](https://codecov.io/github/yegor256/donce?branch=master)
|
10
|
-
[](https://rubydoc.info/github/yegor256/donce/master/frames)
|
11
11
|
[](https://hitsofcode.com/view/github/yegor256/donce)
|
12
12
|
[](https://github.com/yegor256/donce/blob/master/LICENSE.txt)
|
13
13
|
|
@@ -42,18 +42,18 @@ end
|
|
42
42
|
|
43
43
|
Here's a list of the available parameters for `donce`:
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
45
|
+
* `dockerfile`: Content of the Dockerfile (string or array of strings)
|
46
|
+
* `home`: Directory with Dockerfile and all other necessary files
|
47
|
+
* `image`: Name of a Docker image to use (e.g. "ubuntu:22.04")
|
48
|
+
* `log`: Logging destination (defaults to $stdout)
|
49
|
+
* `args`: Extra arguments for the docker command
|
50
|
+
* `env`: Environment variables mapping for the container
|
51
|
+
* `volumes`: Local to container volumes mapping
|
52
|
+
* `ports`: Local to container port mapping
|
53
|
+
* `build_args`: Arguments for docker build (--build-arg)
|
54
|
+
* `root`: Let user inside the container be "root" (default: false)
|
55
|
+
* `command`: The command to execute in the container
|
56
|
+
* `timeout`: Maximum seconds to spend on each docker call (default: 10)
|
57
57
|
|
58
58
|
The function `donce_host()` returns the hostname of the host machine that
|
59
59
|
can be used from within the container.
|
data/Rakefile
CHANGED
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
|
@@ -82,7 +97,7 @@ module Kernel
|
|
82
97
|
a = [
|
83
98
|
"--tag #{i}",
|
84
99
|
build_args.map { |k, v| "--build-arg #{Shellwords.escape("#{k}=#{v}")}" }.join(' ')
|
85
|
-
].join(' ')
|
100
|
+
].compact.join(' ')
|
86
101
|
if dockerfile
|
87
102
|
Dir.mktmpdir do |tmp|
|
88
103
|
dockerfile = dockerfile.join("\n") if dockerfile.is_a?(Array)
|
@@ -97,23 +112,23 @@ 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
131
|
begin
|
104
|
-
cmd = [
|
105
|
-
docker, 'run',
|
106
|
-
block_given? ? '--detach' : nil,
|
107
|
-
'--name', Shellwords.escape(container),
|
108
|
-
OS.linux? ? nil : "--add-host #{donce_host}:host-gateway",
|
109
|
-
args,
|
110
|
-
env.map { |k, v| "--env #{Shellwords.escape("#{k}=#{v}")}" }.join(' '),
|
111
|
-
ports.map { |k, v| "--publish #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
|
112
|
-
volumes.map { |k, v| "--volume #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
|
113
|
-
root ? nil : "--user=#{Shellwords.escape("#{Process.uid}:#{Process.gid}")}",
|
114
|
-
Shellwords.escape(img),
|
115
|
-
command
|
116
|
-
].compact.join(' ')
|
117
132
|
stdout, code =
|
118
133
|
Timeout.timeout(timeout) do
|
119
134
|
qbash(
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: donce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-04-
|
10
|
+
date: 2025-04-22 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: backtrace
|