crspec 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +67 -17
- data/benchmark/README.md +56 -0
- data/benchmark/run.rb +72 -0
- data/benchmark/spec/user_service_crspec_spec.rb +15 -0
- data/benchmark/spec/user_service_rspec_spec.rb +16 -0
- data/benchmark/target_service.rb +12 -0
- data/benchmark/test/user_service_test.rb +18 -0
- data/demo.rb +6 -3
- data/lib/crspec/cli.rb +34 -3
- data/lib/crspec/configuration.rb +59 -0
- data/lib/crspec/example_group.rb +31 -0
- data/lib/crspec/execution_context.rb +1 -1
- data/lib/crspec/generators/init.rb +94 -0
- data/lib/crspec/matchers.rb +55 -0
- data/lib/crspec/mock/double.rb +8 -1
- data/lib/crspec/rails/database_isolation.rb +6 -15
- data/lib/crspec/rails/parallel.rb +1 -1
- data/lib/crspec/rails/request_helpers.rb +96 -0
- data/lib/crspec/transpiler/cli.rb +6 -6
- data/lib/crspec/version.rb +1 -1
- data/lib/crspec.rb +3 -0
- data/samples/book_store/.dockerignore +51 -0
- data/samples/book_store/.gitattributes +9 -0
- data/samples/book_store/.github/dependabot.yml +12 -0
- data/samples/book_store/.github/workflows/ci.yml +130 -0
- data/samples/book_store/.gitignore +35 -0
- data/samples/book_store/.kamal/hooks/docker-setup.sample +3 -0
- data/samples/book_store/.kamal/hooks/post-app-boot.sample +3 -0
- data/samples/book_store/.kamal/hooks/post-deploy.sample +14 -0
- data/samples/book_store/.kamal/hooks/post-proxy-reboot.sample +3 -0
- data/samples/book_store/.kamal/hooks/pre-app-boot.sample +3 -0
- data/samples/book_store/.kamal/hooks/pre-build.sample +51 -0
- data/samples/book_store/.kamal/hooks/pre-connect.sample +47 -0
- data/samples/book_store/.kamal/hooks/pre-deploy.sample +122 -0
- data/samples/book_store/.kamal/hooks/pre-proxy-reboot.sample +3 -0
- data/samples/book_store/.kamal/secrets +20 -0
- data/samples/book_store/.rubocop.yml +8 -0
- data/samples/book_store/.ruby-version +1 -0
- data/samples/book_store/Dockerfile +77 -0
- data/samples/book_store/Gemfile +67 -0
- data/samples/book_store/Gemfile.lock +572 -0
- data/samples/book_store/README.md +24 -0
- data/samples/book_store/Rakefile +6 -0
- data/samples/book_store/app/assets/images/.keep +0 -0
- data/samples/book_store/app/assets/stylesheets/application.css +10 -0
- data/samples/book_store/app/controllers/application_controller.rb +2 -0
- data/samples/book_store/app/controllers/books_controller.rb +30 -0
- data/samples/book_store/app/controllers/comments_controller.rb +21 -0
- data/samples/book_store/app/controllers/concerns/.keep +0 -0
- data/samples/book_store/app/controllers/users_controller.rb +21 -0
- data/samples/book_store/app/helpers/application_helper.rb +2 -0
- data/samples/book_store/app/helpers/books_helper.rb +2 -0
- data/samples/book_store/app/helpers/comments_helper.rb +2 -0
- data/samples/book_store/app/helpers/users_helper.rb +2 -0
- data/samples/book_store/app/javascript/application.js +3 -0
- data/samples/book_store/app/javascript/controllers/application.js +9 -0
- data/samples/book_store/app/javascript/controllers/hello_controller.js +7 -0
- data/samples/book_store/app/javascript/controllers/index.js +4 -0
- data/samples/book_store/app/jobs/application_job.rb +7 -0
- data/samples/book_store/app/mailers/application_mailer.rb +4 -0
- data/samples/book_store/app/models/application_record.rb +3 -0
- data/samples/book_store/app/models/book.rb +10 -0
- data/samples/book_store/app/models/comment.rb +6 -0
- data/samples/book_store/app/models/concerns/.keep +0 -0
- data/samples/book_store/app/models/user.rb +4 -0
- data/samples/book_store/app/views/layouts/application.html.erb +29 -0
- data/samples/book_store/app/views/layouts/mailer.html.erb +13 -0
- data/samples/book_store/app/views/layouts/mailer.text.erb +1 -0
- data/samples/book_store/app/views/pwa/manifest.json.erb +22 -0
- data/samples/book_store/app/views/pwa/service-worker.js +26 -0
- data/samples/book_store/bin/brakeman +7 -0
- data/samples/book_store/bin/bundler-audit +6 -0
- data/samples/book_store/bin/ci +6 -0
- data/samples/book_store/bin/dev +2 -0
- data/samples/book_store/bin/docker-entrypoint +8 -0
- data/samples/book_store/bin/importmap +4 -0
- data/samples/book_store/bin/jobs +6 -0
- data/samples/book_store/bin/kamal +16 -0
- data/samples/book_store/bin/rails +4 -0
- data/samples/book_store/bin/rake +4 -0
- data/samples/book_store/bin/rubocop +8 -0
- data/samples/book_store/bin/setup +35 -0
- data/samples/book_store/bin/thrust +5 -0
- data/samples/book_store/config/application.rb +27 -0
- data/samples/book_store/config/boot.rb +4 -0
- data/samples/book_store/config/bundler-audit.yml +5 -0
- data/samples/book_store/config/cable.yml +17 -0
- data/samples/book_store/config/cache.yml +16 -0
- data/samples/book_store/config/ci.rb +24 -0
- data/samples/book_store/config/credentials.yml.enc +1 -0
- data/samples/book_store/config/database.yml +45 -0
- data/samples/book_store/config/deploy.yml +119 -0
- data/samples/book_store/config/environment.rb +5 -0
- data/samples/book_store/config/environments/development.rb +78 -0
- data/samples/book_store/config/environments/production.rb +90 -0
- data/samples/book_store/config/environments/test.rb +53 -0
- data/samples/book_store/config/importmap.rb +7 -0
- data/samples/book_store/config/initializers/assets.rb +7 -0
- data/samples/book_store/config/initializers/content_security_policy.rb +29 -0
- data/samples/book_store/config/initializers/filter_parameter_logging.rb +8 -0
- data/samples/book_store/config/initializers/inflections.rb +16 -0
- data/samples/book_store/config/locales/en.yml +31 -0
- data/samples/book_store/config/puma.rb +42 -0
- data/samples/book_store/config/queue.yml +18 -0
- data/samples/book_store/config/recurring.yml +15 -0
- data/samples/book_store/config/routes.rb +17 -0
- data/samples/book_store/config/storage.yml +27 -0
- data/samples/book_store/config.ru +6 -0
- data/samples/book_store/db/cable_schema.rb +11 -0
- data/samples/book_store/db/cache_schema.rb +12 -0
- data/samples/book_store/db/migrate/20260731035441_create_users.rb +10 -0
- data/samples/book_store/db/migrate/20260731035506_create_books.rb +11 -0
- data/samples/book_store/db/migrate/20260731035528_create_comments.rb +11 -0
- data/samples/book_store/db/queue_schema.rb +129 -0
- data/samples/book_store/db/schema.rb +39 -0
- data/samples/book_store/db/seeds.rb +9 -0
- data/samples/book_store/lib/tasks/.keep +0 -0
- data/samples/book_store/log/.keep +0 -0
- data/samples/book_store/public/400.html +135 -0
- data/samples/book_store/public/404.html +135 -0
- data/samples/book_store/public/406-unsupported-browser.html +135 -0
- data/samples/book_store/public/422.html +135 -0
- data/samples/book_store/public/500.html +135 -0
- data/samples/book_store/public/icon.png +0 -0
- data/samples/book_store/public/icon.svg +3 -0
- data/samples/book_store/public/robots.txt +1 -0
- data/samples/book_store/script/.keep +0 -0
- data/samples/book_store/spec/models/book_spec.rb +42 -0
- data/samples/book_store/spec/models/comment_spec.rb +22 -0
- data/samples/book_store/spec/models/user_advanced_spec.rb +27 -0
- data/samples/book_store/spec/models/user_spec.rb +30 -0
- data/samples/book_store/spec/rails_helper.rb +36 -0
- data/samples/book_store/spec/rails_parallel_spec.rb +23 -0
- data/samples/book_store/spec/requests/books_spec.rb +21 -0
- data/samples/book_store/spec/requests/users_spec.rb +14 -0
- data/samples/book_store/spec/services/inventory_service_spec.rb +28 -0
- data/samples/book_store/spec/services/time_dependent_service_spec.rb +26 -0
- data/samples/book_store/spec/spec_helper.rb +16 -0
- data/samples/book_store/spec/system/book_store_system_spec.rb +18 -0
- data/samples/book_store/storage/.keep +0 -0
- data/samples/book_store/test/controllers/.keep +0 -0
- data/samples/book_store/test/controllers/books_controller_test.rb +7 -0
- data/samples/book_store/test/controllers/comments_controller_test.rb +7 -0
- data/samples/book_store/test/controllers/users_controller_test.rb +7 -0
- data/samples/book_store/test/fixtures/books.yml +11 -0
- data/samples/book_store/test/fixtures/comments.yml +11 -0
- data/samples/book_store/test/fixtures/files/.keep +0 -0
- data/samples/book_store/test/fixtures/users.yml +9 -0
- data/samples/book_store/test/helpers/.keep +0 -0
- data/samples/book_store/test/integration/.keep +0 -0
- data/samples/book_store/test/mailers/.keep +0 -0
- data/samples/book_store/test/models/.keep +0 -0
- data/samples/book_store/test/models/book_test.rb +7 -0
- data/samples/book_store/test/models/comment_test.rb +7 -0
- data/samples/book_store/test/models/user_test.rb +7 -0
- data/samples/book_store/test/test_helper.rb +15 -0
- data/samples/book_store/tmp/.keep +0 -0
- data/samples/book_store/tmp/pids/.keep +0 -0
- data/samples/book_store/tmp/storage/.keep +0 -0
- data/samples/book_store/vendor/.keep +0 -0
- data/samples/book_store/vendor/javascript/.keep +0 -0
- data/test/crspec/configuration_test.rb +76 -0
- metadata +152 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class UsersController < ApplicationController
|
|
2
|
+
def index
|
|
3
|
+
users = User.all
|
|
4
|
+
render json: users
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def create
|
|
8
|
+
user = User.new(user_params)
|
|
9
|
+
if user.save
|
|
10
|
+
render json: user, status: :created
|
|
11
|
+
else
|
|
12
|
+
render json: { errors: user.errors.full_messages }, status: :unprocessable_entity
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def user_params
|
|
19
|
+
params.require(:user).permit(:name, :email)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Import and register all your controllers from the importmap via controllers/**/*_controller
|
|
2
|
+
import { application } from "controllers/application"
|
|
3
|
+
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
|
4
|
+
eagerLoadControllersFrom("controllers", application)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
class ApplicationJob < ActiveJob::Base
|
|
2
|
+
# Automatically retry jobs that encountered a deadlock
|
|
3
|
+
# retry_on ActiveRecord::Deadlocked
|
|
4
|
+
|
|
5
|
+
# Most jobs are safe to ignore if the underlying records are no longer available
|
|
6
|
+
# discard_on ActiveJob::DeserializationError
|
|
7
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title><%= content_for(:title) || "Book Store" %></title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
7
|
+
<meta name="application-name" content="Book Store">
|
|
8
|
+
<meta name="mobile-web-app-capable" content="yes">
|
|
9
|
+
<%= csrf_meta_tags %>
|
|
10
|
+
<%= csp_meta_tag %>
|
|
11
|
+
|
|
12
|
+
<%= yield :head %>
|
|
13
|
+
|
|
14
|
+
<%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
|
|
15
|
+
<%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>
|
|
16
|
+
|
|
17
|
+
<link rel="icon" href="/icon.png" type="image/png">
|
|
18
|
+
<link rel="icon" href="/icon.svg" type="image/svg+xml">
|
|
19
|
+
<link rel="apple-touch-icon" href="/icon.png">
|
|
20
|
+
|
|
21
|
+
<%# Includes all stylesheet files in app/assets/stylesheets %>
|
|
22
|
+
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
|
|
23
|
+
<%= javascript_importmap_tags %>
|
|
24
|
+
</head>
|
|
25
|
+
|
|
26
|
+
<body>
|
|
27
|
+
<%= yield %>
|
|
28
|
+
</body>
|
|
29
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= yield %>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "BookStore",
|
|
3
|
+
"icons": [
|
|
4
|
+
{
|
|
5
|
+
"src": "/icon.png",
|
|
6
|
+
"type": "image/png",
|
|
7
|
+
"sizes": "512x512"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"src": "/icon.png",
|
|
11
|
+
"type": "image/png",
|
|
12
|
+
"sizes": "512x512",
|
|
13
|
+
"purpose": "maskable"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"start_url": "/",
|
|
17
|
+
"display": "standalone",
|
|
18
|
+
"scope": "/",
|
|
19
|
+
"description": "BookStore.",
|
|
20
|
+
"theme_color": "red",
|
|
21
|
+
"background_color": "red"
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Add a service worker for processing Web Push notifications:
|
|
2
|
+
//
|
|
3
|
+
// self.addEventListener("push", async (event) => {
|
|
4
|
+
// const { title, options } = await event.data.json()
|
|
5
|
+
// event.waitUntil(self.registration.showNotification(title, options))
|
|
6
|
+
// })
|
|
7
|
+
//
|
|
8
|
+
// self.addEventListener("notificationclick", function(event) {
|
|
9
|
+
// event.notification.close()
|
|
10
|
+
// event.waitUntil(
|
|
11
|
+
// clients.matchAll({ type: "window" }).then((clientList) => {
|
|
12
|
+
// for (let i = 0; i < clientList.length; i++) {
|
|
13
|
+
// let client = clientList[i]
|
|
14
|
+
// let clientPath = (new URL(client.url)).pathname
|
|
15
|
+
//
|
|
16
|
+
// if (clientPath == event.notification.data.path && "focus" in client) {
|
|
17
|
+
// return client.focus()
|
|
18
|
+
// }
|
|
19
|
+
// }
|
|
20
|
+
//
|
|
21
|
+
// if (clients.openWindow) {
|
|
22
|
+
// return clients.openWindow(event.notification.data.path)
|
|
23
|
+
// }
|
|
24
|
+
// })
|
|
25
|
+
// )
|
|
26
|
+
// })
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
require "rubygems"
|
|
14
|
+
require "bundler/setup"
|
|
15
|
+
|
|
16
|
+
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,35 @@
|
|
|
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
|
+
system! "bin/rails db:reset" if ARGV.include?("--reset")
|
|
26
|
+
|
|
27
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
28
|
+
system! "bin/rails log:clear tmp:clear"
|
|
29
|
+
|
|
30
|
+
unless ARGV.include?("--skip-server")
|
|
31
|
+
puts "\n== Starting development server =="
|
|
32
|
+
STDOUT.flush # flush the output before exec(2) so that it displays
|
|
33
|
+
exec "bin/dev"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
module BookStore
|
|
10
|
+
class Application < Rails::Application
|
|
11
|
+
# Initialize configuration defaults for originally generated Rails version.
|
|
12
|
+
config.load_defaults 8.1
|
|
13
|
+
|
|
14
|
+
# Please, add to the `ignore` list any other `lib` subdirectories that do
|
|
15
|
+
# not contain `.rb` files, or that should not be reloaded or eager loaded.
|
|
16
|
+
# Common ones are `templates`, `generators`, or `middleware`, for example.
|
|
17
|
+
config.autoload_lib(ignore: %w[assets tasks])
|
|
18
|
+
|
|
19
|
+
# Configuration for the application, engines, and railties goes here.
|
|
20
|
+
#
|
|
21
|
+
# These settings can be overridden in specific environments using the files
|
|
22
|
+
# in config/environments, which are processed later.
|
|
23
|
+
#
|
|
24
|
+
# config.time_zone = "Central Time (US & Canada)"
|
|
25
|
+
# config.eager_load_paths << Rails.root.join("extras")
|
|
26
|
+
end
|
|
27
|
+
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,24 @@
|
|
|
1
|
+
# Run using bin/ci
|
|
2
|
+
|
|
3
|
+
CI.run do
|
|
4
|
+
step "Setup", "bin/setup --skip-server"
|
|
5
|
+
|
|
6
|
+
step "Style: Ruby", "bin/rubocop"
|
|
7
|
+
|
|
8
|
+
step "Security: Gem audit", "bin/bundler-audit"
|
|
9
|
+
step "Security: Importmap vulnerability audit", "bin/importmap audit"
|
|
10
|
+
step "Security: Brakeman code analysis", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error"
|
|
11
|
+
step "Tests: Rails", "bin/rails test"
|
|
12
|
+
step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant"
|
|
13
|
+
|
|
14
|
+
# Optional: Run system tests
|
|
15
|
+
# step "Tests: System", "bin/rails test:system"
|
|
16
|
+
|
|
17
|
+
# Optional: set a green GitHub commit status to unblock PR merge.
|
|
18
|
+
# Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`.
|
|
19
|
+
# if success?
|
|
20
|
+
# step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
|
|
21
|
+
# else
|
|
22
|
+
# failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again."
|
|
23
|
+
# end
|
|
24
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ojAe8w7sOsZkF8EHzorZ9K6yWXWLfAVJgZWQBwbWQ63/7NWXCSbf10eBnB03wp2wmCqATLLZCoKkT2HjNRPjItQioHu6kWHsJ1sHA9YJLfx8XRGShstu6mKesjzeh2koM3Ro8UueDGvDiX1InmGnhVnxZFkpPEkPM4ynb9ZRflP6Jh5i52jnPDBT98NHeZ4386h5mI9/IE830gmlgsnseAe56yolpvoeKcF+mPfdInMVQs392FsddUKVcsswSL7AdXJfY1hNSKQF5ZVA1PoBOUEg8CaG+IITHG6qK1PifSWgO0Ujv2wCo0dBY25G+eyeAUWVhXzhH1tXrZ+XExOrkkxmn3FUVcdQuIH+0xZCwkte9yoqG9lLHXNosd5VsQ2E0rWElsOo3sYAmgGXXm5BmTwOMbkLzKr4jPO4QhThd5C8+h39uv+0ErxNglJc8K4fh3d3GeENee5JXaI4SA7MJ+y9B8OhjrkAxjLdxnaRV++cqu4UyL27ROhH--ocr0VqVdu0Ywi3Ny--c1PbrAzy1cZg6mdR6mTolw==
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
max_connections: <%= ENV.fetch("RAILS_MAX_THREADS") { 50 } %>
|
|
10
|
+
timeout: 10000
|
|
11
|
+
pool: 50
|
|
12
|
+
journal_mode: wal
|
|
13
|
+
|
|
14
|
+
development:
|
|
15
|
+
<<: *default
|
|
16
|
+
database: storage/development.sqlite3
|
|
17
|
+
|
|
18
|
+
# Warning: The database defined as "test" will be erased and
|
|
19
|
+
# re-generated from your development database when you run "rake".
|
|
20
|
+
# Do not set this db to the same as development or production.
|
|
21
|
+
test:
|
|
22
|
+
<<: *default
|
|
23
|
+
database: storage/test.sqlite3
|
|
24
|
+
pool: 50
|
|
25
|
+
timeout: 10000
|
|
26
|
+
journal_mode: wal
|
|
27
|
+
|
|
28
|
+
# Store production database in the storage/ directory, which by default
|
|
29
|
+
# is mounted as a persistent Docker volume in config/deploy.yml.
|
|
30
|
+
production:
|
|
31
|
+
primary:
|
|
32
|
+
<<: *default
|
|
33
|
+
database: storage/production.sqlite3
|
|
34
|
+
cache:
|
|
35
|
+
<<: *default
|
|
36
|
+
database: storage/production_cache.sqlite3
|
|
37
|
+
migrations_paths: db/cache_migrate
|
|
38
|
+
queue:
|
|
39
|
+
<<: *default
|
|
40
|
+
database: storage/production_queue.sqlite3
|
|
41
|
+
migrations_paths: db/queue_migrate
|
|
42
|
+
cable:
|
|
43
|
+
<<: *default
|
|
44
|
+
database: storage/production_cable.sqlite3
|
|
45
|
+
migrations_paths: db/cable_migrate
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Name of your application. Used to uniquely configure containers.
|
|
2
|
+
service: book_store
|
|
3
|
+
|
|
4
|
+
# Name of the container image (use your-user/app-name on external registries).
|
|
5
|
+
image: book_store
|
|
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
|
+
# If used with Cloudflare, set encryption mode in SSL/TLS setting to "Full" to enable CF-to-app encryption.
|
|
18
|
+
#
|
|
19
|
+
# Using an SSL proxy like this requires turning on config.assume_ssl and config.force_ssl in production.rb!
|
|
20
|
+
#
|
|
21
|
+
# Don't use this when deploying to multiple web servers (then you have to terminate SSL at your load balancer).
|
|
22
|
+
#
|
|
23
|
+
# proxy:
|
|
24
|
+
# ssl: true
|
|
25
|
+
# host: app.example.com
|
|
26
|
+
|
|
27
|
+
# Where you keep your container images.
|
|
28
|
+
registry:
|
|
29
|
+
# Alternatives: hub.docker.com / registry.digitalocean.com / ghcr.io / ...
|
|
30
|
+
server: localhost:5555
|
|
31
|
+
|
|
32
|
+
# Needed for authenticated registries.
|
|
33
|
+
# username: your-user
|
|
34
|
+
|
|
35
|
+
# Always use an access token rather than real password when possible.
|
|
36
|
+
# password:
|
|
37
|
+
# - KAMAL_REGISTRY_PASSWORD
|
|
38
|
+
|
|
39
|
+
# Inject ENV variables into containers (secrets come from .kamal/secrets).
|
|
40
|
+
env:
|
|
41
|
+
secret:
|
|
42
|
+
- RAILS_MASTER_KEY
|
|
43
|
+
clear:
|
|
44
|
+
# Run the Solid Queue Supervisor inside the web server's Puma process to do jobs.
|
|
45
|
+
# When you start using multiple servers, you should split out job processing to a dedicated machine.
|
|
46
|
+
SOLID_QUEUE_IN_PUMA: true
|
|
47
|
+
|
|
48
|
+
# Set number of processes dedicated to Solid Queue (default: 1)
|
|
49
|
+
# JOB_CONCURRENCY: 3
|
|
50
|
+
|
|
51
|
+
# Set number of cores available to the application on each server (default: 1).
|
|
52
|
+
# WEB_CONCURRENCY: 2
|
|
53
|
+
|
|
54
|
+
# Match this to any external database server to configure Active Record correctly
|
|
55
|
+
# Use book_store-db for a db accessory server on same machine via local kamal docker network.
|
|
56
|
+
# DB_HOST: 192.168.0.2
|
|
57
|
+
|
|
58
|
+
# Log everything from Rails
|
|
59
|
+
# RAILS_LOG_LEVEL: debug
|
|
60
|
+
|
|
61
|
+
# Aliases are triggered with "bin/kamal <alias>". You can overwrite arguments on invocation:
|
|
62
|
+
# "bin/kamal logs -r job" will tail logs from the first server in the job section.
|
|
63
|
+
aliases:
|
|
64
|
+
console: app exec --interactive --reuse "bin/rails console"
|
|
65
|
+
shell: app exec --interactive --reuse "bash"
|
|
66
|
+
logs: app logs -f
|
|
67
|
+
dbc: app exec --interactive --reuse "bin/rails dbconsole --include-password"
|
|
68
|
+
|
|
69
|
+
# Use a persistent storage volume for sqlite database files and local Active Storage files.
|
|
70
|
+
# Recommended to change this to a mounted volume path that is backed up off server.
|
|
71
|
+
volumes:
|
|
72
|
+
- "book_store_storage:/rails/storage"
|
|
73
|
+
|
|
74
|
+
# Bridge fingerprinted assets, like JS and CSS, between versions to avoid
|
|
75
|
+
# hitting 404 on in-flight requests. Combines all files from new and old
|
|
76
|
+
# version inside the asset_path.
|
|
77
|
+
asset_path: /rails/public/assets
|
|
78
|
+
|
|
79
|
+
# Configure the image builder.
|
|
80
|
+
builder:
|
|
81
|
+
arch: amd64
|
|
82
|
+
|
|
83
|
+
# # Build image via remote server (useful for faster amd64 builds on arm64 computers)
|
|
84
|
+
# remote: ssh://docker@docker-builder-server
|
|
85
|
+
#
|
|
86
|
+
# # Pass arguments and secrets to the Docker build process
|
|
87
|
+
# args:
|
|
88
|
+
# RUBY_VERSION: ruby-4.0.2
|
|
89
|
+
# secrets:
|
|
90
|
+
# - GITHUB_TOKEN
|
|
91
|
+
# - RAILS_MASTER_KEY
|
|
92
|
+
|
|
93
|
+
# Use a different ssh user than root
|
|
94
|
+
# ssh:
|
|
95
|
+
# user: app
|
|
96
|
+
|
|
97
|
+
# Use accessory services (secrets come from .kamal/secrets).
|
|
98
|
+
# accessories:
|
|
99
|
+
# db:
|
|
100
|
+
# image: mysql:8.0
|
|
101
|
+
# host: 192.168.0.2
|
|
102
|
+
# # Change to 3306 to expose port to the world instead of just local network.
|
|
103
|
+
# port: "127.0.0.1:3306:3306"
|
|
104
|
+
# env:
|
|
105
|
+
# clear:
|
|
106
|
+
# MYSQL_ROOT_HOST: '%'
|
|
107
|
+
# secret:
|
|
108
|
+
# - MYSQL_ROOT_PASSWORD
|
|
109
|
+
# files:
|
|
110
|
+
# - config/mysql/production.cnf:/etc/mysql/my.cnf
|
|
111
|
+
# - db/production.sql:/docker-entrypoint-initdb.d/setup.sql
|
|
112
|
+
# directories:
|
|
113
|
+
# - data:/var/lib/mysql
|
|
114
|
+
# redis:
|
|
115
|
+
# image: valkey/valkey:8
|
|
116
|
+
# host: 192.168.0.2
|
|
117
|
+
# port: 6379
|
|
118
|
+
# directories:
|
|
119
|
+
# - data:/data
|