module DockerSigh
Constants
- LOGGER
- VERSION
Public Class Methods
load_tasks(opts)
click to toggle source
# File lib/docker_sigh.rb, line 15 def self.load_tasks(opts) extend Rake::DSL dockerfile_template = Util::template_url(opts) dockerfile = dockerfile_template.gsub("Dockerfile.template.erb", "Dockerfile") namespace :ds do task :template do Util::validate_opts(opts) Util::validate_repo(opts) LOGGER.debug "Beginning 'template' task." template = Erber::Templater.new(IO.read(dockerfile_template), DockerfileMash) IO.write(dockerfile, template.render(Util::generate_template_args(opts))) LOGGER.debug "Ending 'template' task." end task :build do Util::validate_opts(opts) Util::validate_repo(opts) LOGGER.debug "Beginning 'build' task." Dir.chdir(opts[:repository_root]) do name = opts[:container_name] ret = sh "docker build -t '#{name}:working' ." raise "failed to build" unless ret [ Util::repo_current_commit(opts), Util::tag_from_branch_name(opts), Util::repo_current_tags(opts) ].flatten.each do |tag| ret = sh "docker tag --force #{name}:working #{name}:#{tag}" raise "failed to tag with '#{tag}'" unless ret end ret = sh "docker rmi #{name}:working" raise "failed to rmi working tag" unless ret end LOGGER.debug "Ending 'build' task." end task :clean do Util::validate_opts(opts) LOGGER.debug "Beginning 'clean' task." LOGGER.debug "Deleting '#{dockerfile}'." FileUtils.rm_f dockerfile LOGGER.debug "Ending 'clean' task." end task :push do LOGGER.debug "Beginning 'push' task." Dir.chdir(opts[:repository_root]) do name = opts[:container_name] [ Util::repo_current_commit(opts), Util::tag_from_branch_name(opts), Util::repo_current_tags(opts) ].flatten.each do |tag| ret = sh "docker push #{name}:#{tag}" raise "failed to push with tag '#{tag}'" unless ret end end LOGGER.debug "Ending 'push' task." end task :go => [ :template, :build, :clean ] { } end end