changeset 355:56382cb104dd

Add support for environment variable-based deployment.
author edogawaconan <me@myconan.net>
date Mon, 04 Aug 2014 17:05:16 +0900
parents 5ac923264129
children cd1c3a28b89a
files config/application.rb config/default_config.rb config/local_config.rb.example
diffstat 3 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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:
--- 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"]
--- 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.