lib/jarl/application.rb in jarl-0.4.0 vs lib/jarl/application.rb in jarl-0.5.0

- old
+ new

@@ -1,8 +1,8 @@ module Jarl class Application - attr_reader :group, :name, :hostname + attr_reader :group, :name, :hostname, :base_path attr_reader :image, :volumes, :ports, :environment, :entrypoint, :command attr_reader :serial # Create Application object from application definition: # @@ -12,13 +12,14 @@ # - /host/path:/container/path # ports: # - 1234:5678 # command: blabla # - def initialize(group, name, params) + def initialize(group, name, params, base_path) @group = group @name = name + @base_path = base_path @image = params['image'] || fail("Application '#{self}' has no 'image' defined") unless @image.is_a?(String) fail "Application '#{self}' has invalid 'image' definition, String is expected" end @volumes = params['volumes'] || [] @@ -90,19 +91,22 @@ fail 'Not a running application' unless running? instances.first.ssh end def build - fail 'Not a file based image' unless image_is_a_path? - Docker::Image.new(image_name, image_path).build! + Docker::Image.new(image_name, image_full_path).build! end def image_name image_is_a_path? ? File.basename(image) : image end def image_path image_is_a_path? ? image : nil + end + + def image_full_path + image_is_a_path? ? Pathname.new(base_path).join(image).expand_path : nil end def to_s full_name end