Sha256: 8bd30c9723c8141036098b46352c4066fe8fe104d43cb08618d6461add3a521d

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

require "rake"
require "fileutils"
require "dtc_rake/config"
require "dtc_rake/product"
require "dtc_rake/ui"
require "dtc_rake/util"

include DtcRake::UI
product = DtcRake::Product.instance

def build_dockerfiles(product)
  begin
    require "zip"
  rescue LoadError
    error "Gem rubyzip is not available. In order to use this task, you must: gem install rubyzip"
  end

  announce "Building Dockerfiles pack"

  output_dir = DtcRake::Config.instance.output_dir
  base_name = File.basename(product.dockerfiles_file_name, ".zip")
  tmp_dir = File.join(output_dir, base_name)
  FileUtils.rm_rf tmp_dir if File.directory? tmp_dir
  FileUtils.mkdir_p tmp_dir

  %w[
    ../docker
  ].each do |dir|
    FileUtils.cp_r dir, tmp_dir
  end

  archive = File.join(output_dir, product.dockerfiles_file_name)
  info "Creating #{archive}"
  FileUtils.rm_f archive
  Zip::File.open(archive, "w") do |zip|
    Dir["#{tmp_dir}/**/**"].reject { |f| f == archive }.each do |file|
      zip.add(file.sub("#{tmp_dir}/", ""), file)
    end
  end

  FileUtils.rm_rf tmp_dir
end

if product.has_dockerfiles
  namespace :build do
    desc "Builds pack with Dockerfiles"
    task :dockerfiles do
      build_dockerfiles(product)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dtc_rake-1.2.1 lib/tasks/build_dockerfiles.rake
dtc_rake-1.2.0 lib/tasks/build_dockerfiles.rake
dtc_rake-1.1.0 lib/tasks/build_dockerfiles.rake
dtc_rake-1.0.0 lib/tasks/build_dockerfiles.rake
dtc_rake-1.0.0.pre.beta.2 lib/tasks/build_dockerfiles.rake
dtc_rake-1.0.0.pre.beta.1 lib/tasks/build_dockerfiles.rake
dtc_rake-0.2.0 lib/tasks/build_dockerfiles.rake
dtc_rake-0.1.2 lib/tasks/build_dockerfiles.rake
dtc_rake-0.1.0 lib/tasks/build_dockerfiles.rake