Class: Rockstart::DeploymentGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Generators::ClassOptionHelpers, Generators::TemplateHelpers
Defined in:
lib/generators/rockstart/deployment/deployment_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_rack_deflaterObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/generators/rockstart/deployment/deployment_generator.rb', line 39

def add_rack_deflater
  application do
    <<~RACK_DEFLATER
      if ENV["RAILS_SERVE_STATIC_FILES"].present?
        config.middleware.insert_after ActionDispatch::Static, Rack::Deflater
        config.static_cache_control = "public, max-age=\#{2.days.to_i}"
      else
        config.middleware.insert_after Rack::Sendfile, Rack::Deflater
      end
    RACK_DEFLATER
  end
end

#add_rack_deflater_specObject



52
53
54
# File 'lib/generators/rockstart/deployment/deployment_generator.rb', line 52

def add_rack_deflater_spec
  copy_file "rack_deflater_spec.rb", "spec/requests/rack_deflater_spec.rb"
end

#configure_environmentObject



20
21
22
23
24
25
26
27
# File 'lib/generators/rockstart/deployment/deployment_generator.rb', line 20

def configure_environment
  application(nil, env: :production) do
    <<~APP_HOST
      config.action_controller.default_url_options = { host: ENV["APP_HOST"] }
      config.action_controller.asset_host = ENV.fetch("ASSET_HOST") { ENV["APP_HOST"] }
    APP_HOST
  end
end

#create_deployment_scriptsObject



34
35
36
37
# File 'lib/generators/rockstart/deployment/deployment_generator.rb', line 34

def create_deployment_scripts
  script_template "hooks-postdeploy"
  script_template "hooks-release"
end

#create_run_scriptsObject



29
30
31
32
# File 'lib/generators/rockstart/deployment/deployment_generator.rb', line 29

def create_run_scripts
  script_template "web"
  script_template "worker" if sidekiq?
end

#generate_dockerObject



69
70
71
72
73
74
75
76
77
# File 'lib/generators/rockstart/deployment/deployment_generator.rb', line 69

def generate_docker
  generate "rockstart:deployment:docker",
           devise_option,
           frontend_option,
           memcached_option,
           postgres_option,
           rollbar_option,
           sidekiq_option
end

#generate_herokuObject



60
61
62
63
64
65
66
67
# File 'lib/generators/rockstart/deployment/deployment_generator.rb', line 60

def generate_heroku
  generate "rockstart:deployment:heroku",
           auth0_option,
           memcached_option,
           postgres_option,
           rollbar_option,
           sidekiq_option
end

#generate_nginxObject



56
57
58
# File 'lib/generators/rockstart/deployment/deployment_generator.rb', line 56

def generate_nginx
  generate "rockstart:deployment:nginx"
end