Class: LambdaLayerCake::RakeHelper
- Inherits:
-
Object
- Object
- LambdaLayerCake::RakeHelper
- Includes:
- Rake::DSL
- Defined in:
- lib/moonbase_alpha/rake_helper.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #build_version ⇒ Object
- #config ⇒ Object
- #docker_build_definitions! ⇒ Object
-
#initialize(root) ⇒ RakeHelper
constructor
A new instance of RakeHelper.
- #latest_tag ⇒ Object
- #repository ⇒ Object
Constructor Details
#initialize(root) ⇒ RakeHelper
Returns a new instance of RakeHelper.
7 8 9 |
# File 'lib/moonbase_alpha/rake_helper.rb', line 7 def initialize(root) @root = root end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
5 6 7 |
# File 'lib/moonbase_alpha/rake_helper.rb', line 5 def root @root end |
Instance Method Details
#build_version ⇒ Object
50 51 52 53 54 55 |
# File 'lib/moonbase_alpha/rake_helper.rb', line 50 def build_version @build_version ||= begin t = Time.now "build-#{t.strftime("%Y-%m-%d-%H-%M-%S")}" end end |
#config ⇒ Object
42 43 44 |
# File 'lib/moonbase_alpha/rake_helper.rb', line 42 def config Rails.configuration.moonbase_alpha end |
#docker_build_definitions! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/moonbase_alpha/rake_helper.rb', line 11 def docker_build_definitions! desc "Build Docker Image" task :build do dockerfile_path = File.(__dir__ + "/../../templates/Dockerfile") raise "Must specify a repository in moonbase_alpha.yml" if repository.blank? tag = "#{repository}:#{build_version}" cmd = %W{docker build -f #{dockerfile_path} --build-arg RUNTIME_VERSION=#{RUBY_VERSION} --build-arg BLDTIME_PKGS=#{config.build_packages.join(" ")} --build-arg RUNTIME_PKGS=#{config.run_packages.join(" ")} --build-arg COMPILE_ASSETS=#{config.compile_assets.to_s} -t #{tag} #{root}} system(*cmd) or raise end desc "Output the last version built" task :latest_tag do puts latest_tag end desc "Output the image name for the latest build" task :latest_image do puts "#{repository}:#{latest_tag}" end end |
#latest_tag ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/moonbase_alpha/rake_helper.rb', line 57 def latest_tag @latest_tag ||= begin cmd = %W{ docker image list --format {{.Tag}} #{repository} } IO.popen(cmd) do |versions| versions.readlines.select {|v| v =~ /\Abuild-/ }.sort.last end end end |
#repository ⇒ Object
46 47 48 |
# File 'lib/moonbase_alpha/rake_helper.rb', line 46 def repository config.repository end |