# HG changeset patch # User edogawaconan # Date 1407139516 -32400 # Node ID 56382cb104dd76e308e6762abe459af111723785 # Parent 5ac9232641294026eeddfaa75f920554388fc0e2 Add support for environment variable-based deployment. diff -r 5ac923264129 -r 56382cb104dd config/application.rb --- a/config/application.rb Thu Jul 03 15:22:24 2014 +0900 +++ b/config/application.rb Mon Aug 04 17:05:16 2014 +0900 @@ -1,5 +1,8 @@ require File.expand_path("../boot", __FILE__) +# To allow setting environment variable ZP_DATABASE_URL instead of DATABASE_URL. +ENV["DATABASE_URL"] = ENV["ZP_DATABASE_URL"] if ENV["ZP_DATABASE_URL"] + require "active_record/railtie" require "action_controller/railtie" # require "action_mailer/railtie" @@ -8,7 +11,7 @@ require "rails/test_unit/railtie" require File.expand_path("../init_config", __FILE__) -require File.expand_path("../local_config", __FILE__) +suppress(LoadError) { require File.expand_path("../local_config", __FILE__) } require File.expand_path("../default_config", __FILE__) # Pick the frameworks you want: diff -r 5ac923264129 -r 56382cb104dd config/default_config.rb --- a/config/default_config.rb Thu Jul 03 15:22:24 2014 +0900 +++ b/config/default_config.rb Mon Aug 04 17:05:16 2014 +0900 @@ -3,3 +3,6 @@ CONFIG["bundler_groups"] ||= [:default, Rails.env] CONFIG["bundler_groups"] << "standalone" if CONFIG["standalone"] CONFIG["bundler_groups"] << "newrelic" if CONFIG["newrelic"] + +CONFIG["secret_key"] ||= ENV["ZP_SECRET_KEY"] if ENV["ZP_SECRET_KEY"] +CONFIG["newrelic"] = (ENV["ZP_NEWRELIC"] == 1) if ENV["ZP_NEWRELIC"] diff -r 5ac923264129 -r 56382cb104dd config/local_config.rb.example --- a/config/local_config.rb.example Thu Jul 03 15:22:24 2014 +0900 +++ b/config/local_config.rb.example Mon Aug 04 17:05:16 2014 +0900 @@ -1,6 +1,7 @@ # Required: generate with `bundle exec secret` # # CONFIG['secret_key'] = 'FILL_IN_HERE' +# Or set environment variable ZP_SECRET_KEY # Set to false if you want to use different web server (e.g. passenger) # Default is set to use standalone server: @@ -12,3 +13,7 @@ # Don't forget to put your newrelic.yml in config directory. # Default: false # CONFIG['newrelic'] = false +# Or set environment variable ZP_NEWRELIC to 1 +# + +# If you want to deploy with just environment variable, also set ZP_DATABASE_URL or DATABASE_URL.