From 43ce16a6dc667217c6cb1fa61e3af17d2c16bede Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Tue, 8 Oct 2013 13:52:29 +0100 Subject: [PATCH 1/4] Add script to install mandatory config files from their .sample version. --- packaging/debian/setup.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 packaging/debian/setup.sh diff --git a/packaging/debian/setup.sh b/packaging/debian/setup.sh new file mode 100755 index 00000000000..3309113c7f4 --- /dev/null +++ b/packaging/debian/setup.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# This script installs the required example config files before buildpack compilation. + +set -ex + +cp config/database.yml.production-sample config/database.yml +cp config/redis.yml.sample config/redis.yml From a2fa70ab5c2e5b05a352fff86565ea27b89feee8 Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Tue, 8 Oct 2013 14:45:32 +0100 Subject: [PATCH 2/4] Standardize on 'worker' for sidekiq Procfile entry (expected by buildpack). --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index 54e13c77f06..4d752a6c18c 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ web: bundle exec rails server -p $PORT -sidekiq: bundle exec sidekiq -e $RAILS_ENV \ No newline at end of file +worker: bundle exec sidekiq -e $RAILS_ENV \ No newline at end of file From 4f32b8a9ae1ab1790da955490d06b2d101d0ca43 Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Tue, 8 Oct 2013 15:20:57 +0100 Subject: [PATCH 3/4] Copy default production.rb file. --- packaging/debian/setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/debian/setup.sh b/packaging/debian/setup.sh index 3309113c7f4..72afe2d6c08 100755 --- a/packaging/debian/setup.sh +++ b/packaging/debian/setup.sh @@ -5,3 +5,4 @@ set -ex cp config/database.yml.production-sample config/database.yml cp config/redis.yml.sample config/redis.yml +cp config/environments/production.rb.sample config/environments/production.rb From a7b8481c8f8675d13f47fa88bb6c941800ee11b1 Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Tue, 8 Oct 2013 15:48:57 +0100 Subject: [PATCH 4/4] Allow to set SMTP settings via environment variable. --- config/environments/production.rb.sample | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/config/environments/production.rb.sample b/config/environments/production.rb.sample index c12b534dd2a..ef934d5e72c 100644 --- a/config/environments/production.rb.sample +++ b/config/environments/production.rb.sample @@ -40,8 +40,27 @@ Discourse::Application.configure do # :authentication => 'plain', # :enable_starttls_auto => true } - config.action_mailer.delivery_method = :sendmail - config.action_mailer.sendmail_settings = {arguments: '-i'} + if ENV.key?('SMTP_URL') + config.action_mailer.smtp_settings = begin + uri = URI.parse(ENV['SMTP_URL']) + params = { + :address => uri.host, + :port => uri.port, + :domain => (uri.path || "").split("/")[1], + :user_name => uri.user, + :password => uri.password, + :authentication => 'plain', + :enable_starttls_auto => true + } + CGI.parse(uri.query || "").each {|k,v| params[k.to_sym] = v.first} + params + rescue + raise "Invalid SMTP_URL" + end + else + config.action_mailer.delivery_method = :sendmail + config.action_mailer.sendmail_settings = {arguments: '-i'} + end # Send deprecation notices to registered listeners config.active_support.deprecation = :notify