refactor: repo (#1070)
This commit is contained in:
91
packages/web-server/config/application.rb
Normal file
91
packages/web-server/config/application.rb
Normal file
@@ -0,0 +1,91 @@
|
||||
require_relative 'boot'
|
||||
# require 'rails/all'
|
||||
|
||||
require "active_model/railtie"
|
||||
require "action_controller/railtie"
|
||||
require "action_mailer/railtie"
|
||||
require "action_view/railtie"
|
||||
require "active_job/railtie" # Only for Rails >= 4.2
|
||||
require "action_cable/engine" # Only for Rails >= 5.0
|
||||
require "sprockets/railtie"
|
||||
require "rails/test_unit/railtie"
|
||||
|
||||
# Require the gems listed in Gemfile, including any gems
|
||||
# you've limited to :test, :development, or :production.
|
||||
Bundler.require(*Rails.groups)
|
||||
|
||||
module Web
|
||||
class Application < Rails::Application
|
||||
# Cross-Origin Resource Sharing (CORS) for Rack compatible web applications.
|
||||
config.middleware.insert_before 0, Rack::Cors do
|
||||
allow do
|
||||
origins '*'
|
||||
resource '*', :headers => :any, :methods => [:get, :post, :put, :patch, :delete, :options], :expose => ['Access-Token', 'Client', 'UID']
|
||||
end
|
||||
end
|
||||
|
||||
# config.action_dispatch.default_headers = {
|
||||
# 'X-Frame-Options' => 'ALLOWALL'
|
||||
# }
|
||||
|
||||
SecureHeaders::Configuration.default do |config|
|
||||
# Handled by server
|
||||
config.x_frame_options = SecureHeaders::OPT_OUT
|
||||
config.x_content_type_options = SecureHeaders::OPT_OUT
|
||||
config.x_xss_protection = SecureHeaders::OPT_OUT
|
||||
config.hsts = SecureHeaders::OPT_OUT
|
||||
|
||||
config.csp = {
|
||||
# "meta" values. these will shape the header, but the values are not included in the header.
|
||||
preserve_schemes: true, # default: false. Schemes are removed from host sources to save bytes and discourage mixed content.
|
||||
# directive values: these values will directly translate into source directives
|
||||
default_src: %w(https: 'self'),
|
||||
base_uri: %w('self'),
|
||||
block_all_mixed_content: false, # see http://www.w3.org/TR/mixed-content/
|
||||
child_src: ["*", "blob:"],
|
||||
frame_src: ["*", "blob:"],
|
||||
connect_src: ["*", 'data:'],
|
||||
font_src: ['*', "'self'", 'data:'],
|
||||
form_action: %w('self'),
|
||||
frame_ancestors: ["*", "*.standardnotes.com", "*.standardnotes.org"],
|
||||
img_src: ["'self'", '* data:', 'blob:'],
|
||||
manifest_src: %w('self'),
|
||||
media_src: %w('self' blob: *.standardnotes.com),
|
||||
object_src: %w('self' blob: *.standardnotes.com),
|
||||
plugin_types: %w(),
|
||||
script_src: %w('self' 'unsafe-inline' 'unsafe-eval'),
|
||||
style_src: %w(* 'unsafe-inline'),
|
||||
upgrade_insecure_requests: false, # see https://www.w3.org/TR/upgrade-insecure-requests/
|
||||
}
|
||||
end
|
||||
|
||||
# config.middleware.use Rack::Deflater
|
||||
|
||||
config.middleware.insert_before(Rack::Sendfile, Rack::Deflater)
|
||||
|
||||
# Disable auto creation of additional resources with "rails generate"
|
||||
config.generators do |g|
|
||||
g.test_framework false
|
||||
g.view_specs false
|
||||
g.helper_specs false
|
||||
g.stylesheets = false
|
||||
g.javascripts = false
|
||||
g.helper = false
|
||||
end
|
||||
|
||||
config.action_mailer.default_url_options = { host: ENV['APP_HOST'] }
|
||||
|
||||
# SMTP settings
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.smtp_settings = {
|
||||
:address => ENV['SMTP_HOST'],
|
||||
:port => ENV['SMTP_PORT'],
|
||||
:domain => ENV['SMTP_DOMAIN'],
|
||||
:user_name => ENV['SMTP_USERNAME'],
|
||||
:password => ENV['SMTP_PASSWORD'],
|
||||
:authentication => 'login',
|
||||
:enable_starttls_auto => true # detects and uses STARTTLS
|
||||
}
|
||||
|
||||
end
|
||||
end
|
||||
3
packages/web-server/config/boot.rb
Normal file
3
packages/web-server/config/boot.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||||
|
||||
require 'bundler/setup' # Set up gems listed in the Gemfile.
|
||||
15
packages/web-server/config/cap.example.yml
Normal file
15
packages/web-server/config/cap.example.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
default: &default
|
||||
key_path: /path/to/key.pem
|
||||
repo_url: https://github.com/sn-project/sn-web-client.git
|
||||
user: ssh_username
|
||||
|
||||
staging:
|
||||
<<: *default
|
||||
server: staging.yourdomain.com
|
||||
branch: staging
|
||||
deploy_to: ~/sn-staging-client
|
||||
|
||||
production:
|
||||
<<: *default
|
||||
server: yourdomain.com
|
||||
deploy_to: ~/sn-prod-client
|
||||
40
packages/web-server/config/database.yml
Normal file
40
packages/web-server/config/database.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
# MySQL. Versions 5.0+ are recommended.
|
||||
#
|
||||
# Install the MYSQL driver
|
||||
# gem install mysql2
|
||||
#
|
||||
# Ensure the MySQL gem is defined in your Gemfile
|
||||
# gem 'mysql2'
|
||||
#
|
||||
# And be sure to use new-style password hashing:
|
||||
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
|
||||
#
|
||||
default: &default
|
||||
adapter: mysql2
|
||||
encoding: utf8
|
||||
pool: 5
|
||||
username: <%= ENV['DB_USERNAME'] %>
|
||||
password: <%= ENV['DB_PASSWORD'] %>
|
||||
database: <%= ENV['DB_DATABASE'] %>
|
||||
host: <%= ENV['DB_HOST'] %>
|
||||
port: <%= ENV['DB_PORT'] %>
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
<<: *default
|
||||
|
||||
# You can use this database configuration with:
|
||||
#
|
||||
# production:
|
||||
# url: <%= ENV['DATABASE_URL'] %>
|
||||
#
|
||||
staging:
|
||||
<<: *default
|
||||
|
||||
production:
|
||||
<<: *default
|
||||
49
packages/web-server/config/deploy.rb
Normal file
49
packages/web-server/config/deploy.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
CAP_CONFIG = YAML.load_file("config/cap.yml")
|
||||
|
||||
set :application, 'standard-notes'
|
||||
set :repo_url, CAP_CONFIG["default"]["repo_url"]
|
||||
|
||||
# Default branch is :master
|
||||
set :branch, `git rev-parse --abbrev-ref main`.chomp
|
||||
|
||||
# Default deploy_to directory is /var/www/my_app_name
|
||||
# set :deploy_to, '/var/www/my_app_name'
|
||||
|
||||
# Default value for :format is :airbrussh.
|
||||
# set :format, :airbrussh
|
||||
|
||||
# You can configure the Airbrussh format using :format_options.
|
||||
# These are the defaults.
|
||||
# set :format_options, command_output: true, log_file: 'log/capistrano.log', color: :auto, truncate: :auto
|
||||
|
||||
# Default value for :pty is false
|
||||
# set :pty, true
|
||||
|
||||
# Default value for :linked_files is []
|
||||
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
|
||||
set :linked_files, fetch(:linked_files, []).push('.env')
|
||||
|
||||
# Default value for linked_dirs is []
|
||||
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system')
|
||||
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system', 'public/uploads')
|
||||
|
||||
# Default value for keep_releases is 5
|
||||
# set :keep_releases, 5
|
||||
|
||||
namespace :deploy do
|
||||
|
||||
after :restart, :clear_cache do
|
||||
on roles(:web), in: :groups, limit: 3, wait: 5 do
|
||||
# Here we can do anything such as:
|
||||
within release_path do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set :ssh_options, {
|
||||
keys: %W( #{CAP_CONFIG['default']['key_path']} ),
|
||||
forward_agent: false,
|
||||
auth_methods: %w(publickey)
|
||||
}
|
||||
63
packages/web-server/config/deploy/production.rb
Normal file
63
packages/web-server/config/deploy/production.rb
Normal file
@@ -0,0 +1,63 @@
|
||||
# server-based syntax
|
||||
# ======================
|
||||
# Defines a single server with a list of roles and multiple properties.
|
||||
# You can define all roles on a single server, or split them:
|
||||
|
||||
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
|
||||
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
|
||||
# server 'db.example.com', user: 'deploy', roles: %w{db}
|
||||
|
||||
server CAP_CONFIG['production']['server'], user: CAP_CONFIG['production']['user'], roles: %w{app db web}
|
||||
|
||||
set :deploy_to, CAP_CONFIG['production']['deploy_to']
|
||||
|
||||
# role-based syntax
|
||||
# ==================
|
||||
|
||||
# Defines a role with one or multiple servers. The primary server in each
|
||||
# group is considered to be the first unless any hosts have the primary
|
||||
# property set. Specify the username and a domain or IP for the server.
|
||||
# Don't use `:all`, it's a meta role.
|
||||
|
||||
# role :app, %w{deploy@example.com}, my_property: :my_value
|
||||
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
|
||||
# role :db, %w{deploy@example.com}
|
||||
|
||||
|
||||
|
||||
# Configuration
|
||||
# =============
|
||||
# You can set any configuration variable like in config/deploy.rb
|
||||
# These variables are then only loaded and set in this stage.
|
||||
# For available Capistrano configuration variables see the documentation page.
|
||||
# http://capistranorb.com/documentation/getting-started/configuration/
|
||||
# Feel free to add new variables to customise your setup.
|
||||
|
||||
|
||||
|
||||
# Custom SSH Options
|
||||
# ==================
|
||||
# You may pass any option but keep in mind that net/ssh understands a
|
||||
# limited set of options, consult the Net::SSH documentation.
|
||||
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
|
||||
#
|
||||
# Global options
|
||||
# --------------
|
||||
# set :ssh_options, {
|
||||
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
||||
# forward_agent: false,
|
||||
# auth_methods: %w(password)
|
||||
# }
|
||||
#
|
||||
# The server-based syntax can be used to override options:
|
||||
# ------------------------------------
|
||||
# server 'example.com',
|
||||
# user: 'user_name',
|
||||
# roles: %w{web app},
|
||||
# ssh_options: {
|
||||
# user: 'user_name', # overrides user setting above
|
||||
# keys: %w(/home/user_name/.ssh/id_rsa),
|
||||
# forward_agent: false,
|
||||
# auth_methods: %w(publickey password)
|
||||
# # password: 'please use keys'
|
||||
# }
|
||||
65
packages/web-server/config/deploy/staging.rb
Normal file
65
packages/web-server/config/deploy/staging.rb
Normal file
@@ -0,0 +1,65 @@
|
||||
# server-based syntax
|
||||
# ======================
|
||||
# Defines a single server with a list of roles and multiple properties.
|
||||
# You can define all roles on a single server, or split them:
|
||||
|
||||
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
|
||||
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
|
||||
# server 'db.example.com', user: 'deploy', roles: %w{db}
|
||||
|
||||
server CAP_CONFIG['staging']['server'], user: CAP_CONFIG['staging']['user'], roles: %w{app db web}
|
||||
|
||||
set :branch, CAP_CONFIG['staging']['branch']
|
||||
|
||||
set :deploy_to, CAP_CONFIG['staging']['deploy_to']
|
||||
|
||||
# role-based syntax
|
||||
# ==================
|
||||
|
||||
# Defines a role with one or multiple servers. The primary server in each
|
||||
# group is considered to be the first unless any hosts have the primary
|
||||
# property set. Specify the username and a domain or IP for the server.
|
||||
# Don't use `:all`, it's a meta role.
|
||||
|
||||
# role :app, %w{deploy@example.com}, my_property: :my_value
|
||||
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
|
||||
# role :db, %w{deploy@example.com}
|
||||
|
||||
|
||||
|
||||
# Configuration
|
||||
# =============
|
||||
# You can set any configuration variable like in config/deploy.rb
|
||||
# These variables are then only loaded and set in this stage.
|
||||
# For available Capistrano configuration variables see the documentation page.
|
||||
# http://capistranorb.com/documentation/getting-started/configuration/
|
||||
# Feel free to add new variables to customise your setup.
|
||||
|
||||
|
||||
|
||||
# Custom SSH Options
|
||||
# ==================
|
||||
# You may pass any option but keep in mind that net/ssh understands a
|
||||
# limited set of options, consult the Net::SSH documentation.
|
||||
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
|
||||
#
|
||||
# Global options
|
||||
# --------------
|
||||
# set :ssh_options, {
|
||||
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
||||
# forward_agent: false,
|
||||
# auth_methods: %w(password)
|
||||
# }
|
||||
#
|
||||
# The server-based syntax can be used to override options:
|
||||
# ------------------------------------
|
||||
# server 'example.com',
|
||||
# user: 'user_name',
|
||||
# roles: %w{web app},
|
||||
# ssh_options: {
|
||||
# user: 'user_name', # overrides user setting above
|
||||
# keys: %w(/home/user_name/.ssh/id_rsa),
|
||||
# forward_agent: false,
|
||||
# auth_methods: %w(publickey password)
|
||||
# # password: 'please use keys'
|
||||
# }
|
||||
5
packages/web-server/config/environment.rb
Normal file
5
packages/web-server/config/environment.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
# Load the Rails application.
|
||||
require_relative 'application'
|
||||
|
||||
# Initialize the Rails application.
|
||||
Rails.application.initialize!
|
||||
64
packages/web-server/config/environments/development.rb
Normal file
64
packages/web-server/config/environments/development.rb
Normal file
@@ -0,0 +1,64 @@
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# config.assets.js_compressor = Uglifier.new(mangle: false)\
|
||||
|
||||
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
|
||||
# In the development environment your application's code is reloaded on
|
||||
# every request. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the web server when you make code changes.
|
||||
config.cache_classes = false
|
||||
config.reload_classes_only_on_change = true
|
||||
|
||||
# Do not eager load code on boot.
|
||||
config.eager_load = false
|
||||
|
||||
MAX_LOG_MEGABYTES = 50
|
||||
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
|
||||
|
||||
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
||||
config.logger = ActiveSupport::Logger.new(STDOUT)
|
||||
end
|
||||
|
||||
config.colorize_logging = false
|
||||
config.logger.formatter = StandardNotesFormatter.new
|
||||
|
||||
# Show full error reports and disable caching.
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# Don't care if the mailer can't send.
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
config.public_file_server.enabled = true
|
||||
|
||||
# Print deprecation notices to the Rails logger.
|
||||
config.active_support.deprecation = :log
|
||||
|
||||
# Raise an error on page load if there are pending migrations.
|
||||
# config.active_record.migration_error = :page_load
|
||||
|
||||
# Debug mode disables concatenation and preprocessing of assets.
|
||||
# This option may cause significant delays in view rendering with a large
|
||||
# number of complex assets.
|
||||
config.assets.debug = true
|
||||
|
||||
# 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
|
||||
|
||||
# Adds additional error checking when serving assets at runtime.
|
||||
# Checks for improperly declared sprockets dependencies.
|
||||
# Raises helpful error messages.
|
||||
config.assets.raise_runtime_errors = true
|
||||
|
||||
config.assets.logger = false
|
||||
config.assets.quiet = true
|
||||
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
|
||||
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
end
|
||||
94
packages/web-server/config/environments/production.rb
Normal file
94
packages/web-server/config/environments/production.rb
Normal file
@@ -0,0 +1,94 @@
|
||||
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
|
||||
|
||||
MAX_LOG_MEGABYTES = 50
|
||||
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
|
||||
|
||||
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
||||
config.logger = ActiveSupport::Logger.new(STDOUT)
|
||||
end
|
||||
|
||||
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'INFO').to_sym
|
||||
|
||||
config.colorize_logging = false
|
||||
config.logger.formatter = StandardNotesFormatter.new
|
||||
|
||||
# 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
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
config.public_file_server.enabled = true
|
||||
|
||||
# Mount Action Cable outside main process or domain
|
||||
# config.action_cable.mount_path = nil
|
||||
# config.action_cable.url = 'wss://example.com/cable'
|
||||
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
||||
|
||||
|
||||
|
||||
# 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 = true
|
||||
|
||||
# Compress JavaScripts and CSS.
|
||||
config.assets.compress = true
|
||||
# config.assets.js_compressor = Uglifier.new(mangle: false)
|
||||
config.assets.js_compressor = :uglifier
|
||||
config.assets.css_compressor = :sass
|
||||
|
||||
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
||||
config.assets.compile = 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.logger = false
|
||||
config.assets.quiet = 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
|
||||
|
||||
# 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 = 'http://assets.example.com'
|
||||
|
||||
# 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.
|
||||
ActiveSupport::Deprecation.silenced = true
|
||||
|
||||
# Do not dump schema after migrations.
|
||||
# config.active_record.dump_schema_after_migration = false
|
||||
end
|
||||
79
packages/web-server/config/environments/staging.rb
Normal file
79
packages/web-server/config/environments/staging.rb
Normal file
@@ -0,0 +1,79 @@
|
||||
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
|
||||
|
||||
# Use a different logger for distributed setups.
|
||||
# require 'syslog/logger'
|
||||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
||||
|
||||
MAX_LOG_MEGABYTES = 50
|
||||
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
|
||||
|
||||
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
||||
config.logger = ActiveSupport::Logger.new(STDOUT)
|
||||
end
|
||||
|
||||
# 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 = true
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# Compress JavaScripts and CSS.
|
||||
config.assets.compress = true
|
||||
# config.assets.js_compressor = Uglifier.new(mangle: false)
|
||||
config.assets.js_compressor = :uglifier
|
||||
config.assets.css_compressor = :sass
|
||||
|
||||
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
||||
config.assets.compile = 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 = :debug
|
||||
|
||||
# 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 = 'http://assets.example.com'
|
||||
|
||||
# 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
|
||||
|
||||
# Do not dump schema after migrations.
|
||||
# config.active_record.dump_schema_after_migration = false
|
||||
end
|
||||
42
packages/web-server/config/environments/test.rb
Normal file
42
packages/web-server/config/environments/test.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# The test environment is used exclusively to run your application's
|
||||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
# and recreated between test runs. Don't rely on the data there!
|
||||
config.cache_classes = true
|
||||
|
||||
# Do not eager load code on boot. This avoids loading your whole application
|
||||
# just for the purpose of running a single test. If you are using a tool that
|
||||
# preloads Rails for running tests, you may have to set it to true.
|
||||
config.eager_load = false
|
||||
|
||||
# Configure public file server for tests with Cache-Control for performance.
|
||||
config.public_file_server.enabled = true
|
||||
config.public_file_server.headers = {
|
||||
'Cache-Control' => 'public, max-age=3600'
|
||||
}
|
||||
|
||||
# Show full error reports and disable caching.
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# Raise exceptions instead of rendering exception templates.
|
||||
config.action_dispatch.show_exceptions = false
|
||||
|
||||
# Disable request forgery protection in test environment.
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
# Tell Action Mailer not to deliver emails to the real world.
|
||||
# The :test delivery method accumulates sent emails in the
|
||||
# ActionMailer::Base.deliveries array.
|
||||
config.action_mailer.delivery_method = :test
|
||||
|
||||
# Print deprecation notices to the stderr.
|
||||
config.active_support.deprecation = :stderr
|
||||
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# ApplicationController.renderer.defaults.merge!(
|
||||
# http_host: 'example.org',
|
||||
# https: false
|
||||
# )
|
||||
6
packages/web-server/config/initializers/assets.rb
Normal file
6
packages/web-server/config/initializers/assets.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# Version of your assets, change this if you want to expire all your assets.
|
||||
Rails.application.config.assets.version = '1.1'
|
||||
|
||||
Rails.application.config.assets.paths << Rails.root.join('..', 'web', 'dist')
|
||||
|
||||
Rails.application.config.assets.precompile += ['app.js', 'app.css']
|
||||
@@ -0,0 +1,7 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
||||
|
||||
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
||||
# Rails.backtrace_cleaner.remove_silencers!
|
||||
@@ -0,0 +1,5 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Specify a serializer for the signed and encrypted cookie jars.
|
||||
# Valid options are :json, :marshal, and :hybrid.
|
||||
Rails.application.config.action_dispatch.cookies_serializer = :json
|
||||
@@ -0,0 +1,4 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
Rails.application.config.filter_parameters += [:password]
|
||||
16
packages/web-server/config/initializers/inflections.rb
Normal file
16
packages/web-server/config/initializers/inflections.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new inflection rules using the following format. Inflections
|
||||
# are locale specific, and you may define rules for as many different
|
||||
# locales as you wish. All of these examples are active by default:
|
||||
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
# inflect.plural /^(ox)$/i, '\1en'
|
||||
# inflect.singular /^(ox)en/i, '\1'
|
||||
# inflect.irregular 'person', 'people'
|
||||
# inflect.uncountable %w( fish sheep )
|
||||
# end
|
||||
|
||||
# These inflection rules are supported but not enabled by default:
|
||||
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
# inflect.acronym 'RESTful'
|
||||
# end
|
||||
9
packages/web-server/config/initializers/json.rb
Normal file
9
packages/web-server/config/initializers/json.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# fix for JSON deprecation warnings. See: https://github.com/flori/json/issues/399#issuecomment-734863279
|
||||
|
||||
module JSON
|
||||
module_function
|
||||
|
||||
def parse(source, opts = {})
|
||||
Parser.new(source, **opts).parse
|
||||
end
|
||||
end
|
||||
7
packages/web-server/config/initializers/lograge.rb
Normal file
7
packages/web-server/config/initializers/lograge.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
Rails.application.configure do
|
||||
config.lograge.enabled = true
|
||||
|
||||
# Generate log in JSON
|
||||
config.lograge.formatter = Lograge::Formatters::Json.new
|
||||
config.lograge.ignore_actions = ['HealthCheckController#index']
|
||||
end
|
||||
4
packages/web-server/config/initializers/mime_types.rb
Normal file
4
packages/web-server/config/initializers/mime_types.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new mime types for use in respond_to blocks:
|
||||
# Mime::Type.register "text/richtext", :rtf
|
||||
@@ -0,0 +1,23 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
#
|
||||
# This file contains migration options to ease your Rails 5.0 upgrade.
|
||||
#
|
||||
# Once upgraded flip defaults one by one to migrate to the new default.
|
||||
#
|
||||
# Read the Rails 5.0 release notes for more info on each option.
|
||||
|
||||
# Enable per-form CSRF tokens. Previous versions had false.
|
||||
Rails.application.config.action_controller.per_form_csrf_tokens = false
|
||||
|
||||
# Enable origin-checking CSRF mitigation. Previous versions had false.
|
||||
Rails.application.config.action_controller.forgery_protection_origin_check = false
|
||||
|
||||
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
|
||||
# Previous versions had false.
|
||||
ActiveSupport.to_time_preserves_timezone = false
|
||||
|
||||
# Require `belongs_to` associations by default. Previous versions had false.
|
||||
# Rails.application.config.active_record.belongs_to_required_by_default = false
|
||||
|
||||
# Do not halt callback chains when a callback returns false. Previous versions had true.
|
||||
ActiveSupport.halt_callback_chains_on_return_false = true
|
||||
3
packages/web-server/config/initializers/session_store.rb
Normal file
3
packages/web-server/config/initializers/session_store.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
Rails.application.config.session_store :cookie_store, key: '_sn_session'
|
||||
14
packages/web-server/config/initializers/wrap_parameters.rb
Normal file
14
packages/web-server/config/initializers/wrap_parameters.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# This file contains settings for ActionController::ParamsWrapper which
|
||||
# is enabled by default.
|
||||
|
||||
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
wrap_parameters format: [:json]
|
||||
end
|
||||
|
||||
# To enable root element in JSON for ActiveRecord objects.
|
||||
# ActiveSupport.on_load(:active_record) do
|
||||
# self.include_root_in_json = true
|
||||
# end
|
||||
23
packages/web-server/config/locales/en.yml
Normal file
23
packages/web-server/config/locales/en.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
# Files in the config/locales directory are used for internationalization
|
||||
# and are automatically loaded by Rails. If you want to use locales other
|
||||
# than English, add the necessary files in this directory.
|
||||
#
|
||||
# To use the locales, use `I18n.t`:
|
||||
#
|
||||
# I18n.t 'hello'
|
||||
#
|
||||
# In views, this is aliased to just `t`:
|
||||
#
|
||||
# <%= t('hello') %>
|
||||
#
|
||||
# To use a different locale, set it with `I18n.locale`:
|
||||
#
|
||||
# I18n.locale = :es
|
||||
#
|
||||
# This would use the information in config/locales/es.yml.
|
||||
#
|
||||
# To learn more, please read the Rails Internationalization guide
|
||||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
en:
|
||||
hello: "Hello world"
|
||||
53
packages/web-server/config/puma.rb
Normal file
53
packages/web-server/config/puma.rb
Normal file
@@ -0,0 +1,53 @@
|
||||
# Puma can serve each request in a thread from an internal thread pool.
|
||||
# The `threads` method setting takes two numbers a minimum and maximum.
|
||||
# Any libraries that use thread pools should be configured to match
|
||||
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
||||
# and maximum, this matches the default thread size of Active Record.
|
||||
#
|
||||
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
|
||||
threads threads_count, threads_count
|
||||
|
||||
|
||||
#!/usr/bin/env puma
|
||||
|
||||
# start puma with:
|
||||
# RAILS_ENV=production bundle exec puma -C ./config/puma.rb
|
||||
|
||||
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
|
||||
#
|
||||
port ENV.fetch("PORT") { 3000 }
|
||||
|
||||
# Specifies the `environment` that Puma will run in.
|
||||
#
|
||||
environment ENV.fetch("RAILS_ENV") { "development" }
|
||||
|
||||
# Specifies the number of `workers` to boot in clustered mode.
|
||||
# Workers are forked webserver processes. If using threads and workers together
|
||||
# the concurrency of the application would be max `threads` * `workers`.
|
||||
# Workers do not work on JRuby or Windows (both of which do not support
|
||||
# processes).
|
||||
#
|
||||
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
||||
|
||||
# Use the `preload_app!` method when specifying a `workers` number.
|
||||
# This directive tells Puma to first boot the application and load code
|
||||
# before forking the application. This takes advantage of Copy On Write
|
||||
# process behavior so workers use less memory. If you use this option
|
||||
# you need to make sure to reconnect any threads in the `on_worker_boot`
|
||||
# block.
|
||||
#
|
||||
# preload_app!
|
||||
|
||||
# The code in the `on_worker_boot` will be called if you are using
|
||||
# clustered mode by specifying a number of `workers`. After each worker
|
||||
# process is booted this block will be run, if you are using `preload_app!`
|
||||
# option you will want to use this block to reconnect to any threads
|
||||
# or connections that may have been created at application boot, Ruby
|
||||
# cannot share connections between processes.
|
||||
#
|
||||
# on_worker_boot do
|
||||
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
||||
# end
|
||||
|
||||
# Allow puma to be restarted by `rails restart` command.
|
||||
plugin :tmp_restart
|
||||
7
packages/web-server/config/routes.rb
Normal file
7
packages/web-server/config/routes.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
Rails.application.routes.draw do
|
||||
get "/healthcheck" => "health_check#index"
|
||||
|
||||
get '*unmatched_route', to: 'application#route_not_found'
|
||||
|
||||
root 'application#app'
|
||||
end
|
||||
25
packages/web-server/config/secrets.yml
Normal file
25
packages/web-server/config/secrets.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Your secret key is used for verifying the integrity of signed cookies.
|
||||
# If you change this key, all old signed cookies will become invalid!
|
||||
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
# You can use `rake secret` to generate a secure secret key.
|
||||
|
||||
# Make sure the secrets in this file are kept private
|
||||
# if you're sharing your code publicly.
|
||||
|
||||
development:
|
||||
secret_key_base: e3336569c7fc35724ab2f19ca4024f70f20a372ffccf619064007593aa7e4ad0afafb88eb4c03620bdb10f3e975b0240a95c8cfc8b7664750208b9cf9b039f01
|
||||
|
||||
test:
|
||||
secret_key_base: 7eedf23ca7967ab47b0a7e1c1f3bbf1f804f0d76ae7b27e8a37e9cbbffad95f099901f5b4821f391bcdeb104d2e0b1333cf56d485ad3ee41bc7fad2fbaf7ec3e
|
||||
|
||||
staging:
|
||||
secret_key_base: fd5255d5cc6a90944a292df8041cd125e20f28fd62cabf092133ce569457e7399e90294dc0413a43ed7e15f8414593632ff6b41b34d6361fab2069f6351958f6
|
||||
|
||||
# Do not keep production secrets in the repository,
|
||||
# instead read values from the environment.
|
||||
production:
|
||||
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
||||
6
packages/web-server/config/spring.rb
Normal file
6
packages/web-server/config/spring.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
%w(
|
||||
.ruby-version
|
||||
.rbenv-vars
|
||||
tmp/restart.txt
|
||||
tmp/caching-dev.txt
|
||||
).each { |path| Spring.watch(path) }
|
||||
Reference in New Issue
Block a user