all_images 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a916b304f50949d5046c42b262eda706dc71435efcd94d2a12c86580a112aa8a
4
+ data.tar.gz: 361fd26f88d4bbd058b7a74fabf4072cf01483b7b4ae1daea9383ebcd0f68d3e
5
+ SHA512:
6
+ metadata.gz: 15e62d247684491d4a2ac8795892ab330bec6f08a18ca39d2074a379d5427f0ce0d87250d0d05b07373c25552aebefe76000c948422da139892d1ecd1d5dcd5c
7
+ data.tar.gz: a95b892a16e86c525bf731ee8b0362fc2dffee5a48de4cbeeb6bd28b0c7a7ac05100553604d9238ac5d416d0491bd867425700c06691ecfc9ff84ec2e26bfe75
data/.utilsrc ADDED
@@ -0,0 +1,30 @@
1
+ # vim: set ft=ruby:
2
+
3
+ search do
4
+ prune_dirs /\A(\.svn|\.git|CVS|tmp|tags|coverage|pkg)\z/
5
+ skip_files /(\A\.|\.sw[pon]\z|\.(log|fnm|jpg|jpeg|png|pdf|svg)\z|tags|~\z)/i
6
+ end
7
+
8
+ discover do
9
+ prune_dirs /\A(\.svn|\.git|CVS|tmp|tags|coverage|pkg)\z/
10
+ skip_files /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
11
+ binary false
12
+ end
13
+
14
+ strip_spaces do
15
+ prune_dirs /\A(\..*|CVS|pkg)\z/
16
+ skip_files /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
17
+ end
18
+
19
+ probe do
20
+ test_framework :rspec
21
+ #include_dirs 'features'
22
+ end
23
+
24
+ classify do
25
+ shift_path_by_default 1
26
+ end
27
+
28
+ ssh_tunnel do
29
+ terminal_multiplexer :tmux
30
+ end
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # vim: set filetype=ruby et sw=2 ts=2:
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # AllImages - Runs a script in all of the docker images
2
+
3
+ ## Description
4
+
5
+ Run with
6
+
7
+ ```
8
+ $ all_images
9
+ ```
10
+
11
+ Configure the generated `.all_images.yml` configuration file and run it again.
12
+
13
+ Also supports more than one configuration via
14
+
15
+ ```
16
+ $ all_images other_configuration.yml
17
+ ```
18
+
19
+ ## Author
20
+
21
+ Florian Frank mailto:flori@ping.de
22
+
23
+ ## License
24
+
25
+ This software is licensed under the X11 (or MIT) license:
26
+ http://www.xfree86.org/3.3.6/COPYRIGHT2.html#3
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ # vim: set filetype=ruby et sw=2 ts=2:
2
+
3
+ require 'gem_hadar'
4
+
5
+ GemHadar do
6
+ name 'all_images'
7
+ author 'Florian Frank'
8
+ email 'flori@ping.de'
9
+ homepage "http://github.com/flori/#{name}"
10
+ summary 'Runs a script in all of the docker images'
11
+ description 'A script that runs a script in all of the configured docker images'
12
+ test_dir 'spec'
13
+ ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', 'coverage',
14
+ '.AppleDouble', 'tags', '.byebug_history', '.DS_Store'
15
+ readme 'README.md'
16
+ title "#{name.camelize} -- #{summary}"
17
+ package_ignore '.all_images.yml', '.gitignore', 'VERSION'
18
+
19
+ required_ruby_version '>= 2.5'
20
+ dependency 'tins', '~>1.0'
21
+ dependency 'term-ansicolor'
22
+ development_dependency 'rake'
23
+ development_dependency 'simplecov'
24
+ development_dependency 'rspec'
25
+ licenses << 'MIT'
26
+ executables << 'all_images'
27
+ end
@@ -0,0 +1,44 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # stub: all_images 0.0.0 ruby lib
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "all_images".freeze
6
+ s.version = "0.0.0"
7
+
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
+ s.require_paths = ["lib".freeze]
10
+ s.authors = ["Florian Frank".freeze]
11
+ s.date = "2022-05-14"
12
+ s.description = "A script that runs a script in all of the configured docker images".freeze
13
+ s.email = "flori@ping.de".freeze
14
+ s.executables = ["all_images".freeze]
15
+ s.extra_rdoc_files = ["README.md".freeze, "lib/all_images.rb".freeze, "lib/all_images/app.rb".freeze, "lib/all_images/config.rb".freeze, "lib/all_images/version.rb".freeze]
16
+ s.files = [".utilsrc".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "all_images.gemspec".freeze, "bin/all_images".freeze, "lib/all_images.rb".freeze, "lib/all_images/app.rb".freeze, "lib/all_images/config.rb".freeze, "lib/all_images/version.rb".freeze, "spec/spec_helper.rb".freeze]
17
+ s.homepage = "http://github.com/flori/all_images".freeze
18
+ s.licenses = ["MIT".freeze]
19
+ s.rdoc_options = ["--title".freeze, "AllImages -- Runs a script in all of the docker images".freeze, "--main".freeze, "README.md".freeze]
20
+ s.required_ruby_version = Gem::Requirement.new(">= 2.5".freeze)
21
+ s.rubygems_version = "3.3.13".freeze
22
+ s.summary = "Runs a script in all of the docker images".freeze
23
+ s.test_files = ["spec/spec_helper.rb".freeze]
24
+
25
+ if s.respond_to? :specification_version then
26
+ s.specification_version = 4
27
+ end
28
+
29
+ if s.respond_to? :add_runtime_dependency then
30
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.12.0"])
31
+ s.add_development_dependency(%q<rake>.freeze, [">= 0"])
32
+ s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
33
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
34
+ s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.0"])
35
+ s.add_runtime_dependency(%q<term-ansicolor>.freeze, [">= 0"])
36
+ else
37
+ s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.12.0"])
38
+ s.add_dependency(%q<rake>.freeze, [">= 0"])
39
+ s.add_dependency(%q<simplecov>.freeze, [">= 0"])
40
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
41
+ s.add_dependency(%q<tins>.freeze, ["~> 1.0"])
42
+ s.add_dependency(%q<term-ansicolor>.freeze, [">= 0"])
43
+ end
44
+ end
data/bin/all_images ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'all_images'
4
+
5
+ exit AllImages::App.new(ARGV).run
@@ -0,0 +1,74 @@
1
+ require 'term/ansicolor'
2
+ require 'tmpdir'
3
+ require 'fileutils'
4
+
5
+ class AllImages::App
6
+ include Term::ANSIColor
7
+ include FileUtils
8
+
9
+ alias sh system
10
+
11
+ def initialize(args)
12
+ @args = args.dup
13
+ end
14
+
15
+ def run
16
+ result = 0
17
+ @config = load_config or return 23
18
+ dockerfile = @config.fetch('dockerfile').to_s
19
+
20
+ Array(@config['images']).each do |image, script|
21
+ tag = provide_image image, dockerfile
22
+ if sh "docker run --name all_images -v `pwd`:/work '#{tag}' sh -c '#{script}'"
23
+ puts green('SUCCESS')
24
+ else
25
+ puts red('FAILURE')
26
+ result |= 1
27
+ end
28
+ ensure
29
+ sh 'docker rm -f all_images >/dev/null'
30
+ end
31
+ result
32
+ end
33
+
34
+ private
35
+
36
+ def load_config
37
+ config_filename = '.all_images.yml'
38
+ if @args.empty?
39
+ unless File.exist?(config_filename)
40
+ AllImages::Config.init(config_filename)
41
+ puts bold("Config file #{config_filename} not found!\n\n") +
42
+ "The following example was created, adapt to your own needs:\n\n",
43
+ AllImages::Config.example, ""
44
+ return
45
+ end
46
+ else
47
+ config_filename = @args.shift
48
+ end
49
+ AllImages::Config.load(config_filename)
50
+ end
51
+
52
+ def provide_image(image, dockerfile)
53
+ prefix = @config.fetch('prefix', File.basename(Dir.pwd))
54
+ tag = "#{prefix}/all_images/#{image}"
55
+ sh "docker pull '#{image}'"
56
+ build_dir = File.join(Dir.tmpdir, 'build')
57
+ mkdir_p build_dir
58
+ cd build_dir do
59
+ File.open('Dockerfile', 'w') do |t|
60
+ t.puts <<~end
61
+ FROM #{image}
62
+
63
+ WORKDIR /work
64
+
65
+ #{dockerfile}
66
+ end
67
+ end
68
+ sh "docker build --pull -t '#{tag}' ."
69
+ end
70
+ tag
71
+ ensure
72
+ rm_rf File.join(Dir.tmpdir, 'build')
73
+ end
74
+ end
@@ -0,0 +1,40 @@
1
+ require 'yaml'
2
+
3
+ module AllImages::Config
4
+ def load(filename)
5
+ YAML.load_file(filename)
6
+ end
7
+
8
+ EXAMPLE = <<~end
9
+ dockerfile: |-
10
+ RUN apk add --no-cache build-base git
11
+ RUN gem update --system
12
+ RUN gem install gem_hadar bundler
13
+
14
+ script: &script |-
15
+ echo -e "\\e[1m"
16
+ ruby -v
17
+ bundle
18
+ echo -e "\\e[0m"
19
+ rake test
20
+
21
+ images:
22
+ ruby:3.1-alpine: *script
23
+ ruby:3.0-alpine: *script
24
+ ruby:2.7-alpine: *script
25
+ ruby:2.6-alpine: *script
26
+ ruby:2.5-alpine: *script
27
+ end
28
+
29
+ def init(filename)
30
+ File.open(filename, 'w') do |output|
31
+ output.print EXAMPLE
32
+ end
33
+ end
34
+
35
+ def example
36
+ EXAMPLE
37
+ end
38
+
39
+ extend self
40
+ end
@@ -0,0 +1,8 @@
1
+ module AllImages
2
+ # AllImages version
3
+ VERSION = '0.0.0'
4
+ VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
+ VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
+ VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
7
+ VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
8
+ end
data/lib/all_images.rb ADDED
@@ -0,0 +1,6 @@
1
+ module AllImages
2
+ end
3
+
4
+ require 'all_images/version'
5
+ require 'all_images/app'
6
+ require 'all_images/config'
@@ -0,0 +1,12 @@
1
+ if ENV['START_SIMPLECOV'].to_i == 1
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter "#{File.basename(File.dirname(__FILE__))}/"
5
+ end
6
+ end
7
+ require 'rspec'
8
+ begin
9
+ require 'byebug'
10
+ rescue LoadError
11
+ end
12
+ require 'all_images'
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: all_images
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Florian Frank
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-05-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gem_hadar
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.12.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.12.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: tins
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: term-ansicolor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A script that runs a script in all of the configured docker images
98
+ email: flori@ping.de
99
+ executables:
100
+ - all_images
101
+ extensions: []
102
+ extra_rdoc_files:
103
+ - README.md
104
+ - lib/all_images.rb
105
+ - lib/all_images/app.rb
106
+ - lib/all_images/config.rb
107
+ - lib/all_images/version.rb
108
+ files:
109
+ - ".utilsrc"
110
+ - Gemfile
111
+ - README.md
112
+ - Rakefile
113
+ - all_images.gemspec
114
+ - bin/all_images
115
+ - lib/all_images.rb
116
+ - lib/all_images/app.rb
117
+ - lib/all_images/config.rb
118
+ - lib/all_images/version.rb
119
+ - spec/spec_helper.rb
120
+ homepage: http://github.com/flori/all_images
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options:
126
+ - "--title"
127
+ - AllImages -- Runs a script in all of the docker images
128
+ - "--main"
129
+ - README.md
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '2.5'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubygems_version: 3.3.13
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Runs a script in all of the docker images
147
+ test_files:
148
+ - spec/spec_helper.rb