Created
March 30, 2015 13:39
-
-
Save intinig/06dba9f914cfb94e8c8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :docker do | |
desc "Build docker images" | |
task :build do |t, args| | |
require 'securerandom' | |
images = ENV['IMAGES'] | |
images = images.split "," | |
root = File.expand_path("../../../", __FILE__) | |
filename = File.join(root, "Dockerfile") | |
git_revision = `git rev-parse --short HEAD`.strip | |
dockerfile = File.read(filename) | |
secret_key = SecureRandom.hex(64) | |
dockerfile.gsub!(/ENV GIT_REVISION .*\n/, "ENV GIT_REVISION #{git_revision}\n") | |
dockerfile.gsub!(/ENV SECRET_KEY_BASE .*\n/, "ENV SECRET_KEY_BASE #{secret_key}\n") | |
File.open(filename, "w") {|f| f.puts dockerfile} | |
images.each do |img| | |
path = (img == "app_name") ? root : File.join(root, "container", img) | |
remote_img = (img == "app_name") ? "app_name" : "app_name-#{img}" | |
system "docker build -t 'quay.io/mikamai/#{remote_img}' #{path}" | |
end | |
end | |
desc "Push docker images" | |
task :push do |t, args| | |
images = ENV['IMAGES'] || "rgts" | |
images = images.split "," | |
root = File.expand_path("../../../", __FILE__) | |
images.each do |img| | |
remote_img = (img == "rgts") ? "rgts" : "rgts-#{img}" | |
system "docker push 'quay.io/mikamai/#{remote_img}'" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment