class Vtasks::Docker::Image

Docker Image class

Attributes

has_build_args[R]
image[R]
path[R]
tags[R]

Public Class Methods

new(image, path, args = {}) click to toggle source
# File lib/vtasks/docker/image.rb, line 18
def initialize(image, path, args = {})
  @image          ||= image
  @path           ||= path
  @has_build_args ||= args.fetch(:has_build_args, false)
end

Public Instance Methods

build() click to toggle source

Build image

# File lib/vtasks/docker/image.rb, line 49
def build
  args = {
    build_date: build_date,
    build_tag: build_tag
  }
  build = Vtasks::Docker::Image::Build.new(image, path, args)
  if has_build_args
    build.with_arguments
  else
    build.without_arguments
  end
end
build_date() click to toggle source

Compose build date

# File lib/vtasks/docker/image.rb, line 39
def build_date
  @build_date ||= ::Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
end
build_tag() click to toggle source

Compose build tag

# File lib/vtasks/docker/image.rb, line 44
def build_tag
  @build_tag ||= gitver.to_s
end
build_with_tags() click to toggle source

Build image with tags

# File lib/vtasks/docker/image.rb, line 70
def build_with_tags
  build
  tag
end
push() click to toggle source

Push image

# File lib/vtasks/docker/image.rb, line 76
def push
  tags.each do |tag|
    Vtasks::Docker::Image::Push.new(image, tag)
  end
end
tag() click to toggle source

Tag image

# File lib/vtasks/docker/image.rb, line 63
def tag
  tags.each do |tag|
    Vtasks::Docker::Image::Tag.new(image, build_tag, tag)
  end
end