Sha256: 311a128efe4660578544e721957978f89a612e7f9751aa7f9ec2aa1494c477b2
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
#!/usr/bin/env ruby # Configure like so: # dockerfile: |- # RUN apk add --no-cache build-base git # RUN gem install gem_hadar bundler # # script: &script |- # ruby -v # rake test # # images: # ruby:3.0-alpine: *script # ruby:2.7-alpine: *script # ruby:2.6-alpine: *script # ruby:2.5-alpine: *script # ruby:2.4-alpine: *script # ruby:2.3-alpine: *script require 'yaml' require 'tmpdir' require 'fileutils' include FileUtils alias sh system dockerfile: |- RUN apk add --no-cache build-base git RUN gem install gem_hadar bundler script: &script |- ruby -v rake test images: ruby:3.0-alpine: *script ruby:2.7-alpine: *script ruby:2.6-alpine: *script ruby:2.5-alpine: *script ruby:2.4-alpine: *script ruby:2.3-alpine: *script def provide_image(image, dockerfile) tag = "all_images/#{image}" sh "docker pull '#{image}'" build_dir = File.join(Dir.tmpdir, 'build') mkdir_p build_dir cd build_dir do File.open('Dockerfile', 'w') do |t| t.puts <<~end FROM #{image} WORKDIR /work #{dockerfile} end end sh "docker build -t '#{tag}' ." end tag ensure rm_rf File.join(Dir.tmpdir, 'build') end def red(string) "\e[31m#{string}\e[0m" end def green(string) "\e[32m#{string}\e[0m" end config = YAML.load_file(ARGV.shift || '.all_images.yml') dockerfile = config['dockerfile'].to_s Array(config['images']).each do |image, script| tag = provide_image image, dockerfile if sh "docker run --name all_images -v `pwd`:/work '#{tag}' sh -c '#{script}'" puts green('SUCCESS') else puts red('FAILURE') end ensure sh 'docker rm -f all_images >/dev/null' end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
utils-0.24.0 | bin/all_images |