Sha256: b1a79406c9c838e1b3c564f3203969f35e28b506a8b9a1ac859507bfb80910cd
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
#!/usr/bin/env ruby # Configure like so: #dockerfile: |- # RUN apk add --no-cache build-base git # RUN gem update --system # RUN gem install gem_hadar bundler # #script: &script |- # echo -e "\e[1m" # ruby -v # bundle # echo -e "\e[0m" # if 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 def provide_image(image, dockerfile) prefix = $config.fetch('prefix', File.basename(Dir.pwd)) tag = "#{prefix}/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 --pull -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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
utils-0.27.0 | bin/all_images |
utils-0.26.1 | bin/all_images |
utils-0.26.0 | bin/all_images |