class Dockerfile::Split
Public Class Methods
new(xmlfile='dockerfiles.xml', repository: 'myrepo', filepath: '.' , base_image: nil)
click to toggle source
# File lib/dockerfilemerge.rb, line 194 def initialize(xmlfile='dockerfiles.xml', repository: 'myrepo', filepath: '.' , base_image: nil) @repository, @filepath, @xmlfile = repository, filepath, xmlfile @base_image = base_image end
Public Instance Methods
make()
click to toggle source
# File lib/dockerfilemerge.rb, line 202 def make() s = File.read(@xmlfile) doc = Rexle.new(s) a = doc.root.xpath('//dockerfile') a.each.with_index do |entry, i| filename = entry.attributes[:id] path2 = File.join(@filepath, filename) FileUtils.mkdir path2 File.write File.join(path2, 'Dockerfile'), entry.texts.join.strip\ .sub(/<base_image>/, @base_image) s = "sudo docker build -t %s/%s ." % [@repository, filename] File.write build_path=File.join(path2, 'build.sh'), s FileUtils.chmod_R 0755, build_path if i == 0 then builds = "sudo build.sh && " + a[1..-1].map \ {|x| "cd ../%s && sudo build.sh" % x.attributes[:id] }.join(" && ") File.write buildall_path=File.join(path2, 'buildall.sh'), builds FileUtils.chmod_R 0755, buildall_path end end end