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
9
10
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
41
42
43
44
# File 'lib/ruby_yacht/plugins/rails.rb', line 5

def self.load
  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

      environment_variable :app_dependencies, 'RAILS_ENV' do
        @project.rails_environment
      end

      environment_variable :app, 'SECRET_KEY_BASE' do
        @project.rails_secret_key_base
      end
      
      environment_variable :app_dependencies, 'EXCLUDED_GEM_GROUPS' do
        groups = @project.rails_excluded_gem_groups.join(' ')
        groups = '""' if groups == ''
        groups
      end
    end
  end

  RubyYacht.configure do
    add_hooks(server_type: :rails, folder: File.join(File.dirname(__FILE__), 'rails', 'scripts')) do
      during(:install_libraries) { run_script 'install_gems.rb' }
      
      after(:build_checkout) { command 'bundle install --clean' }
      
      during(:load_database_seeds) { run_script 'load_seeds.rb' }

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

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