Class: Dockerb::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/dockerb.rb

Class Method Summary collapse

Class Method Details

.bundleObject



39
40
41
42
43
44
45
46
# File 'lib/dockerb.rb', line 39

def bundle
  <<-EOF.gsub(/^          /, "")
    ADD Gemfile /app/
    ADD Gemfile.lock /app/
    ADD vendor/cache /app/vendor/cache
    RUN (bundle install --quiet --local --jobs 4 || bundle check) && #{delete_gem_junk}
  EOF
end

.compile(code) ⇒ Object



34
35
36
37
# File 'lib/dockerb.rb', line 34

def compile(code)
  warn = "#{GENERATED.sub('VERSION', Dockerb::VERSION)}\n"
  warn + ERB.new(code).result(binding).strip + "\n" + warn
end

.delete_gem_junkObject



54
55
56
# File 'lib/dockerb.rb', line 54

def delete_gem_junk
  "#{delete_tests} && #{delete_build_files}"
end

.install_gem(name, options = nil) ⇒ Object



48
49
50
51
52
# File 'lib/dockerb.rb', line 48

def install_gem(name, options=nil)
  options = " " << options if options
  version = File.read("Gemfile.lock")[/^    #{name} \((.+)\)/, 1] || raise("Gem #{name} not found in Gemfile.lock")
  "RUN gem install -v #{version} #{name}#{options} && #{delete_gem_junk}"
end