Last active
September 3, 2015 19:54
-
-
Save tegud/ac1ecf1654bf781f9b34 to your computer and use it in GitHub Desktop.
Rake Build Image
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
task :build_image do | |
name = ENV['IMAGE_NAME'] || raise('You must specify an IMAGE_NAME') | |
tag = ENV['GO_PIPELINE_LABEL'] || raise('No label specified') | |
docker_hub_user_or_registry = ENV['DOCKER_REGISTRY'] || ENV['DOCKER_HUB_USER'] || raise('No registry or docker hub user specified') | |
docker_file_location = ENV['DOCKER_FILE_LOCATION'] || "." | |
full_image_id = "#{docker_hub_user_or_registry}/#{name}:#{tag}" | |
Dir.chdir("../../#{docker_file_location}") | |
sh "sudo docker build -t #{full_image_id} ." | |
sh "sudo docker push #{full_image_id}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment