Class: Wildcloud::Runner::Builder
- Inherits:
-
Object
- Object
- Wildcloud::Runner::Builder
- Includes:
- Singleton, RubyTemplate, Tools
- Defined in:
- lib/wildcloud/runner/builder.rb,
lib/wildcloud/runner/template/ruby.rb
Instance Method Summary collapse
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #ruby_build(config) ⇒ Object
Methods included from RubyTemplate
Methods included from Tools
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/wildcloud/runner/builder.rb', line 28 def initialize FileUtils.rm_rf('/home/wildcloud') logger.info('Builder', 'Loading build configuration') @buildfile = YAML.load_file('/root/build.yml') logger.info('Builder', 'Cloning git repository') run("git clone #{@buildfile[:repository]} /home/wildcloud 2>&1") logger.info('Builder', 'Changing to application directory') Dir.chdir('/home/wildcloud') logger.info('Builder', 'Loading Cloudfile') @cloudfile = YAML.load_file('Cloudfile') if File.exists?('Cloudfile') @cloudfile ||= {} @cloudfile['templates'] ||= @cloudfile['modules'] if @cloudfile['packages'] logger.info('Builder', 'Installing system packages') packages = @cloudfile['packages'].kind_of?(Array) ? @cloudfile['packages'].join(' ') : @cloudfile['packages'].to_s run("env DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get --force-yes -qyu install #{packages}") end if @cloudfile['templates'].kind_of?(Hash) @cloudfile['templates'].each do |name, config| config ||= {} template = File.("../template/#{name}.rb", __FILE__) if File.exists?(template) logger.info('Builder', "Building template: #{name}") require template send("#{name}_build".to_sym, config) else logger.info('Builder', "Unavailable template: #{name}") end end end logger.info('Builder', 'Ensuring file permissions') FileUtils.chown_R('wildcloud', 'wildcloud', '.') logger.info('Builder', 'Build finished') File.open('/var/build.done', 'w') { |file| file.write('OK') } end |
Instance Method Details
#ruby_build(config) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/wildcloud/runner/template/ruby.rb', line 45 def ruby_build(config) ruby_use(config) if File.exists?('Gemfile') logger.info('Ruby', 'Bundling your gems') run("bundle install --deployment 2>&1") end end |