Skip to content

Instantly share code, notes, and snippets.

@tegud
Last active September 3, 2015 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tegud/ac1ecf1654bf781f9b34 to your computer and use it in GitHub Desktop.
Save tegud/ac1ecf1654bf781f9b34 to your computer and use it in GitHub Desktop.
Rake Build Image
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