Commit 427ab3b0a0f9a03c60bb019dc1be28793a284bc4

Authored by Stephen Crosby
1 parent 68de1f34
Exists in master and in 1 other branch production

support environment variable configuration only

- create configurator lib / specs / yardoc
- update readme with env config instructions
- create configuration docs, documenting all configs
- remove copy_configs from rake errbit:bootstrap
- set defaults environment variables in .env.default
- remove mongoid example yaml configs
.env.default 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +ERRBIT_HOST=errbit.example.com
  2 +ERRBIT_PROTOCOL=http
  3 +ERRBIT_ENFORCE_SSL=false
  4 +CONFIRM_RESOLVE_ERR=true
  5 +ERRBIT_CONFIRM_ERR_ACTIONS=true
  6 +ERRBIT_USER_HAS_USERNAME=false
  7 +ERRBIT_USE_GRAVATAR=true
  8 +ERRBIT_GRAVATAR_DEFAULT=identicon
  9 +ALLOW_COMMENTS_WITH_ISSUE_TRACKER=true
  10 +SERVE_STATIC_ASSETS=true
  11 +SECRET_KEY_BASE=f258ed69266dc8ad0ca79363c3d2f945c388a9c5920fc9a1ae99a98fbb619f135001c6434849b625884a9405a60cd3d50fc3e3b07ecd38cbed7406a4fccdb59c
  12 +ERRBIT_EMAIL_FROM='errbit@example.com'
  13 +ERRBIT_EMAIL_AT_NOTICES='[1,10,100]'
  14 +ERRBIT_PER_APP_EMAIL_AT_NOTICES=false
  15 +ERRBIT_NOTIFY_AT_NOTICES='[0]'
  16 +ERRBIT_PER_APP_NOTIFY_AT_NOTICES=false
  17 +MONGO_URL='mongodb://localhost'
  18 +GITHUB_URL='https://github.com'
  19 +GITHUB_AUTHENTICATION=true
  20 +GITHUB_ACCESS_SCOPE='[repo]'
  21 +EMAIL_DELIVERY_METHOD=sendmail
  22 +DEVISE_MODULES='[database_authenticatable,recoverable,rememberable,trackable,validatable,omniauthable]'
... ...
README.md
... ... @@ -121,35 +121,36 @@ gem install bundler
121 121 bundle install
122 122 ```
123 123  
124   - * Bootstrap Errbit. This will copy over config.yml and also seed the database.
  124 + * Bootstrap Errbit. This will seed the database.
125 125  
126 126 ```bash
127 127 rake errbit:bootstrap
128 128 ```
129 129  
130   - * Update the config.yml and mongoid.yml files with information about your environment
131   -
132 130 * Start Server
133 131  
134 132 ```bash
135 133 script/rails server
136 134 ```
137 135  
138   -Deploy Hooks:
  136 +Configuration
  137 +-------------
  138 +Errbit configuration is done entirely through environment variables. See
  139 +[configuration](docs/configuration.md)
  140 +
  141 +Deploy Hooks
139 142 -------------
140 143 Errbit can track your application deploys. See [deploy hooks](docs/deploy-hooks.md)
141 144  
142   -Deployment:
  145 +Deployment
143 146 ----------
144 147 See [notes on deployment](docs/deployment.md)
145 148  
146 149 Authentication
147 150 --------------
148   -
149 151 ### Configuring GitHub authentication:
150   -
151   - * In `config/config.yml`, set `github_authentication` to `true`
152   - * Register your instance of Errbit at: https://github.com/settings/applications
  152 +* Set GITHUB_AUTHENTICATION to true
  153 +* Register your instance of Errbit at https://github.com/settings/applications
153 154  
154 155 If you hosted Errbit at errbit.example.com, you would fill in:
155 156  
... ... @@ -158,19 +159,22 @@ If you hosted Errbit at errbit.example.com, you would fill in:
158 159 <tr><th>Callback URL:</th><td><a href="http://errbit.example.com/users/auth/github">http://errbit.example.com/users/auth/github</a></td></tr>
159 160 </table>
160 161  
161   - * After you have registered your app, set `github_client_id` and `github_secret`
162   - in `config/config.yml` with your app's Client ID and Secret key.
  162 +* After you have registered your app, set GITHUB_CLIENT_ID and GITHUB_SECRET
  163 + with your app's Client ID and Secret key.
163 164  
  165 +When you start your applicatoin, you should see the option to **Sign in with
  166 +GitHub** on the Login page.
164 167  
165   -After you have followed these instructions, you will be able to **Sign in with GitHub** on the Login page.
  168 +You will also be able to link your GitHub profile to your user account on your
  169 +**Edit profile** page.
166 170  
167   -You will also be able to link your GitHub profile to your user account on your **Edit profile** page.
  171 +If you have signed in with GitHub, or linked your GitHub profile, and the App
  172 +has a GitHub repo configured, then you will be able to create issues on GitHub.
  173 +You will still be able to create an issue on the App's configured issue
  174 +tracker.
168 175  
169   -If you have signed in with GitHub, or linked your GitHub profile, and the App has a GitHub repo configured,
170   -then you will be able to create issues on GitHub.
171   -You will still be able to create an issue on the App's configured issue tracker.
172   -
173   -You can change the requested account permissions by setting `github_access_scope` to:
  176 +You can change the requested account permissions by setting
  177 +`GITHUB_ACCESS_SCOPE` to:
174 178  
175 179 <table>
176 180 <tr><th>['repo'] </th><td>Allow creating issues for public and private repos.</td></tr>
... ... @@ -178,56 +182,16 @@ You can change the requested account permissions by setting `github_access_scope
178 182 <tr><th>[] </th><td>No permission to create issues on any repos.</td></tr>
179 183 </table>
180 184  
181   -
182   -### GitHub authentication when served on Heroku
183   -
184   -You will need to set up Heroku variables accordingly as described in [Configuring GitHub authentication](#configuring-github-authentication):
185   -
186   -* GITHUB_AUTHENTICATION
187   -
188   -```bash
189   -heroku config:add GITHUB_AUTHENTICATION=true
190   -```
191   -
192   -* GITHUB_CLIENT_ID
193   -
194   -```bash
195   -heroku config:add GITHUB_CLIENT_ID=the_client_id_provided_by_GitHub
196   -```
197   -
198   -* GITHUB_SECRET
199   -
200   -```bash
201   -heroku config:add GITHUB_SECRET=the_secret_provided_by_GitHub
202   -```
203   -
204   -* GITHUB_ACCESS_SCOPE - set only one scope `repo` or `public_repo`. If you really need to put more than one, separate them with comma.
205   -
206   -```bash
207   -heroku config:add GITHUB_ACCESS_SCOPE=repo,public_repo
208   -```
209   -
210   -* GITHUB_ORG_ID [*optional*] - If set, any user of the specified GitHub Organization can login. If it is their first time, an account will automatically be created for them.
211   -
212   -```bash
213   -heroku config:add GITHUB_ORG_ID=1234567
214   -```
215   -
216   -
217   -__Note__: To avoid restarting your Heroku app 4 times you can set Heroku variables in a single command, i.e:
218   -
219   -```bash
220   -heroku config:add GITHUB_AUTHENTICATION=true \
221   -GITHUB_CLIENT_ID=the_client_id_provided_by_GitHub \
222   -GITHUB_SECRET=the_secret_provided_by_GitHub \
223   -GITHUB_ACCESS_SCOPE=repo,public_repo
224   -```
  185 +* GITHUB_ORG_ID is an optional environment variable you can set to your own
  186 + github organization id. If set, any user of the specified GitHub organization
  187 + can login. If it is their first time, an account will automatically be
  188 + created for them.
225 189  
226 190 ### Configuring LDAP authentication:
227 191  
228   - * In `config/config.yml`, set `user_has_username` to `true`
  192 + * Set `USER_HAS_USERNAME` to `true`
229 193 * Follow the instructions at https://github.com/cschiewek/devise_ldap_authenticatable
230   - to set up the devise_ldap_authenticatable gem.
  194 + to set up the devise_ldap_authenticatable gem.
231 195 * Ensure to set ```config.ldap_create_user = true``` in ```config/initializers/devise.rb```, this enables creating the users from LDAP, otherwhise login will not work.
232 196 * Create a new initializer (e.g. ```config/initializers/devise_ldap.rb```) and add the following code to enable ldap authentication in the User-model:
233 197 ```ruby
... ... @@ -492,10 +456,6 @@ Solutions known to work are listed below:
492 456 </tr>
493 457 </table>
494 458  
495   -## Other documentation
496   -
497   -* [All ENV variables availables to configure Errbit](docs/ENV-VARIABLES.md)
498   -
499 459 TODO
500 460 ----
501 461  
... ... @@ -530,7 +490,7 @@ Contributing to Errbit
530 490 We welcome any contributions. If you need to tweak Errbit for your organization's needs,
531 491 there are probably other users who will appreciate your work.
532 492 Please try to determine whether or not your feature should be **global** or **optional**,
533   -and make **optional** features configurable via `config/config.yml`.
  493 +and make **optional** features configurable via environment variables.
534 494  
535 495 **Examples of optional features:**
536 496  
... ...
config/application.rb
... ... @@ -18,6 +18,18 @@ module Errbit
18 18 # Custom directories with classes and modules you want to be autoloadable.
19 19 config.autoload_paths += [Rails.root.join('lib')]
20 20  
  21 + config.before_initialize do
  22 + # Load up Errbit::Config with values from the environment
  23 + require Rails.root.join('config/load')
  24 +
  25 + config.secret_key_base = Errbit::Config.secret_key_base
  26 + config.serve_static_assets = Errbit::Config.serve_static_assets
  27 + end
  28 +
  29 + initializer "errbit.mongoid", before: "mongoid.load-config" do
  30 + require Rails.root.join('config/mongo')
  31 + end
  32 +
21 33 # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
22 34 # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
23 35 # config.time_zone = 'Central Time (US & Canada)'
... ...
config/cloud/cloud66/deploy_hooks.yml
... ... @@ -1,119 +0,0 @@
1   -production:
2   - after_checkout:
3   - - source: /config/cloud/cloud66/files/Procfile
4   - destination: <%= ENV['RAILS_STACK_PATH'] %>/Procfile
5   - target: rails
6   - run_on: all_servers
7   - - source: /config/cloud/cloud66/files/_load_config.rb
8   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/initializers/_load_config.rb
9   - target: rails
10   - run_on: all_servers
11   - - source: /config/cloud/cloud66/files/config.yml
12   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/config.yml
13   - target: rails
14   - run_on: all_servers
15   - - source: /config/cloud/cloud66/files/mongoid.yml
16   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/mongoid.yml
17   - target: rails
18   - run_on: all_servers
19   - - source: /config/cloud/cloud66/files/seeds.rb
20   - destination: <%= ENV['RAILS_STACK_PATH'] %>/db/seeds.rb
21   - target: rails
22   - run_on: all_servers
23   - - source: /config/cloud/cloud66/files/unicorn.rb.cloud66
24   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/unicorn.rb.cloud66
25   - target: rails
26   - run_on: all_servers
27   - after_rails:
28   - - source: /config/cloud/cloud66/scripts/bundle.sh
29   - destination: /tmp/bundle.sh
30   - target: rails
31   - apply_during: build_only
32   - execute: true
33   - sudo: true
34   - - source: /config/cloud/cloud66/scripts/env_vars.sh
35   - destination: /tmp/env_vars.sh
36   - target: rails
37   - apply_during: build_only
38   - execute: true
39   - sudo: true
40   -staging:
41   - after_checkout:
42   - - source: /config/cloud/cloud66/files/Procfile
43   - destination: <%= ENV['RAILS_STACK_PATH'] %>/Procfile
44   - target: rails
45   - run_on: all_servers
46   - - source: /config/cloud/cloud66/files/_load_config.rb
47   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/initializers/_load_config.rb
48   - target: rails
49   - run_on: all_servers
50   - - source: /config/cloud/cloud66/files/config.yml
51   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/config.yml
52   - target: rails
53   - run_on: all_servers
54   - - source: /config/cloud/cloud66/files/mongoid.yml
55   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/mongoid.yml
56   - target: rails
57   - run_on: all_servers
58   - - source: /config/cloud/cloud66/files/seeds.rb
59   - destination: <%= ENV['RAILS_STACK_PATH'] %>/db/seeds.rb
60   - target: rails
61   - run_on: all_servers
62   - - source: /config/cloud/cloud66/files/unicorn.rb.cloud66
63   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/unicorn.rb.cloud66
64   - target: rails
65   - run_on: all_servers
66   - after_rails:
67   - - source: /config/cloud/cloud66/scripts/bundle.sh
68   - destination: /tmp/bundle.sh
69   - target: rails
70   - apply_during: build_only
71   - execute: true
72   - sudo: true
73   - - source: /config/cloud/cloud66/scripts/env_vars.sh
74   - destination: /tmp/env_vars.sh
75   - target: rails
76   - apply_during: build_only
77   - execute: true
78   - sudo: true
79   - parse: true
80   -development:
81   - after_checkout:
82   - - source: /config/cloud/cloud66/files/Procfile
83   - destination: <%= ENV['RAILS_STACK_PATH'] %>/Procfile
84   - target: rails
85   - run_on: all_servers
86   - - source: /config/cloud/cloud66/files/_load_config.rb
87   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/initializers/_load_config.rb
88   - target: rails
89   - run_on: all_servers
90   - - source: /config/cloud/cloud66/files/config.yml
91   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/config.yml
92   - target: rails
93   - run_on: all_servers
94   - - source: /config/cloud/cloud66/files/mongoid.yml
95   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/mongoid.yml
96   - target: rails
97   - run_on: all_servers
98   - - source: /config/cloud/cloud66/files/seeds.rb
99   - destination: <%= ENV['RAILS_STACK_PATH'] %>/db/seeds.rb
100   - target: rails
101   - run_on: all_servers
102   - - source: /config/cloud/cloud66/files/unicorn.rb.cloud66
103   - destination: <%= ENV['RAILS_STACK_PATH'] %>/config/unicorn.rb.cloud66
104   - target: rails
105   - run_on: all_servers
106   - after_rails:
107   - - source: /config/cloud/cloud66/scripts/bundle.sh
108   - destination: /tmp/bundle.sh
109   - target: rails
110   - apply_during: build_only
111   - execute: true
112   - sudo: true
113   - - source: /config/cloud/cloud66/scripts/env_vars.sh
114   - destination: /tmp/env_vars.sh
115   - target: rails
116   - apply_during: build_only
117   - execute: true
118   - sudo: true
119   - parse: true
config/cloud/cloud66/files/Procfile
... ... @@ -1,2 +0,0 @@
1   -web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
2   -custom_web: bundle exec unicorn_rails -c config/unicorn.rb.cloud66 -E $RAILS_ENV -D
3 0 \ No newline at end of file
config/cloud/cloud66/files/_load_config.rb
... ... @@ -1,82 +0,0 @@
1   -require 'ostruct'
2   -default_config_file = Rails.root.join("config", "config.yml")
3   -
4   -# Allow a Rails Engine to override config by defining it earlier
5   -unless defined?(Errbit::Config)
6   - Errbit::Config = OpenStruct.new
7   -
8   - Errbit::Config.host = ENV['ERRBIT_HOST']
9   - Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM']
10   - # Not really easy to use like an env because need an array and ENV return a string :(
11   - # Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES']
12   - Errbit::Config.confirm_resolve_err = ENV['ERRBIT_CONFIRM_RESOLVE_ERR'].to_i == 0
13   - Errbit::Config.user_has_username = ENV['ERRBIT_USER_HAS_USERNAME'].to_i == 1
14   - Errbit::Config.enforce_ssl = ENV['ERRBIT_ENFORCE_SSL']
15   -
16   - Errbit::Config.use_gravatar = ENV['ERRBIT_USE_GRAVATAR']
17   - Errbit::Config.gravatar_default = ENV['ERRBIT_GRAVATAR_DEFAULT']
18   -
19   - Errbit::Config.github_url = ENV['GITHUB_URL']
20   - Errbit::Config.github_authentication = ENV['GITHUB_AUTHENTICATION']
21   - Errbit::Config.github_client_id = ENV['GITHUB_CLIENT_ID']
22   - Errbit::Config.github_secret = ENV['GITHUB_SECRET']
23   - Errbit::Config.github_access_scope = ENV['GITHUB_ACCESS_SCOPE'].split(',').map(&:strip) if ENV['GITHUB_ACCESS_SCOPE']
24   -
25   - Errbit::Config.smtp_settings = {
26   - :address => ENV['SMTP_SERVER'] || 'smtp.sendgrid.net',
27   - :port => ENV['SMTP_PORT'] || 25,
28   - :authentication => :plain,
29   - :user_name => ENV['SMTP_USERNAME'] || ENV['SENDGRID_USERNAME'],
30   - :password => ENV['SMTP_PASSWORD'] || ENV['SENDGRID_PASSWORD'],
31   - :domain => ENV['SMTP_DOMAIN'] || ENV['SENDGRID_DOMAIN']
32   - }
33   -
34   - # Use example config for test environment.
35   - config_file = Rails.env == "test" ? default_config_file : Rails.root.join("config", "config.yml")
36   -
37   - # Load config if config file exists.
38   - if File.exists?(config_file)
39   - config = YAML.load_file(config_file)
40   - config.merge!(config.delete(Rails.env)) if config.has_key?(Rails.env)
41   - config.each do |k,v|
42   - Errbit::Config.send("#{k}=", v)
43   - end
44   - # Show message if we are not running tests, not running on Heroku, and config.yml doesn't exist.
45   - elsif not use_env
46   - puts "Please copy 'config/config.example.yml' to 'config/config.yml' and configure your settings. Using default settings."
47   - end
48   -
49   - # Set default devise modules
50   - Errbit::Config.devise_modules = [:database_authenticatable,
51   - :recoverable, :rememberable, :trackable,
52   - :validatable, :token_authenticatable, :omniauthable]
53   -end
54   -
55   -# Set default settings from config.example.yml if key is missing from config.yml
56   -default_config = YAML.load_file(default_config_file)
57   -default_config.each do |k,v|
58   - Errbit::Config.send("#{k}=", v) if Errbit::Config.send(k) === nil
59   -end
60   -
61   -# Disable GitHub oauth if gem is missing
62   -Errbit::Config.github_authentication = false unless defined?(OmniAuth::Strategies::GitHub)
63   -
64   -# Set SMTP settings if given.
65   -if smtp = Errbit::Config.smtp_settings
66   - ActionMailer::Base.delivery_method = :smtp
67   - ActionMailer::Base.smtp_settings = smtp
68   -end
69   -
70   -if sendmail = Errbit::Config.sendmail_settings
71   - ActionMailer::Base.delivery_method = :sendmail
72   - ActionMailer::Base.sendmail_settings = sendmail
73   -end
74   -
75   -# Set config specific values
76   -(ActionMailer::Base.default_url_options ||= {}).tap do |default|
77   - default.merge! :host => Errbit::Config.host if default[:host].blank?
78   -end
79   -
80   -if Rails.env.production?
81   - Rails.application.config.consider_all_requests_local = Errbit::Config.display_internal_errors
82   -end
config/cloud/cloud66/files/config.yml
... ... @@ -1,92 +0,0 @@
1   -# The host of your errbit server
2   -
3   -# Enforce SSL connections
4   -enforce_ssl: false
5   -
6   -# The email address which email notifications
7   -# will be sent from.
8   -#email_from:
9   -
10   -# If you turn on this option, email_at_notices can be
11   -# configured on a per app basis, at the App edit page
12   -per_app_email_at_notices: false
13   -
14   -# Configure when emails are sent for an error.
15   -# [1,3,7] = 1st, 3rd, and 7th occurence triggers
16   -# an email notification.
17   -email_at_notices: [1, 10, 100]
18   -
19   -# If you turn on this option, notify_at_notices can be
20   -# configured on a per app basis, at the App edit page
21   -per_app_notify_at_notices: false
22   -
23   -# Configure when emails are sent for an error.
24   -# [1,3,7] = 1st, 3rd, and 7th occurence triggers
25   -# [0] for all notices, provided notification service is configured
26   -notify_at_notices: [0]
27   -
28   -# Configure whether or not the user should be prompted before resolving an error.
29   -confirm_resolve_err: true
30   -
31   -# Add an optional 'username' field to Users.
32   -# Helpful when you need to plug in a custom authentication strategy, such as LDAP.
33   -user_has_username: false
34   -
35   -# Display internal errors in production
36   -# Since this is an internal application, you might like to see what caused Errbit to crash.
37   -# Pull requests are always welcome!
38   -# However, you might be more comfortable setting this to false if your server can be accessed by anyone.
39   -display_internal_errors: true
40   -# The host of your errbit server
41   -
42   -# Enable Gravatar.
43   -use_gravatar: true
44   -# Default Gravatar image, can be: mm, identicon, monsterid, wavatar, retro.
45   -gravatar_default: identicon
46   -
47   -# Setup your deploy options for capistrano.
48   -#deployment:
49   -# hosts:
50   -# web: errbit.example.com
51   -# app: errbit.example.com
52   -# db: errbit.example.com
53   -# repository: http://github.com/errbit/errbit.git
54   -# branch: master
55   -# user: deploy
56   -# deploy_to: /var/www/apps/errbit
57   -# # setup path to unicorn pids folder (or deploy_to/shared/pids will be used)
58   -# # pids: /var/www/apps/errbit/shared/pids
59   -
60   -# GitHub OAuth configuration
61   -# If you want to allow authentication via GitHub, you will need to register
62   -# your app at: https://github.com/settings/applications
63   -# If you hosted Errbit at errbit.example.com, you would fill in:
64   -#
65   -# URL: http://errbit.example.com/
66   -# Callback URL: http://errbit.example.com/users/auth/github
67   -#
68   -# After you have registered your app, copy your Client ID and Secret key below.
69   -
70   -# GitHub Permissions to request from user
71   -# ['repo'] - Allow creating issues for public and private repos.
72   -# ['public_repo'] - Only allow creating issues for public repos.
73   -# [] - No permission to create issues on any repos.
74   -github_access_scope: ['repo']
75   -
76   -# Configure SMTP settings. If you are running Errbit on Heroku,
77   -# sendgrid will be configured by default.
78   -# ------------------------------------------------------------------------
79   -#smtp_settings:
80   -# :address:
81   -# :domain:
82   -# :port:
83   -# :authentication: :plain
84   -# :enable_starttls_auto:
85   -# :user_name:
86   -# :password:
87   -
88   -
89   -# If you want send your email by your sendmail
90   -# sendmail_settings:
91   -# :location: '/usr/sbin/sendmail'
92   -# :arguments: '-i -t'
93 0 \ No newline at end of file
config/cloud/cloud66/files/mongoid.yml
... ... @@ -1,38 +0,0 @@
1   -# Mongoid Configuration
2   -# =====================
3   -#
4   -# Copy this file to config/mongoid.yml and
5   -# modify it accordingly. This file will automatically
6   -# be copied to shared/config on the server when
7   -# `cap deploy:setup` is ran the first time. Be sure
8   -# to place production specific settings there
9   -
10   -development:
11   - sessions:
12   - default:
13   - database: errbit_development
14   - hosts:
15   - - '<%=ENV["MONGODB_ADDRESS"]%>:27017'
16   - options:
17   - identity_map_enabled: true
18   - use_utc: true
19   -
20   -test:
21   - sessions:
22   - default:
23   - hosts:
24   - - localhost:27017
25   - database: errbit_test
26   - options:
27   - identity_map_enabled: true
28   - use_utc: true
29   -
30   -# set these environment variables on your prod server
31   -production:
32   - sessions:
33   - default:
34   - database: errbit
35   - hosts:
36   - - '<%=ENV["MONGODB_ADDRESS"]%>:27017'
37   - options:
38   - identity_map_enabled: true
39 0 \ No newline at end of file
config/cloud/cloud66/files/seeds.rb
... ... @@ -1,25 +0,0 @@
1   -puts "Seeding database"
2   -puts "-------------------------------"
3   -
4   -# Create an initial Admin User
5   -admin_username = "errbit"
6   -admin_email = "errbit@host.com"
7   -admin_pass = 'password'
8   -
9   -puts "Creating an initial admin user:"
10   -puts "-- username: #{admin_username}" if Errbit::Config.user_has_username
11   -puts "-- email: #{admin_email}"
12   -puts "-- password: #{admin_pass}"
13   -puts ""
14   -puts "Be sure to change these credentials ASAP!"
15   -user = User.where(:email => admin_email).first || User.new({
16   - :name => 'Errbit Admin',
17   - :email => admin_email,
18   - :password => admin_pass,
19   - :password_confirmation => admin_pass
20   - })
21   -user.username = admin_username if Errbit::Config.user_has_username
22   -
23   -user.admin = true
24   -user.save!
25   -
config/cloud/cloud66/files/unicorn.rb.cloud66
... ... @@ -1,36 +0,0 @@
1   -worker_processes 3
2   -timeout 30
3   -
4   -working_directory "#{ENV['RAILS_STACK_PATH']}"
5   -
6   -listen "/tmp/web_server.sock", :backlog => 64
7   -
8   -pid '/tmp/web_server.pid'
9   -
10   -stderr_path "#{ENV['RAILS_STACK_PATH']}/log/unicorn.stderr.log"
11   -stdout_path "#{ENV['RAILS_STACK_PATH']}/log/unicorn.stdout.log"
12   -
13   -preload_app true
14   -GC.respond_to?(:copy_on_write_friendly=) and
15   - GC.copy_on_write_friendly = true
16   -
17   -check_client_connection false
18   -
19   -before_fork do |server, worker|
20   - old_pid = '/tmp/web_server.pid.oldbin'
21   - if File.exists?(old_pid) && server.pid != old_pid
22   - begin
23   - Process.kill("QUIT", File.read(old_pid).to_i)
24   - rescue Errno::ENOENT, Errno::ESRCH
25   - # someone else did our job for us
26   - end
27   - end
28   -
29   - defined?(ActiveRecord::Base) and
30   - ActiveRecord::Base.connection.disconnect!
31   -end
32   -
33   -after_fork do |server, worker|
34   - defined?(ActiveRecord::Base) and
35   - ActiveRecord::Base.establish_connection
36   -end
37 0 \ No newline at end of file
config/cloud/cloud66/manifest.yml
... ... @@ -1,24 +0,0 @@
1   -production:
2   - rails:
3   - server:
4   - unique_name: frontend
5   - configuration:
6   - ruby_version: 2.0.0
7   - environment_variables:
8   - SECRET_TOKEN: AUTO_GENERATE_30
9   -staging:
10   - rails:
11   - server:
12   - unique_name: frontend
13   - configuration:
14   - ruby_version: 2.0.0
15   - environment_variables:
16   - SECRET_TOKEN: AUTO_GENERATE_30
17   -development:
18   - rails:
19   - server:
20   - unique_name: frontend
21   - configuration:
22   - ruby_version: 2.0.0
23   - environment_variables:
24   - SECRET_TOKEN: AUTO_GENERATE_30
config/cloud/cloud66/scripts/bundle.sh
... ... @@ -1,12 +0,0 @@
1   -#!/bin/bash
2   -FILE=/tmp/bundle_done
3   -
4   -if [ -f $FILE ]
5   -then
6   - echo "File $FILE exists..."
7   -else
8   - cd $STACK_PATH
9   - bundle exec rake db:mongoid:create_indexes
10   - bundle exec rake db:seed
11   - touch /tmp/bundle_done
12   -fi
13 0 \ No newline at end of file
config/cloud/cloud66/scripts/env_vars.sh
... ... @@ -1,24 +0,0 @@
1   -#!/bin/bash
2   -FILE=/tmp/env_vars_done
3   -
4   -if [ -f $FILE ]
5   -then
6   - echo "File $FILE exists..."
7   -else
8   - cd $RAILS_STACK_PATH
9   - echo "github_authentication: $GITHUB_AUTHENTICATION
10   - github_client_id: $GITHUB_CLIENT_ID
11   - github_secret: $GITHUB_SECRET
12   - ERRBIT_EMAIL_FROM: $MAILER_SENDER
13   - host: $ERRBIT_HOST
14   - email_from: $MAILER_SENDER
15   - smtp_settings:
16   - :address: $SMTP_ADDRESS
17   - :domain: $SMTP_DOMAIN
18   - :port: $SMTP_PORT
19   - :authentication: :plain
20   - :enable_starttls_auto: "true"
21   - :user_name: $SMTP_USERNAME
22   - :password: $SMTP_PASSWORD" >> config/config.yml
23   - touch /tmp/env_vars_done
24   -fi
25 0 \ No newline at end of file
config/config.example.yml
... ... @@ -1,103 +0,0 @@
1   -# Errbit Config
2   -# =============
3   -#
4   -# Copy this file to config/config.yml and
5   -# modify it accordingly. This file will automatically
6   -# be copied to shared/config on the server when
7   -# `cap deploy:setup` is ran the first time. Be sure
8   -# to place production specific settings there
9   -# You will need to restart the server after changing any settings.
10   -
11   -# The host of your errbit server
12   -host: errbit.example.com
13   -
14   -# The port for your errbit server.
15   -# Only set this if it isn't the default for the protocol (i.e.. 80 for HTTP, 443 for HTTPS)
16   -# port: 8080
17   -
18   -# The protocol for your errbit server.
19   -# Only set if not running default HTTP
20   -# protocol: https
21   -
22   -# Enforce SSL connections
23   -enforce_ssl: false
24   -
25   -# The email address which email notifications
26   -# will be sent from.
27   -email_from: errbit@example.com
28   -
29   -# If you turn on this option, email_at_notices can be
30   -# configured on a per app basis, at the App edit page
31   -per_app_email_at_notices: false
32   -
33   -# Configure when emails are sent for an error.
34   -# [1,3,7] = 1st, 3rd, and 7th occurence triggers
35   -# an email notification.
36   -email_at_notices: [1, 10, 100]
37   -
38   -# If you turn on this option, notify_at_notices can be
39   -# configured on a per app basis, at the App edit page
40   -per_app_notify_at_notices: false
41   -
42   -# Configure when emails are sent for an error.
43   -# [1,3,7] = 1st, 3rd, and 7th occurence triggers
44   -# [0] for all notices, provided notification service is configured
45   -notify_at_notices: [0]
46   -
47   -# Configure whether or not the user should be prompted before resolving/deleting/merging/etc an error.
48   -confirm_err_actions: true
49   -
50   -# Add an optional 'username' field to Users.
51   -# Helpful when you need to plug in a custom authentication strategy, such as LDAP.
52   -user_has_username: false
53   -
54   -# Display internal errors in production
55   -# Since this is an internal application, you might like to see what caused Errbit to crash.
56   -# Pull requests are always welcome!
57   -# However, you might be more comfortable setting this to false if your server can be accessed by anyone.
58   -display_internal_errors: true
59   -
60   -# Enable Gravatar.
61   -use_gravatar: true
62   -# Default Gravatar image, can be: mm, identicon, monsterid, wavatar, retro.
63   -gravatar_default: identicon
64   -
65   -# GitHub OAuth configuration
66   -# If you want to allow authentication via GitHub, you will need to register
67   -# your app at: https://github.com/settings/applications
68   -# If you hosted Errbit at errbit.example.com, you would fill in:
69   -#
70   -# URL: http://errbit.example.com/
71   -# Callback URL: http://errbit.example.com/users/auth/github
72   -#
73   -# After you have registered your app, copy your Client ID and Secret key below.
74   -github_authentication: false
75   -github_client_id: 'GITHUB_CLIENT_ID'
76   -github_secret: 'GITHUB_SECRET'
77   -# GitHub Permissions to request from user
78   -# ['repo'] - Allow creating issues for public and private repos.
79   -# ['public_repo'] - Only allow creating issues for public repos.
80   -# [] - No permission to create issues on any repos.
81   -github_access_scope: ['repo']
82   -
83   -# Change this to point to the URL of your GitHub Enterprise installation, if
84   -# you want to link local repositories.
85   -github_url: https://github.com
86   -
87   -# Configure SMTP settings. If you are running Errbit on Heroku,
88   -# sendgrid will be configured by default.
89   -# ------------------------------------------------------------------------
90   -#smtp_settings:
91   -# :address: ADDRESS
92   -# :domain: DOMAIN
93   -# :port: "25"
94   -# :authentication: :plain, :login, :cram_md5
95   -# :enable_starttls_auto: true
96   -# :user_name: USERNAME
97   -# :password: PASSWORD
98   -
99   -
100   -# If you want send your email by your sendmail
101   -# sendmail_settings:
102   -# :location: '/usr/sbin/sendmail'
103   -# :arguments: '-i -t'
config/environments/production.rb
... ... @@ -14,14 +14,6 @@ Rails.application.configure do
14 14 config.consider_all_requests_local = false
15 15 config.action_controller.perform_caching = true
16 16  
17   - # Enable Rack::Cache to put a simple HTTP cache in front of your application
18   - # Add `rack-cache` to your Gemfile before enabling this.
19   - # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20   - # config.action_dispatch.rack_cache = true
21   -
22   - # Disable Rails's static asset server (Apache or nginx will already do this).
23   - config.serve_static_assets = false
24   -
25 17 # Compress JavaScripts and CSS.
26 18 config.assets.js_compressor = :uglifier
27 19 # config.assets.css_compressor = :sass
... ... @@ -38,9 +30,6 @@ Rails.application.configure do
38 30 # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
39 31 # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
40 32  
41   - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
42   - # config.force_ssl = true
43   -
44 33 # Set to :debug to see everything in the log.
45 34 config.log_level = :info
46 35  
... ...
config/initializers/_load_config.rb
... ... @@ -1,101 +0,0 @@
1   -require 'ostruct'
2   -default_config_file = Rails.root.join("config", "config.example.yml")
3   -
4   -# Allow a Rails Engine to override config by defining it earlier
5   -unless defined?(Errbit::Config)
6   - Errbit::Config = OpenStruct.new
7   - use_env = ENV['HEROKU'] || ENV['USE_ENV']
8   -
9   - Errbit::Config.protocol = 'http'
10   -
11   - # If Errbit is running on Heroku, config can be set from environment variables.
12   - if use_env
13   - Errbit::Config.host = ENV['ERRBIT_HOST']
14   - Errbit::Config.protocol = ENV['ERRBIT_PROTOCOL'] || 'http'
15   - Errbit::Config.port = ENV['ERRBIT_PORT']
16   - Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM']
17   - # Not really easy to use like an env because need an array and ENV return a string :(
18   - # Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES']
19   - Errbit::Config.confirm_err_actions = ENV['ERRBIT_CONFIRM_ERR_ACTIONS'].to_i == 0
20   - Errbit::Config.user_has_username = ENV['ERRBIT_USER_HAS_USERNAME'].to_i == 1
21   - Errbit::Config.enforce_ssl = ENV['ERRBIT_ENFORCE_SSL']
22   - Errbit::Config.use_gravatar = ENV['ERRBIT_USE_GRAVATAR']
23   - Errbit::Config.gravatar_default = ENV['ERRBIT_GRAVATAR_DEFAULT']
24   -
25   - Errbit::Config.github_url = ENV['GITHUB_URL']
26   - Errbit::Config.github_authentication = ENV['GITHUB_AUTHENTICATION']
27   - Errbit::Config.github_client_id = ENV['GITHUB_CLIENT_ID']
28   - Errbit::Config.github_secret = ENV['GITHUB_SECRET']
29   - Errbit::Config.github_org_id = ENV['GITHUB_ORG_ID'] if ENV['GITHUB_ORG_ID']
30   - Errbit::Config.github_access_scope = ENV['GITHUB_ACCESS_SCOPE'].split(',').map(&:strip) if ENV['GITHUB_ACCESS_SCOPE']
31   -
32   - Errbit::Config.smtp_settings = {
33   - :address => ENV['SMTP_SERVER'] || 'smtp.sendgrid.net',
34   - :port => ENV['SMTP_PORT'] || 25,
35   - :authentication => :plain,
36   - :user_name => ENV['SMTP_USERNAME'] || ENV['SENDGRID_USERNAME'],
37   - :password => ENV['SMTP_PASSWORD'] || ENV['SENDGRID_PASSWORD'],
38   - :domain => ENV['SMTP_DOMAIN'] || ENV['SENDGRID_DOMAIN'] ||
39   - (ENV['ERRBIT_EMAIL_FROM'] ? ENV['ERRBIT_EMAIL_FROM'].split('@').last : nil)
40   - }
41   - end
42   -
43   - # Use example config for test environment.
44   - config_file = Rails.env == "test" ? default_config_file : Rails.root.join("config", "config.yml")
45   -
46   - # Load config if config file exists.
47   - if File.exists?(config_file)
48   - config = YAML.load_file(config_file)
49   - config.merge!(config.delete(Rails.env)) if config.has_key?(Rails.env)
50   - config.each do |k,v|
51   - Errbit::Config.send("#{k}=", v)
52   - end
53   - # Show message if we are not running tests, not running on Heroku, and config.yml doesn't exist.
54   - elsif not use_env
55   - puts "Please copy 'config/config.example.yml' to 'config/config.yml' and configure your settings. Using default settings."
56   - end
57   -
58   - # Set default devise modules
59   - Errbit::Config.devise_modules = [:database_authenticatable,
60   - :recoverable, :rememberable, :trackable,
61   - :validatable, :omniauthable]
62   -end
63   -
64   -# Set default settings from config.example.yml if key is missing from config.yml
65   -default_config = YAML.load_file(default_config_file)
66   -default_config.each do |k,v|
67   - Errbit::Config.send("#{k}=", v) if Errbit::Config.send(k) === nil
68   -end
69   -
70   -# Make sure the GitHub link doesn't end with a slash, so we don't have to deal
71   -# with it later on in the code.
72   -Errbit::Config.github_url.gsub!(/\/*\z/, '')
73   -
74   -# Disable GitHub oauth if gem is missing
75   -Errbit::Config.github_authentication = false unless defined?(OmniAuth::Strategies::GitHub)
76   -
77   -# Set SMTP settings if given.
78   -if smtp = Errbit::Config.smtp_settings
79   - ActionMailer::Base.delivery_method = :smtp
80   - ActionMailer::Base.smtp_settings = smtp
81   -end
82   -
83   -if sendmail = Errbit::Config.sendmail_settings
84   - ActionMailer::Base.delivery_method = :sendmail
85   - ActionMailer::Base.sendmail_settings = sendmail
86   -end
87   -
88   -# Set config specific values
89   -(ActionMailer::Base.default_url_options ||= {}).tap do |default|
90   - options_from_config = {
91   - host: Errbit::Config.host,
92   - port: Errbit::Config.port,
93   - protocol: Errbit::Config.protocol
94   - }.select { |k, v| v }
95   -
96   - default.reverse_merge!(options_from_config)
97   -end
98   -
99   -if Rails.env.production?
100   - Rails.application.config.consider_all_requests_local = Errbit::Config.display_internal_errors
101   -end
config/initializers/action_mailer.rb 0 → 100644
... ... @@ -0,0 +1,32 @@
  1 +# Set SMTP settings if given.
  2 +if Errbit::Config.email_delivery_method == :smtp
  3 + ActionMailer::Base.delivery_method = :smtp
  4 + ActionMailer::Base.smtp_settings = {
  5 + :address => Errbit::Config.smtp_address,
  6 + :port => Errbit::Config.smtp_port,
  7 + :authentication => Errbit::Config.smtp_authentication,
  8 + :user_name => Errbit::Config.smtp_user_name,
  9 + :password => Errbit::Config.smtp_password,
  10 + :domain => Errbit::Config.smtp_domain,
  11 + }
  12 +end
  13 +
  14 +if Errbit::Config.email_delivery_method == :sendmail
  15 + sendmail_settings = {}
  16 + sendmail_settings[:location] = Errbit::Config.sendmail_location if Errbit::Config.sendmail_location
  17 + sendmail_settings[:arguments] = Errbit::Config.sendmail_arguments if Errbit::Config.sendmail_arguments
  18 +
  19 + ActionMailer::Base.delivery_method = :sendmail
  20 + ActionMailer::Base.sendmail_settings = sendmail_settings
  21 +end
  22 +
  23 +# Set config specific values
  24 +(ActionMailer::Base.default_url_options ||= {}).tap do |default|
  25 + options_from_config = {
  26 + host: Errbit::Config.host,
  27 + port: Errbit::Config.port,
  28 + protocol: Errbit::Config.protocol
  29 + }.select { |k, v| v }
  30 +
  31 + default.reverse_merge!(options_from_config)
  32 +end
... ...
config/initializers/mongo.rb
... ... @@ -1,42 +0,0 @@
1   -# Some code extract from Mongoid gem
2   -config_file = Rails.root.join("config", "mongoid.yml")
3   -if config_file.file? &&
4   - YAML.load(ERB.new(File.read(config_file)).result)[Rails.env].values.flatten.any?
5   - ::Mongoid.load!(config_file)
6   -elsif ENV['HEROKU'] || ENV['USE_ENV']
7   - # No mongoid.yml file. Use ENV variable to define your MongoDB
8   - # configuration
9   - if mongo = ENV['MONGOLAB_URI'] || ENV['MONGOHQ_URL'] || ENV['MONGODB_URL'] || ENV['MONGO_URL']
10   - settings = URI.parse(mongo)
11   - database_name = settings.path.gsub(/^\//, '')
12   - else
13   - settings = OpenStruct.new({
14   - :host => ENV['MONGOID_HOST'],
15   - :port => ENV['MONGOID_PORT'],
16   - :user => ENV['MONGOID_USERNAME'],
17   - :password => ENV['MONGOID_PASSWORD']
18   - })
19   - database_name = ENV['MONGOID_DATABASE']
20   - end
21   -
22   - Mongoid.configure do |config|
23   -
24   - hash = {
25   - sessions: {
26   - default: {
27   - database: database_name,
28   - hosts: [ "#{settings.host}:#{settings.port}" ]
29   - }
30   - },
31   - }
32   -
33   - if settings.user && settings.password
34   - hash[:sessions][:default][:username] = settings.user
35   - hash[:sessions][:default][:password] = settings.password
36   - end
37   -
38   - config.load_configuration(hash)
39   - end
40   -end
41   -
42   -Mongoid.use_activesupport_time_zone = true
config/load.rb 0 → 100644
... ... @@ -0,0 +1,56 @@
  1 +# load default ENV values (without overwriting any existing value)
  2 +Dotenv.load('.env.default')
  3 +
  4 +# map config keys to environment variables
  5 +#
  6 +# We use the first non-nil environment variable in the list. If the last array
  7 +# element is a proc, it runs at the end, overriding the config value
  8 +Errbit::Config = Configurator.run({
  9 + host: ['ERRBIT_HOST'],
  10 + protocol: ['ERRBIT_PROTOCOL'],
  11 + port: ['ERRBIT_PORT'],
  12 + enforce_ssl: ['ERRBIT_ENFORCE_SSL'],
  13 + confirm_err_actions: ['ERRBIT_CONFIRM_ERR_ACTIONS'],
  14 + user_has_username: ['ERRBIT_USER_HAS_USERNAME'],
  15 + use_gravatar: ['ERRBIT_USE_GRAVATAR'],
  16 + gravatar_default: ['ERRBIT_GRAVATAR_DEFAULT'],
  17 + email_from: ['ERRBIT_EMAIL_FROM'],
  18 + email_at_notices: ['ERRBIT_EMAIL_AT_NOTICES'],
  19 + per_app_email_at_notices: ['ERRBIT_PER_APP_EMAIL_AT_NOTICES'],
  20 + notify_at_notices: ['ERRBIT_NOTIFY_AT_NOTICES'],
  21 + per_app_notify_at_notices: ['ERRBIT_PER_APP_NOTIFY_AT_NOTICES'],
  22 +
  23 + serve_static_assets: ['SERVE_STATIC_ASSETS'],
  24 + secret_key_base: ['SECRET_KEY_BASE'],
  25 + mongo_url: ['MONGOLAB_URI', 'MONGOHQ_URL', 'MONGODB_URL', 'MONGO_URL'],
  26 +
  27 + # github
  28 + github_url: ['GITHUB_URL', ->(values) {
  29 + values[:github_url].gsub(/\/*\z/, '')
  30 + }],
  31 + github_authentication: ['GITHUB_AUTHENTICATION'],
  32 + github_client_id: ['GITHUB_CLIENT_ID'],
  33 + github_secret: ['GITHUB_SECRET'],
  34 + github_org_id: ['GITHUB_ORG_ID'],
  35 + github_access_scope: ['GITHUB_ACCESS_SCOPE'],
  36 +
  37 + email_delivery_method: ['EMAIL_DELIVERY_METHOD'],
  38 +
  39 + # smtp settings
  40 + smtp_address: ['SMTP_SERVER'],
  41 + smtp_port: ['SMTP_PORT'],
  42 + smtp_authentication: ['SMTP_AUTHENTICATION'],
  43 + smtp_user_name: ['SMTP_USERNAME', 'SENDGRID_USERNAME'],
  44 + smtp_password: ['SMTP_PASSWORD', 'SENDGRID_PASSWORD'],
  45 + smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', ->(values) {
  46 + values[:smtp_domain] ||
  47 + (values[:email_from] && values[:email_from].split('@').last)||
  48 + nil
  49 + }],
  50 +
  51 + # sendmail settings
  52 + sendmail_location: ['SENDMAIL_LOCATION'],
  53 + sendmail_arguments: ['SENDMAIL_ARGUMENTS'],
  54 +
  55 + devise_modules: ['DEVISE_MODULES'],
  56 +})
... ...
config/mongo.rb 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +require 'uri'
  2 +
  3 +Mongoid.configure do |config|
  4 + uri = URI.parse(Errbit::Config.mongo_url)
  5 + uri.path = "/errbit_#{Rails.env}" if uri.path.empty?
  6 +
  7 + config.load_configuration({
  8 + sessions: {
  9 + default: {
  10 + uri: uri.to_s
  11 + }
  12 + },
  13 + options: {
  14 + use_activesupport_time_zone: true
  15 + }
  16 + })
  17 +end
... ...
config/mongoid.example.yml
... ... @@ -1,38 +0,0 @@
1   -# Mongoid Configuration
2   -# =====================
3   -#
4   -# Copy this file to config/mongoid.yml and
5   -# modify it accordingly. This file will automatically
6   -# be copied to shared/config on the server when
7   -# `cap deploy:setup` is ran the first time. Be sure
8   -# to place production specific settings there
9   -
10   -development:
11   - sessions:
12   - default:
13   - database: errbit_development
14   - hosts:
15   - - localhost:27017
16   - options:
17   - use_utc: true
18   -
19   -test:
20   - sessions:
21   - default:
22   - hosts:
23   - - localhost:27017
24   - database: errbit_test
25   - options:
26   - use_utc: true
27   -
28   -# set these environment variables on your prod server
29   -production:
30   - sessions:
31   - default:
32   - database: <%= ENV['MONGOID_DATABASE'] %>
33   - hosts:
34   - - '<%=ENV["MONGOID_HOST"]%>:<%=ENV["MONGOID_PORT"]%>'
35   - username: <%= ENV['MONGOID_USERNAME'] %>
36   - password: <%= ENV['MONGOID_PASSWORD'] %>
37   - options:
38   - use_utc: true
39 0 \ No newline at end of file
config/mongoid.mongohq.yml
... ... @@ -1,10 +0,0 @@
1   -# Mongoid Configuration for MongoHQ on Heroku
2   -# ===========================================
3   -#
4   -# Copy this file to config/mongoid.yml,
5   -# commit it to your repo, then push to heroku.
6   -
7   -production:
8   - sessions:
9   - default:
10   - uri: <%= ENV['MONGOHQ_URL'] %>
config/mongoid.mongolab.yml
... ... @@ -1,10 +0,0 @@
1   -# Mongoid Configuration for MongoLab on Heroku
2   -# ===========================================
3   -#
4   -# Copy this file to config/mongoid.yml,
5   -# commit it to your repo, then push to heroku.
6   -
7   -production:
8   - sessions:
9   - default:
10   - uri: <%= ENV['MONGOLAB_URI'] %>
config/secrets.yml
... ... @@ -1,22 +0,0 @@
1   -# Be sure to restart your server when you modify this file.
2   -
3   -# Your secret key is used for verifying the integrity of signed cookies.
4   -# If you change this key, all old signed cookies will become invalid!
5   -
6   -# Make sure the secret is at least 30 characters and all random,
7   -# no regular words or you'll be exposed to dictionary attacks.
8   -# You can use `rake secret` to generate a secure secret key.
9   -
10   -# Make sure the secrets in this file are kept private
11   -# if you're sharing your code publicly.
12   -
13   -development:
14   - secret_key_base: f258ed69266dc8ad0ca79363c3d2f945c388a9c5920fc9a1ae99a98fbb619f135001c6434849b625884a9405a60cd3d50fc3e3b07ecd38cbed7406a4fccdb59c
15   -
16   -test:
17   - secret_key_base: f258ed69266dc8ad0ca79363c3d2f945c388a9c5920fc9a1ae99a98fbb619f135001c6434849b625884a9405a60cd3d50fc3e3b07ecd38cbed7406a4fccdb59c
18   -
19   -# Do not keep production secrets in the repository,
20   -# instead read values from the environment.
21   -production:
22   - secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
docs/ENV-VARIABLES.md
... ... @@ -1,91 +0,0 @@
1   -# Which env variable you can use ?
2   -
3   -Errbit can be almost configured by some ENVIRONMENT variables. If you
4   -use this variable, you don't need copy all of you configuration file
5   -
6   -## Ruby version
7   -
8   -You can define your own ruby version you want to use. By default it's
9   -the 2.0.0 to use. But you can change it with RUBY_VERSION variable.
10   -
11   -We test it on :
12   -
13   - * 1.9.3
14   - * 2.0.0
15   - * 2.1.0
16   - * 2.2.0
17   -
18   -## Use configuration by ENV
19   -
20   -To activate this env variable you need activate it by a Variable env.
21   -You can do that with HEROKU or USE_ENV variable
22   -
23   -If you activate it you can use all of this env variable :
24   -
25   -## Errbit base configuration
26   -
27   -* ERRBIT_HOST : the host of your errbit instance (not define by default)
28   -* ERRBIT_EMAIL_FROM : the email sending all of your notification (not
29   - define by default )
30   -* ERRBIT_CONFIRM_RESOLVE_ERR : define if you need confirm when you mark
31   - a problem resolve. ( true by default, fill it and you not need
32   -confirm )
33   -* ERRBIT_USER_HAS_USERNAME : allow identify your user by username
34   - instead of email. ( false by default, set to '1' to activate it)
35   -* ERRBIT_ALLOW_COMMENTS_WITH_ISSUE_TRACKER : define if you activate the
36   - comment or not. By default comment are
37   -* ERRBIT_ENFORCE_SSL : allow force the ssl on all the application. By
38   - default is false
39   -* ERRBIT_USE_GRAVATAR : allow use gravatar to see user gravatar in user
40   - comment and page
41   -
42   -## Authentification configuration
43   -
44   -Environement variable allow define how you can auth on your errbit
45   -
46   -### Github authentification
47   -
48   -You can allow the GITHUB auth
49   -
50   -* GITHUB_AUTHENTIFICATION : define if you allow the github auth. By
51   - default false
52   -* GITHUB_CLIENT_ID : you github app client id to use in your github auth
53   -* GITHUB_SECRET : your github app secret to use in your github auth
54   -* GITHUB_ACCESS_SCOPE : The scope to ask to access on github account
55   -
56   -## Email sending configuration
57   -
58   -You can define how you connect your email sending system By all of this
59   -information. All mail can be send only by SMTP if you use variable
60   -system
61   -
62   -* SMTP_SERVER
63   -* SMTP_PORT
64   -* SMTP_USERNAME
65   -* SMTP_PASSWORD
66   -* SMTP_DOMAIN
67   -
68   -## MongoDB
69   -
70   -You can define your MongoDB connection by 2 ways. If you have an URL,
71   -you can define one of this ENV variables. All independently can works
72   -
73   -* MONGOLAB_URI
74   -* MONGOHQ_URL
75   -
76   -If you have a complete MongoDB connection you can define it by all
77   -information associate to your MongoDB connection. You need define all
78   -variable.
79   -
80   -* MONGOID_HOST
81   -* MONGOID_PORT
82   -* MONGOID_USERNAME
83   -* MONGOID_PASSWORD
84   -* MONGOID_DATABASE
85   -
86   -## Flowdock notification adapter
87   -
88   -If you noticed default Gravatar icon in your Flowdock notifications you
89   -may want to [add Errbit icon](http://gravatar.com) for email that is
90   -set in ERRBIT_EMAIL_FROM.
91   -You don't need to approve or authorize it on Flowdock because it is used only for an icon.
docs/configuration.md 0 → 100644
... ... @@ -0,0 +1,98 @@
  1 +# Configuring Errbit
  2 +Following the recommendation of [12factor.net](http://12factor.net/config),
  3 +Errbit takes all of its configuration from environment variables. You can use
  4 +[dotenv](https://github.com/bkeepers/dotenv), which is included in the Gemfile,
  5 +to fill in any values that you can't or won't supply through the environment.
  6 +
  7 +In order of precedence Errbit uses:
  8 +1. Environment variables (for example MY_VALUE=abc bundle exec unicorn)
  9 +2. Values provided in a .env file
  10 +3. Default values from .env.default
  11 +
  12 +## Configuration Parameters
  13 +<dl>
  14 +<dt>ERRBIT_HOST
  15 +<dd>Hostname to use when building links back to Errbit
  16 +<dd>defaults to errbit.example.com
  17 +<dt>ERRBIT_PROTOCOL
  18 +<dd>Protocol to use when building links back to Errbit (http or https)
  19 +<dd>defaults to http
  20 +<dt>ERRBIT_PORT
  21 +<dd>TCP port to use when building links back to Errbit
  22 +<dt>ERRBIT_ENFORCE_SSL
  23 +<dd>When enabled, Errbit forces all traffic over https
  24 +<dd>defaults to false
  25 +<dt>ERRBIT_CONFIRM_ERR_ACTIONS
  26 +<dd>Present confirmation dialogs when users act on errors
  27 +<dd>defaults to true
  28 +<dt>ERRBIT_USER_HAS_USERNAME
  29 +<dd>Allow users to have a username field
  30 +<dd>defaults to true
  31 +<dt>ERRBIT_USE_GRAVATAR
  32 +<dd>Enable gravatar
  33 +<dd>defaults to true
  34 +<dt>ERRBIT_GRAVATAR_DEFAULT
  35 +<dd>Default gravatar image (see https://en.gravatar.com/site/implement/images/)
  36 +<dd>identicon
  37 +<dt>ERRBIT_EMAIL_FROM
  38 +<dd>The value that should be set in the 'from' field for outgoing emails
  39 +<dd>defaults to errbit@example.com
  40 +<dt>ERRBIT_EMAIL_AT_NOTICES
  41 +<dd>Errbit notifies watchers via email after the set number of occurances of the same error
  42 +<dd>defaults to [1,10,100]
  43 +<dt>ERRBIT_PER_APP_EMAIL_AT_NOTICES
  44 +<dd>Let every application have it's own configuration rather than using ERRBIT_EMAIL_AT_NOTICES. If this value is true, you can configure each app using the web UI.
  45 +<dd>defaults to false
  46 +<dt>ERRBIT_NOTIFY_AT_NOTICES
  47 +<dd>Notify each application's configured notification service after the set number of occurances of the same error. [0] means notify on every occurance.
  48 +<dd>defaults to [0]
  49 +<dt>ERRBIT_PER_APP_NOTIFY_AT_NOTICES
  50 +<dd>Let every application have it's own configuration rather than using ERRBIT_NOTIFY_AT_NOTICES. If this value is set to true, you can configure each app using the web UI.
  51 +<dd>defaults to false
  52 +<dt>SERVE_STATIC_ASSETS
  53 +<dd>Allow Rails to serve static assets. For most production environments, this should be false because your web server should be configured to serve static assets for you. But some environments like Heroku require this to be true.
  54 +<dd>defaults to true
  55 +<dt>SECRET_KEY_BASE
  56 +<dd>For production environments, you should run `rake secret` to generate a secret, unique key for this parameter
  57 +<dd>defaults to f258ed69266dc8ad0ca79363c3d2f945c388a9c5920fc9a1ae99a98fbb619f135001c6434849b625884a9405a60cd3d50fc3e3b07ecd38cbed7406a4fccdb59c
  58 +<dt>MONGO_URL
  59 +<dd>URL connection string for mongo in the form mongodb://username:password@example.com:port To more easily set up connections to third party mongo providers, you can call this value MONGOLAB_URI, MONGOHQ_URL, MONGODB_URL or MONGO_URL
  60 +<dd>defaults to mongodb://localhost/errbit_&lt;Rails.env&gt;
  61 +<dt>GITHUB_URL
  62 +<dd>Use this URL for interacting github. This is useful if you have a github enterprise account and you're using a URL other than https://github.com
  63 +<dd>defaults to https://github.com
  64 +<dt>GITHUB_AUTHENTICATION
  65 +<dd>Allow github sign-in via OAuth
  66 +<dd>defaults to true
  67 +<dt>GITHUB_CLIENT_ID
  68 +<dd>Client id of your github application
  69 +<dt>GITHUB_SECRET
  70 +<dd>Secret key for your github application
  71 +<dt>GITHUB_ORG_ID
  72 +<dd>ID of your github organization. If set, Errbit will create user accounts for users in your github organization who sign into Errbit without having a user account
  73 +<dt>GITHUB_ACCESS_SCOPE
  74 +<dd>OAuth scope to request from users when they sign-in through github
  75 +<dd>defaults to [repo]
  76 +<dt>EMAIL_DELIVERY_METHOD
  77 +<dd>SMTP or sendmail, depending on how you want Errbit to send email
  78 +<dd>defaults to sendmail
  79 +<dt>SMTP_SERVER
  80 +<dd>Server address for outgoing SMTP messages
  81 +<dt>SMTP_PORT
  82 +<dd>Server port for outgoing SMTP messages
  83 +<dt>SMTP_AUTHENTICATION
  84 +<dd>Authentication method for the SMTP connection (see http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration)
  85 +<dt>SMTP_USERNAME
  86 +<dd>Username for SMTP auth, you could also set SENDGRID_USERNAME
  87 +<dt>SMTP_PASSWORD
  88 +<dd>Password for SMTP auth, you could also set SENDGRID_PASSWORD
  89 +<dt>SMTP_DOMAIN
  90 +<dd>HELO domain to set for outgoing SMTP messages, you can also use SENDGRID_DOMAIN
  91 +<dt>SENDMAIL_LOCATION
  92 +<dd>Path to sendmail
  93 +<dt>SENDMAIL_ARGUMENTS
  94 +<dd>Custom arguments for sendmail
  95 +<dt>DEVISE_MODULES
  96 +<dd>Devise modules to enable
  97 +<dd>defaults to [database_authenticatable,recoverable,rememberable,trackable,validatable,omniauthable]
  98 +</dl>
... ...
lib/configurator.rb 0 → 100644
... ... @@ -0,0 +1,82 @@
  1 +require 'ostruct'
  2 +
  3 +# Configurator maps lists of environment variables to names that you define in
  4 +# order to provide a consistent way to use configuration throughout your
  5 +# application
  6 +class Configurator
  7 +
  8 + # Run the configurator and return the processed values
  9 + #
  10 + # @example Simple mapping
  11 + # ENV['BAR'] = 'onevalue'
  12 + # ENV['BAZ'] = 'another'
  13 + #
  14 + # config = Configurator.run({
  15 + # key_one: ['FOO', 'BAR'],
  16 + # key_two: ['BAZ']
  17 + # })
  18 + #
  19 + # config.key_one
  20 + # #=> 'onevalue'
  21 + # config.key_two
  22 + # #=> 'another'
  23 + #
  24 + # @example Using override blocks
  25 + # ENV['BAR'] = 'onevalue'
  26 + # ENV['BAZ'] = 'another'
  27 + #
  28 + # config = Configurator.run({
  29 + # key_one: ['FOO', 'BAR', ->(values) {
  30 + # values[:key_two]
  31 + # }],
  32 + # key_two: ['BAZ']
  33 + # })
  34 + #
  35 + # config.key_one
  36 + # #=> 'another'
  37 + #
  38 + # @param Hash map of configuration keys with array values where the array is
  39 + # a list of environment variables to scan for configuration
  40 + # @return OpenStruct configuration object
  41 + def self.run(mapping)
  42 + reader = self.new(mapping)
  43 + reader.read
  44 + end
  45 +
  46 + # Create the Configurator object
  47 + #
  48 + # @param [Hash] mapping mapping of config names to environment value names
  49 + # @return [Configurator]
  50 + def initialize(mapping)
  51 + @mapping = mapping
  52 + @overrides = {}
  53 + @storage = {}
  54 + end
  55 +
  56 + # Process the environment variable values and store the overrides
  57 + def scan
  58 + @mapping.each do |key, values|
  59 + @overrides[key] = values.pop if values.last.is_a? Proc
  60 + env_name = values.find { |v| ENV[v] }
  61 + @storage[key] = YAML.parse(ENV[env_name]).to_ruby if env_name
  62 + end
  63 + end
  64 +
  65 + # Apply the override functions
  66 + def apply_overrides
  67 + @overrides.each do |key, override|
  68 + @storage[key] = override.call(@storage)
  69 + end
  70 + end
  71 +
  72 + # Perform all the required processing and return the configuration object
  73 + #
  74 + # @return [OpenStruct] configuration object
  75 + def read
  76 + @storage = {}
  77 + scan
  78 + apply_overrides
  79 +
  80 + OpenStruct.new(@storage)
  81 + end
  82 +end
... ...
lib/tasks/errbit/bootstrap.rake
1 1 require 'fileutils'
2 2  
3 3 namespace :errbit do
4   -
5   - desc "Copys of example config files"
6   - task :copy_configs do
7   - configs = {
8   - 'config.example.yml' => 'config.yml',
9   - 'deploy.example.rb' => 'deploy.rb',
10   - (ENV['HEROKU'] ? 'mongoid.mongohq.yml' : 'mongoid.example.yml') => 'mongoid.yml'
11   - }
12   -
13   - puts "Copying example config files..."
14   - configs.each do |old, new|
15   - if File.exists?("config/#{new}")
16   - puts "-- Skipping config/#{new}: already exists"
17   - else
18   - puts "-- Copying config/#{old} to config/#{new}"
19   - FileUtils.cp "config/#{old}", "config/#{new}"
20   - end
21   - end
22   - end
23   -
24   - desc "Copy's over example files and seeds the database"
  4 + desc "Seed and index the DB"
25 5 task :bootstrap do
26   - Rake::Task['errbit:copy_configs'].execute
27   - puts "\n"
28 6 Rake::Task['db:seed'].invoke
29 7 puts "\n"
30 8 Rake::Task['db:mongoid:create_indexes'].invoke
31 9 end
32   -
33 10 end
... ...
spec/lib/configurator_spec.rb 0 → 100644
... ... @@ -0,0 +1,37 @@
  1 +describe Configurator do
  2 + before(:each) do
  3 + allow(ENV).to receive(:[]).and_return(nil)
  4 + allow(ENV).to receive(:[]).with('VARONE').and_return('zoom')
  5 + allow(ENV).to receive(:[]).with('VARTHREE').and_return('zipp')
  6 + end
  7 +
  8 + it 'takes the first existing env, second item' do
  9 + result = Configurator.run({ two: ['VARTWO', 'VARTHREE'] })
  10 + expect(result.two).to eq('zipp')
  11 + end
  12 +
  13 + it 'takes the first existing env, first item' do
  14 + result = Configurator.run({ three: ['VARTHREE', 'VARONE'] })
  15 + expect(result.three).to eq('zipp')
  16 + end
  17 +
  18 + it 'provides nothing for missing variables' do
  19 + result = Configurator.run({ four: ['VAREIGHTY'] })
  20 + expect(result.four).to be_nil
  21 + end
  22 +
  23 + it 'overrides existing variables' do
  24 + result = Configurator.run({
  25 + one: ['VARONE', ->(values) { 'oveRIIIDE' } ]
  26 + })
  27 + expect(result.one).to eq('oveRIIIDE')
  28 + end
  29 +
  30 + it 'overrides can refer to other values' do
  31 + result = Configurator.run({
  32 + one: ['VARONE', ->(values) { values[:one] } ],
  33 + three: ['VARTHREE' ]
  34 + })
  35 + expect(result.one).to eq('zoom')
  36 + end
  37 +end
... ...