Sha256: 376098e1e5ea548b12adf7cfcea2adbcf997d8010d85a419f184c3db15c951d6
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 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| if container.running? $logger.debug "Stopping '#{container.name}' container" Stop.new(container).execute! end end end def start_containers!(containers, exec_scripts: true) exec_on_containers!(containers) do |container| unless container.running? $logger.debug "Starting '#{container.name}' container" Start.new(container, dependant_containers: container.dependant_containers.values, exec_scripts: exec_scripts).execute! end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
percheron-0.6.4 | lib/percheron/actions/base.rb |