add Dockerfile and configure production app
This commit is contained in:
@@ -21,5 +21,7 @@ module DocuSeal
|
||||
config.active_storage.routes_prefix = ''
|
||||
|
||||
config.action_view.frozen_string_literal = true
|
||||
|
||||
config.middleware.insert_before ActionDispatch::Static, Rack::Deflater
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,5 +2,27 @@
|
||||
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||||
|
||||
if ENV['RAILS_ENV'] == 'production' && ENV['SECRET_KEY_BASE'].to_s.empty?
|
||||
require 'dotenv'
|
||||
require 'securerandom'
|
||||
|
||||
dotenv_path = './docuseal.env'
|
||||
|
||||
unless File.exist?(dotenv_path)
|
||||
default_env = <<~TEXT
|
||||
DATABASE_URL= # keep empty to use sqlite or specify postgresql database URL
|
||||
SECRET_KEY_BASE=#{SecureRandom.hex(64)}
|
||||
TEXT
|
||||
|
||||
File.write(dotenv_path, default_env)
|
||||
end
|
||||
|
||||
database_url = ENV.fetch('DATABASE_URL', nil)
|
||||
|
||||
Dotenv.load(dotenv_path)
|
||||
|
||||
ENV['DATABASE_URL'] = ENV['DATABASE_URL'].to_s.empty? ? database_url : ENV.fetch('DATABASE_URL', nil)
|
||||
end
|
||||
|
||||
require 'bundler/setup' # Set up gems listed in the Gemfile.
|
||||
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
|
||||
|
||||
+3
-2
@@ -11,5 +11,6 @@ test:
|
||||
database: docuseal_test
|
||||
|
||||
production:
|
||||
<<: *default
|
||||
database: db/production.sqlite3
|
||||
adapter: <%= ENV['DATABASE_URL'].present? ? 'postgresql' : 'sqlite3' %>
|
||||
encoding: unicode
|
||||
database: <%= ENV['WORKDIR'] || '.' %>/db.sqlite3
|
||||
|
||||
@@ -9,6 +9,11 @@ Rails.application.configure do
|
||||
# Code is not reloaded between requests.
|
||||
config.cache_classes = true
|
||||
|
||||
config.public_file_server.headers = {
|
||||
'Cache-Control' => 'public, s-maxage=31536000, max-age=15552000',
|
||||
'Expires' => 1.year.from_now.to_fs(:rfc822)
|
||||
}
|
||||
|
||||
# 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.
|
||||
@@ -18,6 +23,7 @@ Rails.application.configure do
|
||||
# Full error reports are disabled and caching is turned on.
|
||||
config.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
config.active_record.sqlite3_production_warning = false
|
||||
|
||||
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
||||
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
||||
@@ -75,12 +81,24 @@ Rails.application.configure do
|
||||
logger.formatter = config.log_formatter
|
||||
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
||||
|
||||
encryption_secret = Digest::SHA256.hexdigest(ENV['SECRET_KEY_BASE'].to_s)
|
||||
|
||||
config.active_record.encryption = {
|
||||
primary_key: ENV['SECRET_KEY_BASE'].first(32),
|
||||
deterministic_key: ENV['SECRET_KEY_BASE'].last(32),
|
||||
key_derivation_salt: ENV.fetch('SECRET_KEY_BASE', nil)
|
||||
primary_key: encryption_secret.first(32),
|
||||
deterministic_key: encryption_secret.last(32),
|
||||
key_derivation_salt: encryption_secret
|
||||
}
|
||||
|
||||
# Do not dump schema after migrations.
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
|
||||
config.lograge.enabled = true
|
||||
config.lograge.formatter = Lograge::Formatters::Json.new
|
||||
config.lograge.base_controller_class = ['ActionController::API', 'ActionController::Base']
|
||||
|
||||
config.lograge.custom_payload do |controller|
|
||||
{
|
||||
fwd: controller.request.ip
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,8 @@ ActiveSupport.on_load(:active_storage_attachment) do
|
||||
has_many_attached :preview_images
|
||||
end
|
||||
|
||||
ActiveStorage::LogSubscriber.detach_from(:active_storage) if Rails.env.production?
|
||||
|
||||
Rails.configuration.to_prepare do
|
||||
ActiveStorage::DiskController.after_action do
|
||||
response.set_header('Cache-Control', 'public, max-age=31536000') if action_name == 'show'
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ActiveRecord::Tasks::DatabaseTasks.migrate if ENV['RAILS_ENV'] == 'production'
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
# 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.
|
||||
#
|
||||
max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 10)
|
||||
max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 15)
|
||||
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
|
||||
threads min_threads_count, max_threads_count
|
||||
|
||||
@@ -24,7 +24,7 @@ port ENV.fetch('PORT', 3000)
|
||||
environment ENV.fetch('RAILS_ENV', 'development')
|
||||
|
||||
# Specifies the `pidfile` that Puma will use.
|
||||
pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')
|
||||
# pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')
|
||||
|
||||
# Specifies the number of `workers` to boot in clustered mode.
|
||||
# Workers are forked web server processes. If using threads and workers together
|
||||
|
||||
@@ -5,13 +5,14 @@ default: &default
|
||||
public_root_path: public
|
||||
public_output_path: packs
|
||||
cache_path: tmp/webpacker
|
||||
webpacker_precompile: true
|
||||
shakapacker_precompile: true
|
||||
webpack_compile_output: true
|
||||
additional_paths: []
|
||||
webpack_loader: 'babel'
|
||||
compiler_strategy: digest
|
||||
cache_manifest: false
|
||||
ensure_consistent_versioning: false
|
||||
useContentHash: false
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
local:
|
||||
service: Disk
|
||||
root: <%= ENV['WORKDIR'] %>docuseal-attachments
|
||||
root: <%= ENV['WORKDIR'] || '.' %>/attachments
|
||||
public: true
|
||||
|
||||
disk:
|
||||
service: Disk
|
||||
root: <%= ENV['WORKDIR'] %>docuseal-attachments
|
||||
root: <%= ENV['WORKDIR'] || '.' %>/attachments
|
||||
public: true
|
||||
|
||||
aws_s3:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const { webpackConfig, merge } = require('shakapacker')
|
||||
const { globalMutableWebpackConfig, merge } = require('shakapacker')
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||
const { VueLoaderPlugin } = require('vue-loader')
|
||||
|
||||
const configs = merge(webpackConfig, {
|
||||
const configs = merge(globalMutableWebpackConfig, {
|
||||
resolve: {
|
||||
extensions: ['.css', '.scss', '.vue']
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user