Last active
November 10, 2022 18:37
-
-
Save mtrense/f325e04b291388bbb69f to your computer and use it in GitHub Desktop.
Dynamically create Rake tasks for all Dockerfiles (following the convention "<name>.Dockerfile") in the current directory
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
require 'rake/file_list' | |
IMAGES = Rake::FileList['*.Dockerfile'].collect {|f| f[/.+(?=\.Dockerfile)/] } | |
namespace :images do | |
IMAGES.each do |name| | |
desc "Build image '#{name}'" | |
task "build_#{name}" do | |
sh "docker build -f #{name}.Dockerfile -t mtrense/#{name} ." | |
end | |
end | |
desc 'Build all images' | |
task build_all: IMAGES.collect {|i| "build_#{i}" } | |
end | |
desc 'Build all images' | |
task default: 'images:build_all' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment