Sha256: 1a977ef5361183405791210d98e7d64fd6314583d4b085848a99418bec398d32
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
module Percheron module Actions module Base def base_dir container.dockerfile.dirname.to_s end def in_working_directory(new_dir) old_dir = Dir.pwd Dir.chdir(new_dir) yield ensure Dir.chdir(old_dir) end def now_timestamp Time.now.strftime('%Y%m%d%H%M%S') end def insert_files!(files) files.each do |file| file = Pathname.new(File.expand_path(file, base_dir)) container.image.insert_local('localPath' => file.to_s, 'outputPath' => "/tmp/#{file.basename}").tap do |new_image| new_image.tag(repo: container.name, tag: container.version.to_s, force: true) end end end def stop_containers!(containers) exec_on_containers!(containers) do |container| Stop.new(container).execute! if container.running? end end def start_containers!(containers) exec_on_containers!(containers) do |container| Start.new(container, container.dependant_containers.values).execute! unless container.running? end end def exec_on_containers!(containers) containers.inject([]) do |all, container| all << container if yield(container) all end.compact end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
percheron-0.6.1 | lib/percheron/actions/base.rb |
percheron-0.6.0 | lib/percheron/actions/base.rb |