th7-clerk-sdk-ruby 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.env.example +3 -0
- data/.github/workflows/main.yml +30 -0
- data/.github/workflows/semgrep.yml +24 -0
- data/.gitignore +21 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +212 -0
- data/Gemfile +33 -0
- data/Gemfile.lock +300 -0
- data/Guardfile +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +278 -0
- data/Rakefile +56 -0
- data/apps/rack/app.rb +67 -0
- data/apps/rack/config.ru +17 -0
- data/apps/rack/middleware/disable_paths.rb +13 -0
- data/apps/rails-api/.dockerignore +41 -0
- data/apps/rails-api/.gitattributes +9 -0
- data/apps/rails-api/.gitignore +32 -0
- data/apps/rails-api/.kamal/hooks/docker-setup.sample +3 -0
- data/apps/rails-api/.kamal/hooks/post-deploy.sample +14 -0
- data/apps/rails-api/.kamal/hooks/post-proxy-reboot.sample +3 -0
- data/apps/rails-api/.kamal/hooks/pre-build.sample +51 -0
- data/apps/rails-api/.kamal/hooks/pre-connect.sample +47 -0
- data/apps/rails-api/.kamal/hooks/pre-deploy.sample +109 -0
- data/apps/rails-api/.kamal/hooks/pre-proxy-reboot.sample +3 -0
- data/apps/rails-api/.kamal/secrets +17 -0
- data/apps/rails-api/.rubocop.yml +8 -0
- data/apps/rails-api/.ruby-version +1 -0
- data/apps/rails-api/Dockerfile +69 -0
- data/apps/rails-api/Gemfile +54 -0
- data/apps/rails-api/Gemfile.lock +374 -0
- data/apps/rails-api/README.md +24 -0
- data/apps/rails-api/Rakefile +6 -0
- data/apps/rails-api/app/controllers/application_controller.rb +3 -0
- data/apps/rails-api/app/controllers/home_controller.rb +5 -0
- data/apps/rails-api/app/jobs/application_job.rb +7 -0
- data/apps/rails-api/app/mailers/application_mailer.rb +4 -0
- data/apps/rails-api/app/models/application_record.rb +3 -0
- data/apps/rails-api/app/views/layouts/mailer.html.erb +13 -0
- data/apps/rails-api/app/views/layouts/mailer.text.erb +1 -0
- data/apps/rails-api/bin/brakeman +7 -0
- data/apps/rails-api/bin/bundle +109 -0
- data/apps/rails-api/bin/dev +2 -0
- data/apps/rails-api/bin/docker-entrypoint +14 -0
- data/apps/rails-api/bin/jobs +6 -0
- data/apps/rails-api/bin/kamal +27 -0
- data/apps/rails-api/bin/rails +4 -0
- data/apps/rails-api/bin/rake +4 -0
- data/apps/rails-api/bin/rubocop +8 -0
- data/apps/rails-api/bin/setup +34 -0
- data/apps/rails-api/bin/thrust +5 -0
- data/apps/rails-api/config/application.rb +36 -0
- data/apps/rails-api/config/boot.rb +4 -0
- data/apps/rails-api/config/cable.yml +17 -0
- data/apps/rails-api/config/cache.yml +16 -0
- data/apps/rails-api/config/credentials.yml.enc +1 -0
- data/apps/rails-api/config/database.yml +41 -0
- data/apps/rails-api/config/deploy.yml +116 -0
- data/apps/rails-api/config/environment.rb +5 -0
- data/apps/rails-api/config/environments/development.rb +70 -0
- data/apps/rails-api/config/environments/production.rb +88 -0
- data/apps/rails-api/config/environments/test.rb +53 -0
- data/apps/rails-api/config/initializers/cors.rb +16 -0
- data/apps/rails-api/config/initializers/filter_parameter_logging.rb +8 -0
- data/apps/rails-api/config/initializers/inflections.rb +16 -0
- data/apps/rails-api/config/locales/en.yml +31 -0
- data/apps/rails-api/config/puma.rb +41 -0
- data/apps/rails-api/config/queue.yml +18 -0
- data/apps/rails-api/config/recurring.yml +10 -0
- data/apps/rails-api/config/routes.rb +10 -0
- data/apps/rails-api/config/storage.yml +34 -0
- data/apps/rails-api/config.ru +6 -0
- data/apps/rails-api/db/cable_schema.rb +11 -0
- data/apps/rails-api/db/cache_schema.rb +14 -0
- data/apps/rails-api/db/queue_schema.rb +129 -0
- data/apps/rails-api/db/seeds.rb +9 -0
- data/apps/rails-api/public/robots.txt +1 -0
- data/apps/rails-api/test/controllers/home_controller_test.rb +7 -0
- data/apps/rails-api/test/test_helper.rb +15 -0
- data/apps/rails-full/.dockerignore +47 -0
- data/apps/rails-full/.gitattributes +9 -0
- data/apps/rails-full/.gitignore +34 -0
- data/apps/rails-full/.kamal/hooks/docker-setup.sample +3 -0
- data/apps/rails-full/.kamal/hooks/post-deploy.sample +14 -0
- data/apps/rails-full/.kamal/hooks/post-proxy-reboot.sample +3 -0
- data/apps/rails-full/.kamal/hooks/pre-build.sample +51 -0
- data/apps/rails-full/.kamal/hooks/pre-connect.sample +47 -0
- data/apps/rails-full/.kamal/hooks/pre-deploy.sample +109 -0
- data/apps/rails-full/.kamal/hooks/pre-proxy-reboot.sample +3 -0
- data/apps/rails-full/.kamal/secrets +17 -0
- data/apps/rails-full/.rubocop.yml +8 -0
- data/apps/rails-full/.ruby-version +1 -0
- data/apps/rails-full/Dockerfile +72 -0
- data/apps/rails-full/Gemfile +70 -0
- data/apps/rails-full/Gemfile.lock +429 -0
- data/apps/rails-full/README.md +24 -0
- data/apps/rails-full/Rakefile +6 -0
- data/apps/rails-full/app/assets/stylesheets/application.css +10 -0
- data/apps/rails-full/app/controllers/application_controller.rb +6 -0
- data/apps/rails-full/app/controllers/home_controller.rb +11 -0
- data/apps/rails-full/app/helpers/application_helper.rb +2 -0
- data/apps/rails-full/app/helpers/home_helper.rb +2 -0
- data/apps/rails-full/app/javascript/application.js +3 -0
- data/apps/rails-full/app/javascript/controllers/application.js +9 -0
- data/apps/rails-full/app/javascript/controllers/hello_controller.js +7 -0
- data/apps/rails-full/app/javascript/controllers/index.js +4 -0
- data/apps/rails-full/app/jobs/application_job.rb +7 -0
- data/apps/rails-full/app/mailers/application_mailer.rb +4 -0
- data/apps/rails-full/app/models/application_record.rb +3 -0
- data/apps/rails-full/app/views/home/index.html.erb +7 -0
- data/apps/rails-full/app/views/layouts/application.html.erb +60 -0
- data/apps/rails-full/app/views/layouts/mailer.html.erb +13 -0
- data/apps/rails-full/app/views/layouts/mailer.text.erb +1 -0
- data/apps/rails-full/app/views/pwa/manifest.json.erb +22 -0
- data/apps/rails-full/app/views/pwa/service-worker.js +26 -0
- data/apps/rails-full/bin/brakeman +7 -0
- data/apps/rails-full/bin/bundle +109 -0
- data/apps/rails-full/bin/dev +2 -0
- data/apps/rails-full/bin/docker-entrypoint +14 -0
- data/apps/rails-full/bin/importmap +4 -0
- data/apps/rails-full/bin/jobs +6 -0
- data/apps/rails-full/bin/kamal +27 -0
- data/apps/rails-full/bin/rails +4 -0
- data/apps/rails-full/bin/rake +4 -0
- data/apps/rails-full/bin/rubocop +8 -0
- data/apps/rails-full/bin/setup +34 -0
- data/apps/rails-full/bin/thrust +5 -0
- data/apps/rails-full/config/application.rb +31 -0
- data/apps/rails-full/config/boot.rb +4 -0
- data/apps/rails-full/config/cable.yml +17 -0
- data/apps/rails-full/config/cache.yml +16 -0
- data/apps/rails-full/config/credentials.yml.enc +1 -0
- data/apps/rails-full/config/database.yml +41 -0
- data/apps/rails-full/config/deploy.yml +116 -0
- data/apps/rails-full/config/environment.rb +5 -0
- data/apps/rails-full/config/environments/development.rb +72 -0
- data/apps/rails-full/config/environments/production.rb +91 -0
- data/apps/rails-full/config/environments/test.rb +53 -0
- data/apps/rails-full/config/importmap.rb +7 -0
- data/apps/rails-full/config/initializers/assets.rb +7 -0
- data/apps/rails-full/config/initializers/clerk.rb +4 -0
- data/apps/rails-full/config/initializers/content_security_policy.rb +25 -0
- data/apps/rails-full/config/initializers/filter_parameter_logging.rb +8 -0
- data/apps/rails-full/config/initializers/inflections.rb +16 -0
- data/apps/rails-full/config/locales/en.yml +31 -0
- data/apps/rails-full/config/puma.rb +41 -0
- data/apps/rails-full/config/queue.yml +18 -0
- data/apps/rails-full/config/recurring.yml +10 -0
- data/apps/rails-full/config/routes.rb +15 -0
- data/apps/rails-full/config/storage.yml +34 -0
- data/apps/rails-full/config.ru +6 -0
- data/apps/rails-full/db/cable_schema.rb +11 -0
- data/apps/rails-full/db/cache_schema.rb +14 -0
- data/apps/rails-full/db/queue_schema.rb +129 -0
- data/apps/rails-full/db/seeds.rb +9 -0
- data/apps/rails-full/public/400.html +114 -0
- data/apps/rails-full/public/404.html +114 -0
- data/apps/rails-full/public/406-unsupported-browser.html +114 -0
- data/apps/rails-full/public/422.html +114 -0
- data/apps/rails-full/public/500.html +114 -0
- data/apps/rails-full/public/icon.png +0 -0
- data/apps/rails-full/public/icon.svg +3 -0
- data/apps/rails-full/public/robots.txt +1 -0
- data/apps/rails-full/test/application_system_test_case.rb +5 -0
- data/apps/rails-full/test/controllers/home_controller_test.rb +7 -0
- data/apps/rails-full/test/test_helper.rb +15 -0
- data/apps/sinatra/app.rb +29 -0
- data/apps/sinatra/config.ru +8 -0
- data/apps/sinatra/views/index.erb +44 -0
- data/bin/console +16 -0
- data/bin/release +21 -0
- data/bin/setup +8 -0
- data/clerk-sdk-ruby.gemspec +38 -0
- data/docs/clerk-logo-dark.png +0 -0
- data/docs/clerk-logo-light.png +0 -0
- data/lib/clerk/authenticatable.rb +32 -0
- data/lib/clerk/authenticate_context.rb +168 -0
- data/lib/clerk/authenticate_request.rb +261 -0
- data/lib/clerk/configuration.rb +84 -0
- data/lib/clerk/constants.rb +74 -0
- data/lib/clerk/error.rb +17 -0
- data/lib/clerk/jwks_cache.rb +37 -0
- data/lib/clerk/proxy.rb +135 -0
- data/lib/clerk/rack.rb +2 -0
- data/lib/clerk/rack_middleware.rb +112 -0
- data/lib/clerk/rails.rb +3 -0
- data/lib/clerk/railtie.rb +15 -0
- data/lib/clerk/sdk.rb +84 -0
- data/lib/clerk/sinatra.rb +52 -0
- data/lib/clerk/utils.rb +73 -0
- data/lib/clerk/version.rb +5 -0
- data/lib/clerk.rb +27 -0
- metadata +340 -0
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../Gemfile", __dir__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_requirement
|
64
|
+
@bundler_requirement ||=
|
65
|
+
env_var_version ||
|
66
|
+
cli_arg_version ||
|
67
|
+
bundler_requirement_for(lockfile_version)
|
68
|
+
end
|
69
|
+
|
70
|
+
def bundler_requirement_for(version)
|
71
|
+
return "#{Gem::Requirement.default}.a" unless version
|
72
|
+
|
73
|
+
bundler_gem_version = Gem::Version.new(version)
|
74
|
+
|
75
|
+
bundler_gem_version.approximate_recommendation
|
76
|
+
end
|
77
|
+
|
78
|
+
def load_bundler!
|
79
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
80
|
+
|
81
|
+
activate_bundler
|
82
|
+
end
|
83
|
+
|
84
|
+
def activate_bundler
|
85
|
+
gem_error = activation_error_handling do
|
86
|
+
gem "bundler", bundler_requirement
|
87
|
+
end
|
88
|
+
return if gem_error.nil?
|
89
|
+
require_error = activation_error_handling do
|
90
|
+
require "bundler/version"
|
91
|
+
end
|
92
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
93
|
+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
94
|
+
exit 42
|
95
|
+
end
|
96
|
+
|
97
|
+
def activation_error_handling
|
98
|
+
yield
|
99
|
+
nil
|
100
|
+
rescue StandardError, LoadError => e
|
101
|
+
e
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
m.load_bundler!
|
106
|
+
|
107
|
+
if m.invoked_as_script?
|
108
|
+
load Gem.bin_path("bundler", "bundle")
|
109
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/bin/bash -e
|
2
|
+
|
3
|
+
# Enable jemalloc for reduced memory usage and latency.
|
4
|
+
if [ -z "${LD_PRELOAD+x}" ]; then
|
5
|
+
LD_PRELOAD=$(find /usr/lib -name libjemalloc.so.2 -print -quit)
|
6
|
+
export LD_PRELOAD
|
7
|
+
fi
|
8
|
+
|
9
|
+
# If running the rails server then create or migrate existing database
|
10
|
+
if [ "${@: -2:1}" == "./bin/rails" ] && [ "${@: -1:1}" == "server" ]; then
|
11
|
+
./bin/rails db:prepare
|
12
|
+
fi
|
13
|
+
|
14
|
+
exec "${@}"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'kamal' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("kamal", "kamal")
|
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "rubygems"
|
3
|
+
require "bundler/setup"
|
4
|
+
|
5
|
+
# explicit rubocop config increases performance slightly while avoiding config confusion.
|
6
|
+
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
|
7
|
+
|
8
|
+
load Gem.bin_path("rubocop", "rubocop")
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
5
|
+
|
6
|
+
def system!(*args)
|
7
|
+
system(*args, exception: true)
|
8
|
+
end
|
9
|
+
|
10
|
+
FileUtils.chdir APP_ROOT do
|
11
|
+
# This script is a way to set up or update your development environment automatically.
|
12
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
13
|
+
# Add necessary setup steps to this file.
|
14
|
+
|
15
|
+
puts "== Installing dependencies =="
|
16
|
+
system("bundle check") || system!("bundle install")
|
17
|
+
|
18
|
+
# puts "\n== Copying sample files =="
|
19
|
+
# unless File.exist?("config/database.yml")
|
20
|
+
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
21
|
+
# end
|
22
|
+
|
23
|
+
puts "\n== Preparing database =="
|
24
|
+
system! "bin/rails db:prepare"
|
25
|
+
|
26
|
+
puts "\n== Removing old logs and tempfiles =="
|
27
|
+
system! "bin/rails log:clear tmp:clear"
|
28
|
+
|
29
|
+
unless ARGV.include?("--skip-server")
|
30
|
+
puts "\n== Starting development server =="
|
31
|
+
STDOUT.flush # flush the output before exec(2) so that it displays
|
32
|
+
exec "bin/dev"
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative "boot"
|
2
|
+
|
3
|
+
require "rails/all"
|
4
|
+
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
7
|
+
Bundler.require(*Rails.groups)
|
8
|
+
|
9
|
+
# Load environment variables manually from shared .env file
|
10
|
+
require "dotenv/rails"
|
11
|
+
Dotenv::Rails.files.unshift(File.expand_path(File.join("..", "..", ".env")))
|
12
|
+
|
13
|
+
module RailsApi
|
14
|
+
class Application < Rails::Application
|
15
|
+
# Initialize configuration defaults for originally generated Rails version.
|
16
|
+
config.load_defaults 8.0
|
17
|
+
|
18
|
+
# Please, add to the `ignore` list any other `lib` subdirectories that do
|
19
|
+
# not contain `.rb` files, or that should not be reloaded or eager loaded.
|
20
|
+
# Common ones are `templates`, `generators`, or `middleware`, for example.
|
21
|
+
config.autoload_lib(ignore: %w[assets tasks])
|
22
|
+
|
23
|
+
# Configuration for the application, engines, and railties goes here.
|
24
|
+
#
|
25
|
+
# These settings can be overridden in specific environments using the files
|
26
|
+
# in config/environments, which are processed later.
|
27
|
+
#
|
28
|
+
# config.time_zone = "Central Time (US & Canada)"
|
29
|
+
# config.eager_load_paths << Rails.root.join("extras")
|
30
|
+
|
31
|
+
# Only loads a smaller set of middleware suitable for API only apps.
|
32
|
+
# Middleware like session, flash, cookies can be added back manually.
|
33
|
+
# Skip views, helpers and assets when generating a new resource.
|
34
|
+
config.api_only = true
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Async adapter only works within the same process, so for manually triggering cable updates from a console,
|
2
|
+
# and seeing results in the browser, you must do so from the web console (running inside the dev process),
|
3
|
+
# not a terminal started via bin/rails console! Add "console" to any action or any ERB template view
|
4
|
+
# to make the web console appear.
|
5
|
+
development:
|
6
|
+
adapter: async
|
7
|
+
|
8
|
+
test:
|
9
|
+
adapter: test
|
10
|
+
|
11
|
+
production:
|
12
|
+
adapter: solid_cable
|
13
|
+
connects_to:
|
14
|
+
database:
|
15
|
+
writing: cable
|
16
|
+
polling_interval: 0.1.seconds
|
17
|
+
message_retention: 1.day
|
@@ -0,0 +1,16 @@
|
|
1
|
+
default: &default
|
2
|
+
store_options:
|
3
|
+
# Cap age of oldest cache entry to fulfill retention policies
|
4
|
+
# max_age: <%= 60.days.to_i %>
|
5
|
+
max_size: <%= 256.megabytes %>
|
6
|
+
namespace: <%= Rails.env %>
|
7
|
+
|
8
|
+
development:
|
9
|
+
<<: *default
|
10
|
+
|
11
|
+
test:
|
12
|
+
<<: *default
|
13
|
+
|
14
|
+
production:
|
15
|
+
database: cache
|
16
|
+
<<: *default
|
@@ -0,0 +1 @@
|
|
1
|
+
DxqE9vmSeT9Klo+KJDhexo4vQZXc4+vELnjH3Ajkh+aTfnR9mkTMkXhq7FwifMXvmXMtMoc1pZH9GuIJ9hvI3maLlPjYeb7Ktext15q8+xTP0hJrw7vpVQvqxMMC/pRVv0mFbzGBdQaOVer9toCFYSs3L+rrA3mbPOhc9uub+jwWAz3N61gjPOifX4Lu3vqU484m5lK35xHNyACcy2IUxv+1ijk+42pgedWFCiYvuANi3Lc9sb1SHRA8Tn4jVoj842WAQ4abiVg2P4IFGhSaveGP6zmanyoRg11UBlc62SmmnQL9kpaTnDWZqsf16dJ6pNkT3mvgjFRjhy9lvT+gbXLtJNqS8GP13KpO4kmLVD7YNXtjFyyqHamPaUeSUOZ8C8STeSl6YiU+40Ia9yIQ47zsNLLIaRR4MWhQGIEf+H0ZdwmmMOzGUGs+p6R6/RJb6W+JvI4wl8lgLlQBXOhA8Mi8sCYG+1nJQPXRAGIZ3uvH0cQqUGhWodrr--OJs3x4FP6O6jMsR0--oF4iFB4bTnDh0TJVPfIl3w==
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# SQLite. Versions 3.8.0 and up are supported.
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem "sqlite3"
|
6
|
+
#
|
7
|
+
default: &default
|
8
|
+
adapter: sqlite3
|
9
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
development:
|
13
|
+
<<: *default
|
14
|
+
database: storage/development.sqlite3
|
15
|
+
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
17
|
+
# re-generated from your development database when you run "rake".
|
18
|
+
# Do not set this db to the same as development or production.
|
19
|
+
test:
|
20
|
+
<<: *default
|
21
|
+
database: storage/test.sqlite3
|
22
|
+
|
23
|
+
|
24
|
+
# Store production database in the storage/ directory, which by default
|
25
|
+
# is mounted as a persistent Docker volume in config/deploy.yml.
|
26
|
+
production:
|
27
|
+
primary:
|
28
|
+
<<: *default
|
29
|
+
database: storage/production.sqlite3
|
30
|
+
cache:
|
31
|
+
<<: *default
|
32
|
+
database: storage/production_cache.sqlite3
|
33
|
+
migrations_paths: db/cache_migrate
|
34
|
+
queue:
|
35
|
+
<<: *default
|
36
|
+
database: storage/production_queue.sqlite3
|
37
|
+
migrations_paths: db/queue_migrate
|
38
|
+
cable:
|
39
|
+
<<: *default
|
40
|
+
database: storage/production_cable.sqlite3
|
41
|
+
migrations_paths: db/cable_migrate
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# Name of your application. Used to uniquely configure containers.
|
2
|
+
service: rails_api
|
3
|
+
|
4
|
+
# Name of the container image.
|
5
|
+
image: your-user/rails_api
|
6
|
+
|
7
|
+
# Deploy to these servers.
|
8
|
+
servers:
|
9
|
+
web:
|
10
|
+
- 192.168.0.1
|
11
|
+
# job:
|
12
|
+
# hosts:
|
13
|
+
# - 192.168.0.1
|
14
|
+
# cmd: bin/jobs
|
15
|
+
|
16
|
+
# Enable SSL auto certification via Let's Encrypt and allow for multiple apps on a single web server.
|
17
|
+
# Remove this section when using multiple web servers and ensure you terminate SSL at your load balancer.
|
18
|
+
#
|
19
|
+
# Note: If using Cloudflare, set encryption mode in SSL/TLS setting to "Full" to enable CF-to-app encryption.
|
20
|
+
proxy:
|
21
|
+
ssl: true
|
22
|
+
host: app.example.com
|
23
|
+
|
24
|
+
# Credentials for your image host.
|
25
|
+
registry:
|
26
|
+
# Specify the registry server, if you're not using Docker Hub
|
27
|
+
# server: registry.digitalocean.com / ghcr.io / ...
|
28
|
+
username: your-user
|
29
|
+
|
30
|
+
# Always use an access token rather than real password when possible.
|
31
|
+
password:
|
32
|
+
- KAMAL_REGISTRY_PASSWORD
|
33
|
+
|
34
|
+
# Inject ENV variables into containers (secrets come from .kamal/secrets).
|
35
|
+
env:
|
36
|
+
secret:
|
37
|
+
- RAILS_MASTER_KEY
|
38
|
+
clear:
|
39
|
+
# Run the Solid Queue Supervisor inside the web server's Puma process to do jobs.
|
40
|
+
# When you start using multiple servers, you should split out job processing to a dedicated machine.
|
41
|
+
SOLID_QUEUE_IN_PUMA: true
|
42
|
+
|
43
|
+
# Set number of processes dedicated to Solid Queue (default: 1)
|
44
|
+
# JOB_CONCURRENCY: 3
|
45
|
+
|
46
|
+
# Set number of cores available to the application on each server (default: 1).
|
47
|
+
# WEB_CONCURRENCY: 2
|
48
|
+
|
49
|
+
# Match this to any external database server to configure Active Record correctly
|
50
|
+
# Use rails_api-db for a db accessory server on same machine via local kamal docker network.
|
51
|
+
# DB_HOST: 192.168.0.2
|
52
|
+
|
53
|
+
# Log everything from Rails
|
54
|
+
# RAILS_LOG_LEVEL: debug
|
55
|
+
|
56
|
+
# Aliases are triggered with "bin/kamal <alias>". You can overwrite arguments on invocation:
|
57
|
+
# "bin/kamal logs -r job" will tail logs from the first server in the job section.
|
58
|
+
aliases:
|
59
|
+
console: app exec --interactive --reuse "bin/rails console"
|
60
|
+
shell: app exec --interactive --reuse "bash"
|
61
|
+
logs: app logs -f
|
62
|
+
dbc: app exec --interactive --reuse "bin/rails dbconsole"
|
63
|
+
|
64
|
+
|
65
|
+
# Use a persistent storage volume for sqlite database files and local Active Storage files.
|
66
|
+
# Recommended to change this to a mounted volume path that is backed up off server.
|
67
|
+
volumes:
|
68
|
+
- "rails_api_storage:/rails/storage"
|
69
|
+
|
70
|
+
|
71
|
+
# Bridge fingerprinted assets, like JS and CSS, between versions to avoid
|
72
|
+
# hitting 404 on in-flight requests. Combines all files from new and old
|
73
|
+
# version inside the asset_path.
|
74
|
+
asset_path: /rails/public/assets
|
75
|
+
|
76
|
+
# Configure the image builder.
|
77
|
+
builder:
|
78
|
+
arch: amd64
|
79
|
+
|
80
|
+
# # Build image via remote server (useful for faster amd64 builds on arm64 computers)
|
81
|
+
# remote: ssh://docker@docker-builder-server
|
82
|
+
#
|
83
|
+
# # Pass arguments and secrets to the Docker build process
|
84
|
+
# args:
|
85
|
+
# RUBY_VERSION: 3.3.5
|
86
|
+
# secrets:
|
87
|
+
# - GITHUB_TOKEN
|
88
|
+
# - RAILS_MASTER_KEY
|
89
|
+
|
90
|
+
# Use a different ssh user than root
|
91
|
+
# ssh:
|
92
|
+
# user: app
|
93
|
+
|
94
|
+
# Use accessory services (secrets come from .kamal/secrets).
|
95
|
+
# accessories:
|
96
|
+
# db:
|
97
|
+
# image: mysql:8.0
|
98
|
+
# host: 192.168.0.2
|
99
|
+
# # Change to 3306 to expose port to the world instead of just local network.
|
100
|
+
# port: "127.0.0.1:3306:3306"
|
101
|
+
# env:
|
102
|
+
# clear:
|
103
|
+
# MYSQL_ROOT_HOST: '%'
|
104
|
+
# secret:
|
105
|
+
# - MYSQL_ROOT_PASSWORD
|
106
|
+
# files:
|
107
|
+
# - config/mysql/production.cnf:/etc/mysql/my.cnf
|
108
|
+
# - db/production.sql:/docker-entrypoint-initdb.d/setup.sql
|
109
|
+
# directories:
|
110
|
+
# - data:/var/lib/mysql
|
111
|
+
# redis:
|
112
|
+
# image: redis:7.0
|
113
|
+
# host: 192.168.0.2
|
114
|
+
# port: 6379
|
115
|
+
# directories:
|
116
|
+
# - data:/data
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
2
|
+
|
3
|
+
Rails.application.configure do
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
+
|
6
|
+
# Make code changes take effect immediately without server restart.
|
7
|
+
config.enable_reloading = true
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
|
15
|
+
# Enable server timing.
|
16
|
+
config.server_timing = true
|
17
|
+
|
18
|
+
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
|
19
|
+
# Run rails dev:cache to toggle Action Controller caching.
|
20
|
+
if Rails.root.join("tmp/caching-dev.txt").exist?
|
21
|
+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
|
22
|
+
else
|
23
|
+
config.action_controller.perform_caching = false
|
24
|
+
end
|
25
|
+
|
26
|
+
# Change to :null_store to avoid any caching.
|
27
|
+
config.cache_store = :memory_store
|
28
|
+
|
29
|
+
# Store uploaded files on the local file system (see config/storage.yml for options).
|
30
|
+
config.active_storage.service = :local
|
31
|
+
|
32
|
+
# Don't care if the mailer can't send.
|
33
|
+
config.action_mailer.raise_delivery_errors = false
|
34
|
+
|
35
|
+
# Make template changes take effect immediately.
|
36
|
+
config.action_mailer.perform_caching = false
|
37
|
+
|
38
|
+
# Set localhost to be used by links generated in mailer templates.
|
39
|
+
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
|
40
|
+
|
41
|
+
# Print deprecation notices to the Rails logger.
|
42
|
+
config.active_support.deprecation = :log
|
43
|
+
|
44
|
+
# Raise an error on page load if there are pending migrations.
|
45
|
+
config.active_record.migration_error = :page_load
|
46
|
+
|
47
|
+
# Highlight code that triggered database queries in logs.
|
48
|
+
config.active_record.verbose_query_logs = true
|
49
|
+
|
50
|
+
# Append comments with runtime information tags to SQL queries in logs.
|
51
|
+
config.active_record.query_log_tags_enabled = true
|
52
|
+
|
53
|
+
# Highlight code that enqueued background job in logs.
|
54
|
+
config.active_job.verbose_enqueue_logs = true
|
55
|
+
|
56
|
+
# Raises error for missing translations.
|
57
|
+
# config.i18n.raise_on_missing_translations = true
|
58
|
+
|
59
|
+
# Annotate rendered view with file names.
|
60
|
+
config.action_view.annotate_rendered_view_with_filenames = true
|
61
|
+
|
62
|
+
# Uncomment if you wish to allow Action Cable access from any origin.
|
63
|
+
# config.action_cable.disable_request_forgery_protection = true
|
64
|
+
|
65
|
+
# Raise error when a before_action's only/except options reference missing actions.
|
66
|
+
config.action_controller.raise_on_missing_callback_actions = true
|
67
|
+
|
68
|
+
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
|
69
|
+
# config.generators.apply_rubocop_autocorrect_after_generate!
|
70
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
2
|
+
|
3
|
+
Rails.application.configure do
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
+
|
6
|
+
# Code is not reloaded between requests.
|
7
|
+
config.enable_reloading = false
|
8
|
+
|
9
|
+
# Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
|
10
|
+
config.eager_load = true
|
11
|
+
|
12
|
+
# Full error reports are disabled.
|
13
|
+
config.consider_all_requests_local = false
|
14
|
+
|
15
|
+
# Cache assets for far-future expiry since they are all digest stamped.
|
16
|
+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
|
17
|
+
|
18
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
19
|
+
# config.asset_host = "http://assets.example.com"
|
20
|
+
|
21
|
+
# Store uploaded files on the local file system (see config/storage.yml for options).
|
22
|
+
config.active_storage.service = :local
|
23
|
+
|
24
|
+
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
|
25
|
+
config.assume_ssl = true
|
26
|
+
|
27
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
28
|
+
config.force_ssl = true
|
29
|
+
|
30
|
+
# Skip http-to-https redirect for the default health check endpoint.
|
31
|
+
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
|
32
|
+
|
33
|
+
# Log to STDOUT with the current request id as a default log tag.
|
34
|
+
config.log_tags = [ :request_id ]
|
35
|
+
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
|
36
|
+
|
37
|
+
# Change to "debug" to log everything (including potentially personally-identifiable information!)
|
38
|
+
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
|
39
|
+
|
40
|
+
# Prevent health checks from clogging up the logs.
|
41
|
+
config.silence_healthcheck_path = "/up"
|
42
|
+
|
43
|
+
# Don't log any deprecations.
|
44
|
+
config.active_support.report_deprecations = false
|
45
|
+
|
46
|
+
# Replace the default in-process memory cache store with a durable alternative.
|
47
|
+
config.cache_store = :solid_cache_store
|
48
|
+
|
49
|
+
# Replace the default in-process and non-durable queuing backend for Active Job.
|
50
|
+
config.active_job.queue_adapter = :solid_queue
|
51
|
+
config.solid_queue.connects_to = { database: { writing: :queue } }
|
52
|
+
|
53
|
+
|
54
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
55
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
56
|
+
# config.action_mailer.raise_delivery_errors = false
|
57
|
+
|
58
|
+
# Set host to be used by links generated in mailer templates.
|
59
|
+
config.action_mailer.default_url_options = { host: "example.com" }
|
60
|
+
|
61
|
+
# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
|
62
|
+
# config.action_mailer.smtp_settings = {
|
63
|
+
# user_name: Rails.application.credentials.dig(:smtp, :user_name),
|
64
|
+
# password: Rails.application.credentials.dig(:smtp, :password),
|
65
|
+
# address: "smtp.example.com",
|
66
|
+
# port: 587,
|
67
|
+
# authentication: :plain
|
68
|
+
# }
|
69
|
+
|
70
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
71
|
+
# the I18n.default_locale when a translation cannot be found).
|
72
|
+
config.i18n.fallbacks = true
|
73
|
+
|
74
|
+
# Do not dump schema after migrations.
|
75
|
+
config.active_record.dump_schema_after_migration = false
|
76
|
+
|
77
|
+
# Only use :id for inspections in production.
|
78
|
+
config.active_record.attributes_for_inspect = [ :id ]
|
79
|
+
|
80
|
+
# Enable DNS rebinding protection and other `Host` header attacks.
|
81
|
+
# config.hosts = [
|
82
|
+
# "example.com", # Allow requests from example.com
|
83
|
+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
|
84
|
+
# ]
|
85
|
+
#
|
86
|
+
# Skip DNS rebinding protection for the default health check endpoint.
|
87
|
+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
|
88
|
+
end
|