Module: RubyYacht::Plugins::Rails

Defined in:
lib/ruby_yacht/plugins/rails.rb

Overview

This module provides the plugin for managing Ruby on Rails apps.

Class Method Summary collapse

Class Method Details

.loadObject

This method loads the configuration for the Rails plugin.



5
6
7
8
# File 'lib/ruby_yacht/plugins/rails.rb', line 5

def self.load
  load_server_type
  load_hooks
end

.load_hooksObject

This method loads the configuration for the Rails hooks.



24
25
26
27
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
# File 'lib/ruby_yacht/plugins/rails.rb', line 24

def self.load_hooks
  RubyYacht.configure do
    add_hooks(app_server_type: :rails, container_type: :app, script_folder: File.join(File.dirname(__FILE__), 'rails', 'scripts')) do
      during :initialize_app_environment do
        set_environment_variable 'RAILS_ENV' do
          @project.rails_environment
        end
        set_environment_variable 'SECRET_KEY_BASE' do
          @project.rails_secret_key_base
        end
        set_environment_variable 'EXCLUDED_GEM_GROUPS' do
          groups = @project.rails_excluded_gem_groups.join(' ')
          groups = '""' if groups == ''
          groups
        end
      end
      during(:install_libraries) { run_script :ruby, 'install_gems.rb' }
      
      after(:build_checkout) { command 'bundle install --clean' }
      
      during :load_database_seeds do
        container_type :database
        run_script :ruby, 'load_seeds.rb'
      end
      
      during :build_new_app do
        run_script :ruby, 'build_new_app.rb'
      end

      before(:startup) { run_script :ruby, 'update_rails_config.rb' }
      before(:startup) { run_script :ruby, 'prepare_rails_for_launch.rb' }

      during(:startup) { command 'rails s -b 0.0.0.0 -p $APP_PORT -e $RAILS_ENV' }
    end
  end
end

.load_server_typeObject

This method loads the configuration for the Rails server type.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ruby_yacht/plugins/rails.rb', line 11

def self.load_server_type
  RubyYacht.configure do
    server_type :rails do
      container_type :app
      baseline_image 'ruby:2.3'
      project_attribute name: :environment, default: 'development'
      project_attribute name: :excluded_gem_groups, default: []
      project_attribute name: :secret_key_base
    end
  end
end