class Njord::DockerHandler
Public Class Methods
build_images()
click to toggle source
# File lib/njord/docker_handler.rb, line 6 def build_images Njord.config.images.each do |image_config| execute("docker build #{build_args(image_config)}-t #{image_config.image_name}:#{image_tag(image_config)}" \ " -f #{image_config.dockerfile} .") end end
push_images()
click to toggle source
# File lib/njord/docker_handler.rb, line 20 def push_images Njord.config.images.each do |image_config| execute("docker push #{image_config.docker_repo}/#{image_config.image_name}:#{image_tag(image_config)}") execute("docker push #{image_config.docker_repo}/#{image_config.image_name}:latest") end end
tag_images()
click to toggle source
# File lib/njord/docker_handler.rb, line 13 def tag_images Njord.config.images.each do |image_config| execute("docker tag #{image_config.image_name}:#{image_tag(image_config)} #{image_config.docker_repo}/#{image_config.image_name}:#{image_tag(image_config)}") execute("docker tag #{image_config.image_name}:#{image_tag(image_config)} #{image_config.docker_repo}/#{image_config.image_name}:latest") end end
Private Class Methods
build_args(image_config)
click to toggle source
# File lib/njord/docker_handler.rb, line 45 def build_args(image_config) image_config.build_args && image_config.build_args.collect{ |x| "--build-arg #{x} " }.join("") end
execute(cmd)
click to toggle source
# File lib/njord/docker_handler.rb, line 28 def execute(cmd) puts "Executing #{cmd}" raise RuntimeError unless system(cmd, out: $stdout, err: :out) end
image_tag(image_config)
click to toggle source
# File lib/njord/docker_handler.rb, line 33 def image_tag(image_config) case image_config.tagging when :sem_ver then "" # TODO else image_tag_via_git end end
image_tag_via_git()
click to toggle source
# File lib/njord/docker_handler.rb, line 41 def image_tag_via_git `git rev-parse --short HEAD`.strip end