This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
/
production.rb
133 lines (107 loc) · 5 KB
/
production.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = {
# metastore: 'redis://redis:6379/1/metastore',
# entitystore: 'redis://redis:6379/1/entitystore'
# }
# Whether the application server should serve static files depends on ENV
config.serve_static_files = Settings.rails_serve_static_assets || false
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do fall back to assets pipeline if a precompiled asset is missed.
config.assets.compile = Settings.compile_static || false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :info
config.lograge.enabled = true
config.lograge.custom_options = lambda do |event|
params = event.payload[:params].reject do |k|
['controller', 'action'].include? k
end
log_hash = {"params"=> params, "time"=>event.time}
if not event.payload[:exception].blank?
log_hash["exception"]=event.payload[:exception]
end
log_hash
end
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
config.action_controller.asset_host = Settings.cloudfront_url
config.assets.prefix = '/assets'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
config.paperclip_defaults = {
storage: :s3,
s3_host_name: Settings.s3_host_name,
s3_host_alias: Settings.cloudfront_url,
s3_protocol: 'https',
path: '/:class/:attachment/:id_partition/:style/:filename',
url: ':s3_alias_url',
s3_credentials: {
bucket: Settings.s3_asset_bucket,
access_key_id: Settings.aws_access_key_id,
secret_access_key: Settings.aws_secret_access_key
}
}
# config.action_controller.perform_caching = true
#
# We don't want to use memory_store, it's just a convenient choice for development.
# AWS provides a managed memcached/redis service, with a t2.micro instances (1Gb) as
# part of their free tier.
#
# config.cache_store = :memory_store, { size: 10.megabytes }
config.cache_store = :readthis_store, {
namespace: 'cache',
expires_in: 1.day.to_i,
redis: { host: Settings.redis.host,
port: Settings.redis.port, drive: :hiredis }
}
# In production, we only accept CORS request from sumofus.org or its subdomains.
config.middleware.insert_before 0, 'Rack::Cors', logger: (-> { Rails.logger }) do
allow do
origins(/^(https?:\/\/)?([a-z0-9-]+\.)?sumofus\.org$/i)
resource '*',
headers: :any,
methods: [:get, :post, :delete, :put, :patch, :options, :head],
max_age: 86_400
end
end
end