railties 7.2.0 → 8.0.0.beta1

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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +111 -254
  3. data/lib/minitest/rails_plugin.rb +1 -1
  4. data/lib/rails/application/configuration.rb +15 -2
  5. data/lib/rails/application/default_middleware_stack.rb +4 -0
  6. data/lib/rails/application/finisher.rb +2 -2
  7. data/lib/rails/application/routes_reloader.rb +11 -1
  8. data/lib/rails/application.rb +12 -0
  9. data/lib/rails/code_statistics.rb +128 -86
  10. data/lib/rails/code_statistics_calculator.rb +78 -76
  11. data/lib/rails/command/helpers/editor.rb +1 -1
  12. data/lib/rails/commands/app/update_command.rb +10 -9
  13. data/lib/rails/commands/console/irb_console.rb +1 -2
  14. data/lib/rails/commands/credentials/USAGE +4 -4
  15. data/lib/rails/commands/credentials/credentials_command.rb +5 -1
  16. data/lib/rails/commands/dev/dev_command.rb +1 -1
  17. data/lib/rails/commands/devcontainer/devcontainer_command.rb +1 -1
  18. data/lib/rails/commands/stats/stats_command.rb +19 -0
  19. data/lib/rails/dev_caching.rb +2 -2
  20. data/lib/rails/engine/configuration.rb +3 -1
  21. data/lib/rails/engine/lazy_route_set.rb +109 -0
  22. data/lib/rails/engine.rb +10 -5
  23. data/lib/rails/gem_version.rb +3 -3
  24. data/lib/rails/generators/app_base.rb +46 -24
  25. data/lib/rails/generators/database.rb +102 -68
  26. data/lib/rails/generators/erb/authentication/authentication_generator.rb +15 -0
  27. data/lib/rails/generators/erb/authentication/templates/views/passwords/edit.html.erb +9 -0
  28. data/lib/rails/generators/erb/authentication/templates/views/passwords/new.html.erb +8 -0
  29. data/lib/rails/generators/erb/authentication/templates/views/sessions/new.html.erb +11 -0
  30. data/lib/rails/generators/generated_attribute.rb +16 -11
  31. data/lib/rails/generators/rails/app/app_generator.rb +22 -32
  32. data/lib/rails/generators/rails/app/templates/Dockerfile.tt +12 -3
  33. data/lib/rails/generators/rails/app/templates/Gemfile.tt +23 -8
  34. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +6 -11
  35. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +10 -3
  36. data/lib/rails/generators/rails/app/templates/app/views/pwa/service-worker.js +3 -3
  37. data/lib/rails/generators/rails/app/templates/bin/dev.tt +1 -0
  38. data/lib/rails/generators/rails/app/templates/bin/setup.tt +5 -7
  39. data/lib/rails/generators/rails/app/templates/bin/thrust.tt +4 -0
  40. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +23 -0
  41. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +23 -0
  42. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +40 -0
  43. data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +23 -0
  44. data/lib/rails/generators/rails/app/templates/config/deploy.yml.tt +124 -0
  45. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +12 -23
  46. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +34 -51
  47. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +5 -19
  48. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +0 -7
  49. data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +1 -1
  50. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +25 -0
  51. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +13 -3
  52. data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +5 -3
  53. data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +4 -3
  54. data/lib/rails/generators/rails/app/templates/dockerignore.tt +1 -2
  55. data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +1 -1
  56. data/lib/rails/generators/rails/app/templates/gitignore.tt +1 -2
  57. data/lib/rails/generators/rails/app/templates/kamal-secrets.tt +17 -0
  58. data/lib/rails/generators/rails/app/templates/public/400.html +114 -0
  59. data/lib/rails/generators/rails/app/templates/public/404.html +113 -66
  60. data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +113 -65
  61. data/lib/rails/generators/rails/app/templates/public/422.html +113 -66
  62. data/lib/rails/generators/rails/app/templates/public/500.html +113 -65
  63. data/lib/rails/generators/rails/app/templates/public/icon.png +0 -0
  64. data/lib/rails/generators/rails/app/templates/public/icon.svg +2 -2
  65. data/lib/rails/generators/rails/authentication/USAGE +6 -0
  66. data/lib/rails/generators/rails/authentication/authentication_generator.rb +54 -0
  67. data/lib/rails/generators/rails/authentication/templates/controllers/concerns/authentication.rb +55 -0
  68. data/lib/rails/generators/rails/authentication/templates/controllers/passwords_controller.rb +33 -0
  69. data/lib/rails/generators/rails/authentication/templates/controllers/sessions_controller.rb +21 -0
  70. data/lib/rails/generators/rails/authentication/templates/mailers/passwords_mailer.rb +6 -0
  71. data/lib/rails/generators/rails/authentication/templates/models/current.rb +4 -0
  72. data/lib/rails/generators/rails/authentication/templates/models/session.rb +3 -0
  73. data/lib/rails/generators/rails/authentication/templates/models/user.rb +6 -0
  74. data/lib/rails/generators/rails/authentication/templates/test/mailers/previews/passwords_mailer_preview.rb +7 -0
  75. data/lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.html.erb +4 -0
  76. data/lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.text.erb +2 -0
  77. data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +4 -0
  78. data/lib/rails/generators/rails/db/system/change/change_generator.rb +1 -1
  79. data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +5 -3
  80. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +1 -1
  81. data/lib/rails/generators/rails/plugin/plugin_generator.rb +11 -11
  82. data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +1 -1
  83. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +2 -2
  84. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +2 -2
  85. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +3 -3
  86. data/lib/rails/generators/rails/script/USAGE +18 -0
  87. data/lib/rails/generators/rails/script/script_generator.rb +18 -0
  88. data/lib/rails/generators/rails/script/templates/script.rb.tt +3 -0
  89. data/lib/rails/generators.rb +7 -2
  90. data/lib/rails/info_controller.rb +10 -2
  91. data/lib/rails/rack/silence_request.rb +33 -0
  92. data/lib/rails/rack.rb +1 -0
  93. data/lib/rails/railtie.rb +13 -13
  94. data/lib/rails/source_annotation_extractor.rb +31 -14
  95. data/lib/rails/tasks/statistics.rake +13 -28
  96. data/lib/rails/templates/rails/info/notes.html.erb +65 -0
  97. metadata +45 -25
  98. data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -2
  99. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb.tt +0 -4
  100. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb.tt +0 -4
  101. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.tt +0 -70
  102. data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +0 -13
  103. data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +0 -13
  104. data/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js.tt +0 -10
  105. data/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js.tt +0 -6
  106. data/lib/rails/generators/rails/plugin/templates/rails/javascripts.js.tt +0 -17
@@ -109,7 +109,7 @@ module Rails
109
109
  end
110
110
 
111
111
  def bin
112
- exclude_pattern = Regexp.union([(/rubocop/ if skip_rubocop?), (/brakeman/ if skip_brakeman?)].compact)
112
+ exclude_pattern = Regexp.union([(/thrust/ if skip_thruster?), (/rubocop/ if skip_rubocop?), (/brakeman/ if skip_brakeman?)].compact)
113
113
  directory "bin", { exclude_pattern: exclude_pattern } do |content|
114
114
  "#{shebang}\n" + content
115
115
  end
@@ -142,10 +142,8 @@ module Rails
142
142
  active_storage_config_exist = File.exist?("config/storage.yml")
143
143
  rack_cors_config_exist = File.exist?("config/initializers/cors.rb")
144
144
  assets_config_exist = File.exist?("config/initializers/assets.rb")
145
- asset_manifest_exist = File.exist?("app/assets/config/manifest.js")
146
145
  asset_app_stylesheet_exist = File.exist?("app/assets/stylesheets/application.css")
147
146
  csp_config_exist = File.exist?("config/initializers/content_security_policy.rb")
148
- permissions_policy_config_exist = File.exist?("config/initializers/permissions_policy.rb")
149
147
 
150
148
  @config_target_version = Rails.application.config.loaded_config_version || "5.0"
151
149
 
@@ -159,15 +157,11 @@ module Rails
159
157
  template "config/storage.yml"
160
158
  end
161
159
 
162
- if skip_sprockets? && skip_propshaft? && !assets_config_exist
160
+ if skip_asset_pipeline? && !assets_config_exist
163
161
  remove_file "config/initializers/assets.rb"
164
162
  end
165
163
 
166
- if skip_sprockets? && !asset_manifest_exist
167
- remove_file "app/assets/config/manifest.js"
168
- end
169
-
170
- if skip_sprockets? && !asset_app_stylesheet_exist
164
+ if skip_asset_pipeline? && !asset_app_stylesheet_exist
171
165
  remove_file "app/assets/stylesheets/application.css"
172
166
  end
173
167
 
@@ -179,10 +173,6 @@ module Rails
179
173
  unless csp_config_exist
180
174
  remove_file "config/initializers/content_security_policy.rb"
181
175
  end
182
-
183
- unless permissions_policy_config_exist
184
- remove_file "config/initializers/permissions_policy.rb"
185
- end
186
176
  end
187
177
  end
188
178
 
@@ -211,7 +201,7 @@ module Rails
211
201
  end
212
202
 
213
203
  def database_yml
214
- template "config/databases/#{options[:database]}.yml", "config/database.yml"
204
+ template database.template, "config/database.yml"
215
205
  end
216
206
 
217
207
  def db
@@ -221,7 +211,6 @@ module Rails
221
211
  def lib
222
212
  empty_directory "lib"
223
213
  empty_directory_with_keep_file "lib/tasks"
224
- empty_directory_with_keep_file "lib/assets"
225
214
  end
226
215
 
227
216
  def log
@@ -229,9 +218,15 @@ module Rails
229
218
  end
230
219
 
231
220
  def public_directory
221
+ return if options[:update] && options[:api]
222
+
232
223
  directory "public", "public", recursive: false
233
224
  end
234
225
 
226
+ def script
227
+ empty_directory_with_keep_file "script"
228
+ end
229
+
235
230
  def storage
236
231
  empty_directory_with_keep_file "storage"
237
232
  empty_directory_with_keep_file "tmp/storage"
@@ -245,7 +240,6 @@ module Rails
245
240
  empty_directory_with_keep_file "test/helpers"
246
241
  empty_directory_with_keep_file "test/integration"
247
242
 
248
- template "test/channels/application_cable/connection_test.rb"
249
243
  template "test/test_helper.rb"
250
244
  end
251
245
 
@@ -271,7 +265,7 @@ module Rails
271
265
  def devcontainer
272
266
  devcontainer_options = {
273
267
  database: options[:database],
274
- redis: !(options[:skip_action_cable] && options[:skip_active_job]),
268
+ redis: options[:skip_solid] && !(options[:skip_action_cable] && options[:skip_active_job]),
275
269
  system_test: depends_on_system_test?,
276
270
  active_storage: !options[:skip_active_storage],
277
271
  dev: options[:dev],
@@ -284,10 +278,6 @@ module Rails
284
278
  end
285
279
 
286
280
  module Generators
287
- # We need to store the RAILS_DEV_PATH in a constant, otherwise the path
288
- # can change in Ruby 1.8.7 when we FileUtils.cd.
289
- RAILS_DEV_PATH = File.expand_path("../../../../../..", __dir__)
290
-
291
281
  class AppGenerator < AppBase
292
282
  # :stopdoc:
293
283
 
@@ -445,6 +435,11 @@ module Rails
445
435
  build(:public_directory)
446
436
  end
447
437
 
438
+ def create_script_folder
439
+ return if options[:dummy_app]
440
+ build(:script)
441
+ end
442
+
448
443
  def create_tmp_files
449
444
  build(:tmp)
450
445
  end
@@ -473,7 +468,6 @@ module Rails
473
468
  def delete_app_assets_if_api_option
474
469
  if options[:api]
475
470
  remove_dir "app/assets"
476
- remove_dir "lib/assets"
477
471
  end
478
472
  end
479
473
 
@@ -490,12 +484,14 @@ module Rails
490
484
  remove_dir "app/views"
491
485
  else
492
486
  remove_file "app/views/layouts/application.html.erb"
487
+ remove_dir "app/views/pwa"
493
488
  end
494
489
  end
495
490
  end
496
491
 
497
492
  def delete_public_files_if_api_option
498
493
  if options[:api]
494
+ remove_file "public/400.html"
499
495
  remove_file "public/404.html"
500
496
  remove_file "public/406-unsupported-browser.html"
501
497
  remove_file "public/422.html"
@@ -505,14 +501,9 @@ module Rails
505
501
  end
506
502
  end
507
503
 
508
- def delete_assets_initializer_skipping_sprockets_and_propshaft
509
- if skip_sprockets? && skip_propshaft?
504
+ def delete_assets_initializer_skipping_asset_pipeline
505
+ if skip_asset_pipeline?
510
506
  remove_file "config/initializers/assets.rb"
511
- end
512
-
513
- if skip_sprockets?
514
- remove_file "app/assets/config/manifest.js"
515
- remove_dir "app/assets/config"
516
507
  remove_file "app/assets/stylesheets/application.css"
517
508
  create_file "app/assets/stylesheets/application.css", "/* Application styles */\n" unless options[:api]
518
509
  end
@@ -542,15 +533,12 @@ module Rails
542
533
  def delete_action_cable_files_skipping_action_cable
543
534
  if options[:skip_action_cable]
544
535
  remove_dir "app/javascript/channels"
545
- remove_dir "app/channels"
546
- remove_dir "test/channels"
547
536
  end
548
537
  end
549
538
 
550
539
  def delete_non_api_initializers_if_api_option
551
540
  if options[:api]
552
541
  remove_file "config/initializers/content_security_policy.rb"
553
- remove_file "config/initializers/permissions_policy.rb"
554
542
  end
555
543
  end
556
544
 
@@ -577,6 +565,8 @@ module Rails
577
565
  public_task :run_javascript
578
566
  public_task :run_hotwire
579
567
  public_task :run_css
568
+ public_task :run_kamal
569
+ public_task :run_solid
580
570
 
581
571
  def run_after_bundle_callbacks
582
572
  @after_bundle_callbacks.each(&:call)
@@ -1,8 +1,11 @@
1
- # syntax = docker/dockerfile:1
1
+ # syntax=docker/dockerfile:1
2
+ # check=error=true
2
3
 
3
4
  # This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
4
- # docker build -t my-app .
5
- # docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY=<value from config/master.key> my-app
5
+ # docker build -t <%= app_name %> .
6
+ # docker run -d -p 80:<%= skip_thruster? ? 3000 : 80 %> -e RAILS_MASTER_KEY=<value from config/master.key> --name <%= app_name %> <%= app_name %>
7
+
8
+ # For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html
6
9
 
7
10
  # Make sure RUBY_VERSION matches the Ruby version in .ruby-version
8
11
  ARG RUBY_VERSION=<%= gem_ruby_version %>
@@ -105,6 +108,12 @@ USER 1000:1000
105
108
  # Entrypoint prepares the database.
106
109
  ENTRYPOINT ["/rails/bin/docker-entrypoint"]
107
110
 
111
+ <% if skip_thruster? -%>
108
112
  # Start the server by default, this can be overwritten at runtime
109
113
  EXPOSE 3000
110
114
  CMD ["./bin/rails", "server"]
115
+ <% else -%>
116
+ # Start server via Thruster by default, this can be overwritten at runtime
117
+ EXPOSE 80
118
+ CMD ["./bin/thrust", "./bin/rails", "server"]
119
+ <% end -%>
@@ -5,20 +5,40 @@ source "https://rubygems.org"
5
5
  <% end -%>
6
6
  <% unless options.minimal? -%>
7
7
 
8
- # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
9
- # gem "kredis"
10
-
11
8
  # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
12
9
  # gem "bcrypt", "~> 3.1.7"
13
10
  <% end -%>
14
11
 
15
12
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
16
13
  gem "tzinfo-data", platforms: %i[ <%= bundler_windows_platforms %> jruby ]
14
+ <% unless options.skip_solid? -%>
15
+
16
+ <% if options.skip_action_cable? -%>
17
+ # Use the database-backed adapters for Rails.cache and Active Job
18
+ <% else -%>
19
+ # Use the database-backed adapters for Rails.cache, Active Job, and Action Cable
20
+ <% end -%>
21
+ gem "solid_cache"
22
+ gem "solid_queue"
23
+ <% unless options.skip_action_cable? -%>
24
+ gem "solid_cable"
25
+ <% end -%>
26
+ <% end -%>
17
27
  <% if depend_on_bootsnap? -%>
18
28
 
19
29
  # Reduces boot times through caching; required in config/boot.rb
20
30
  gem "bootsnap", require: false
21
31
  <% end -%>
32
+ <% unless options.skip_kamal? -%>
33
+
34
+ # Deploy this application anywhere as a Docker container [https://kamal-deploy.org]
35
+ gem "kamal", ">= 2.0.0.rc2", require: false
36
+ <% end -%>
37
+ <% unless options.skip_thruster? -%>
38
+
39
+ # Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/]
40
+ gem "thruster", require: false
41
+ <% end -%>
22
42
  <% unless skip_active_storage? -%>
23
43
 
24
44
  # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
@@ -51,11 +71,6 @@ end
51
71
  group :development do
52
72
  # Use console on exceptions pages [https://github.com/rails/web-console]
53
73
  gem "web-console"
54
- <%- if RUBY_VERSION < "3.2" -%>
55
-
56
- # Highlight the fine-grained location where an error occurred [https://github.com/ruby/error_highlight]
57
- gem "error_highlight", ">= 0.4.0", platforms: [:ruby]
58
- <%- end -%>
59
74
  end
60
75
  <%- end -%>
61
76
 
@@ -1,15 +1,10 @@
1
1
  /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
2
+ * This is a manifest file that'll be compiled into application.css.
4
3
  *
5
- * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
6
- * vendor/assets/stylesheets directory can be referenced here using a relative path.
4
+ * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
5
+ * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
6
+ * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
7
+ * depending on specificity.
7
8
  *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
9
+ * Consider organizing styles into separate files for maintainability.
15
10
  */
@@ -4,19 +4,26 @@
4
4
  <title><%%= content_for(:title) || "<%= app_name.titleize %>" %></title>
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
6
  <meta name="apple-mobile-web-app-capable" content="yes">
7
+ <meta name="mobile-web-app-capable" content="yes">
7
8
  <%%= csrf_meta_tags %>
8
9
  <%%= csp_meta_tag %>
9
10
 
10
11
  <%%= yield :head %>
11
12
 
12
- <link rel="manifest" href="/manifest.json">
13
+ <%%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
14
+ <%%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>
15
+
13
16
  <link rel="icon" href="/icon.png" type="image/png">
14
17
  <link rel="icon" href="/icon.svg" type="image/svg+xml">
15
18
  <link rel="apple-touch-icon" href="/icon.png">
19
+
20
+ <%- style_link_target = options[:skip_asset_pipeline] ? "\"application\"" : ":app" -%>
16
21
  <%- if options[:skip_hotwire] || options[:skip_javascript] -%>
17
- <%%= stylesheet_link_tag "application" %>
22
+ <%%# Includes all stylesheet files in app/views/stylesheets %>
23
+ <%%= stylesheet_link_tag <%= style_link_target %> %>
18
24
  <%- else -%>
19
- <%%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
25
+ <%%# Includes all stylesheet files in app/views/stylesheets %>
26
+ <%%= stylesheet_link_tag <%= style_link_target %>, "data-turbo-track": "reload" %>
20
27
  <%- end -%>
21
28
  </head>
22
29
 
@@ -4,7 +4,7 @@
4
4
  // const { title, options } = await event.data.json()
5
5
  // event.waitUntil(self.registration.showNotification(title, options))
6
6
  // })
7
- //
7
+ //
8
8
  // self.addEventListener("notificationclick", function(event) {
9
9
  // event.notification.close()
10
10
  // event.waitUntil(
@@ -12,12 +12,12 @@
12
12
  // for (let i = 0; i < clientList.length; i++) {
13
13
  // let client = clientList[i]
14
14
  // let clientPath = (new URL(client.url)).pathname
15
- //
15
+ //
16
16
  // if (clientPath == event.notification.data.path && "focus" in client) {
17
17
  // return client.focus()
18
18
  // }
19
19
  // }
20
- //
20
+ //
21
21
  // if (clients.openWindow) {
22
22
  // return clients.openWindow(event.notification.data.path)
23
23
  // }
@@ -0,0 +1 @@
1
+ exec "./bin/rails", "server", *ARGV
@@ -13,7 +13,6 @@ FileUtils.chdir APP_ROOT do
13
13
  # Add necessary setup steps to this file.
14
14
 
15
15
  puts "== Installing dependencies =="
16
- system! "gem install bundler --conservative"
17
16
  system("bundle check") || system!("bundle install")
18
17
  <% if using_node? -%>
19
18
 
@@ -38,10 +37,9 @@ FileUtils.chdir APP_ROOT do
38
37
  puts "\n== Removing old logs and tempfiles =="
39
38
  system! "bin/rails log:clear tmp:clear"
40
39
 
41
- puts "\n== Restarting application server =="
42
- system! "bin/rails restart"
43
-
44
- # puts "\n== Configuring puma-dev =="
45
- # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
46
- # system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
40
+ unless ARGV.include?("--skip-server")
41
+ puts "\n== Starting development server =="
42
+ STDOUT.flush # flush the output before exec(2) so that it displays
43
+ exec "bin/dev"
44
+ end
47
45
  end
@@ -0,0 +1,4 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ load Gem.bin_path("thruster", "thrust")
@@ -52,8 +52,31 @@ test:
52
52
  # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
53
53
  # for a full overview on how database connection configuration can be specified.
54
54
  #
55
+ <%- if options.skip_solid? -%>
55
56
  production:
56
57
  <<: *default
57
58
  database: <%= app_name %>_production
58
59
  username: <%= app_name %>
59
60
  password: <%%= ENV["<%= app_name.upcase %>_DATABASE_PASSWORD"] %>
61
+ <%- else -%>
62
+ production:
63
+ primary: &primary_production
64
+ <<: *default
65
+ database: <%= app_name %>_production
66
+ username: <%= app_name %>
67
+ password: <%%= ENV["<%= app_name.upcase %>_DATABASE_PASSWORD"] %>
68
+ cache:
69
+ <<: *primary_production
70
+ database: <%= app_name %>_production_cache
71
+ migrations_paths: db/cache_migrate
72
+ queue:
73
+ <<: *primary_production
74
+ database: <%= app_name %>_production_queue
75
+ migrations_paths: db/queue_migrate
76
+ <%- unless options.skip_action_cable? -%>
77
+ cable:
78
+ <<: *primary_production
79
+ database: <%= app_name %>_production_cable
80
+ migrations_paths: db/cable_migrate
81
+ <%- end -%>
82
+ <%- end -%>
@@ -84,8 +84,31 @@ test:
84
84
  # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
85
85
  # for a full overview on how database connection configuration can be specified.
86
86
  #
87
+ <%- if options.skip_solid? -%>
87
88
  production:
88
89
  <<: *default
89
90
  database: <%= app_name %>_production
90
91
  username: <%= app_name %>
91
92
  password: <%%= ENV["<%= app_name.upcase %>_DATABASE_PASSWORD"] %>
93
+ <%- else -%>
94
+ production:
95
+ primary: &primary_production
96
+ <<: *default
97
+ database: <%= app_name %>_production
98
+ username: <%= app_name %>
99
+ password: <%%= ENV["<%= app_name.upcase %>_DATABASE_PASSWORD"] %>
100
+ cache:
101
+ <<: *primary_production
102
+ database: <%= app_name %>_production_cache
103
+ migrations_paths: db/cache_migrate
104
+ queue:
105
+ <<: *primary_production
106
+ database: <%= app_name %>_production_queue
107
+ migrations_paths: db/queue_migrate
108
+ <%- unless options.skip_action_cable? -%>
109
+ cable:
110
+ <<: *primary_production
111
+ database: <%= app_name %>_production_cable
112
+ migrations_paths: db/cable_migrate
113
+ <%- end -%>
114
+ <%- end -%>
@@ -21,12 +21,52 @@ test:
21
21
  database: storage/test.sqlite3
22
22
 
23
23
 
24
+ <%- if options.skip_kamal? -%>
24
25
  # SQLite3 write its data on the local filesystem, as such it requires
25
26
  # persistent disks. If you are deploying to a managed service, you should
26
27
  # make sure it provides disk persistence, as many don't.
27
28
  #
28
29
  # Similarly, if you deploy your application as a Docker container, you must
29
30
  # ensure the database is located in a persisted volume.
31
+ <%- if options.skip_solid? -%>
30
32
  production:
31
33
  <<: *default
32
34
  # database: path/to/persistent/storage/production.sqlite3
35
+ <%- else -%>
36
+ production:
37
+ primary:
38
+ <<: *default
39
+ # database: path/to/persistent/storage/production.sqlite3
40
+ cache:
41
+ <<: *default
42
+ # database: path/to/persistent/storage/production_cache.sqlite3
43
+ migrations_paths: db/cache_migrate
44
+ <%- end -%>
45
+ <%- else -%>
46
+ # Store production database in the storage/ directory, which by default
47
+ # is mounted as a persistent Docker volume in config/deploy.yml.
48
+ <%- if options.skip_solid? -%>
49
+ production:
50
+ <<: *default
51
+ database: storage/production.sqlite3
52
+ <%- else -%>
53
+ production:
54
+ primary:
55
+ <<: *default
56
+ database: storage/production.sqlite3
57
+ cache:
58
+ <<: *default
59
+ database: storage/production_cache.sqlite3
60
+ migrations_paths: db/cache_migrate
61
+ queue:
62
+ <<: *default
63
+ database: storage/production_queue.sqlite3
64
+ migrations_paths: db/queue_migrate
65
+ <%- unless options.skip_action_cable? -%>
66
+ cable:
67
+ <<: *default
68
+ database: storage/production_cable.sqlite3
69
+ migrations_paths: db/cable_migrate
70
+ <%- end -%>
71
+ <%- end -%>
72
+ <%- end -%>
@@ -52,8 +52,31 @@ test:
52
52
  # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
53
53
  # for a full overview on how database connection configuration can be specified.
54
54
  #
55
+ <%- if options.skip_solid? -%>
55
56
  production:
56
57
  <<: *default
57
58
  database: <%= app_name %>_production
58
59
  username: <%= app_name %>
59
60
  password: <%%= ENV["<%= app_name.upcase %>_DATABASE_PASSWORD"] %>
61
+ <%- else -%>
62
+ production:
63
+ primary: &primary_production
64
+ <<: *default
65
+ database: <%= app_name %>_production
66
+ username: <%= app_name %>
67
+ password: <%%= ENV["<%= app_name.upcase %>_DATABASE_PASSWORD"] %>
68
+ cache:
69
+ <<: *primary_production
70
+ database: <%= app_name %>_production_cache
71
+ migrations_paths: db/cache_migrate
72
+ queue:
73
+ <<: *primary_production
74
+ database: <%= app_name %>_production_queue
75
+ migrations_paths: db/queue_migrate
76
+ <%- unless options.skip_action_cable? -%>
77
+ cable:
78
+ <<: *primary_production
79
+ database: <%= app_name %>_production_cable
80
+ migrations_paths: db/cable_migrate
81
+ <%- end -%>
82
+ <%- end -%>
@@ -0,0 +1,124 @@
1
+ # Name of your application. Used to uniquely configure containers.
2
+ service: <%= app_name %>
3
+
4
+ # Name of the container image.
5
+ image: your-user/<%= app_name %>
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 one server).
17
+ # Set ssl: false if using something like Cloudflare to terminate SSL (but keep host!).
18
+ proxy:
19
+ ssl: true
20
+ host: app.example.com
21
+
22
+ # Credentials for your image host.
23
+ registry:
24
+ # Specify the registry server, if you're not using Docker Hub
25
+ # server: registry.digitalocean.com / ghcr.io / ...
26
+ username: your-user
27
+
28
+ # Always use an access token rather than real password when possible.
29
+ password:
30
+ - KAMAL_REGISTRY_PASSWORD
31
+
32
+ # Inject ENV variables into containers (secrets come from .kamal/secrets).
33
+ env:
34
+ secret:
35
+ - RAILS_MASTER_KEY
36
+ <% if skip_solid? -%>
37
+ # clear:
38
+ # # Set number of cores available to the application on each server (default: 1).
39
+ # WEB_CONCURRENCY: 2
40
+
41
+ # # Match this to any external database server to configure Active Record correctly
42
+ # DB_HOST: 192.168.0.2
43
+
44
+ # # Log everything from Rails
45
+ # RAILS_LOG_LEVEL: debug
46
+ <% else -%>
47
+ clear:
48
+ # Run the Solid Queue Supervisor inside the web server's Puma process to do jobs.
49
+ # When you start using multiple servers, you should split out job processing to a dedicated machine.
50
+ SOLID_QUEUE_IN_PUMA: true
51
+
52
+ # Set number of processes dedicated to Solid Queue (default: 1)
53
+ # JOB_CONCURRENCY: 3
54
+
55
+ # Set number of cores available to the application on each server (default: 1).
56
+ # WEB_CONCURRENCY: 2
57
+
58
+ # Match this to any external database server to configure Active Record correctly
59
+ # DB_HOST: 192.168.0.2
60
+
61
+ # Log everything from Rails
62
+ # RAILS_LOG_LEVEL: debug
63
+ <% end -%>
64
+
65
+ # Aliases are triggered with "bin/kamal <alias>". You can overwrite arguments on invocation:
66
+ # "bin/kamal logs -r job" will tail logs from the first server in the job section.
67
+ aliases:
68
+ console: app exec --interactive --reuse "bin/rails console"
69
+ shell: app exec --interactive --reuse "bash"
70
+ logs: app logs -f
71
+ dbc: app exec --interactive --reuse "bin/rails dbconsole"
72
+
73
+ <% unless skip_storage? %>
74
+ # Use a persistent storage volume for sqlite database files and local Active Storage files.
75
+ # Recommended to change this to a mounted volume path that is backed up off server.
76
+ volumes:
77
+ - "<%= app_name %>_storage:/rails/storage"
78
+
79
+ <% end %>
80
+ # Bridge fingerprinted assets, like JS and CSS, between versions to avoid
81
+ # hitting 404 on in-flight requests. Combines all files from new and old
82
+ # version inside the asset_path.
83
+ asset_path: /rails/public/assets
84
+
85
+ # Configure the image builder.
86
+ builder:
87
+ arch: amd64
88
+
89
+ # # Build image via remote server (useful for faster amd64 builds on arm64 computers)
90
+ # remote: ssh://docker@docker-builder-server
91
+ #
92
+ # # Pass arguments and secrets to the Docker build process
93
+ # args:
94
+ # RUBY_VERSION: <%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}" %>
95
+ # secrets:
96
+ # - GITHUB_TOKEN
97
+ # - RAILS_MASTER_KEY
98
+
99
+ # Use a different ssh user than root
100
+ # ssh:
101
+ # user: app
102
+
103
+ # Use accessory services (secrets come from .kamal/secrets).
104
+ # accessories:
105
+ # db:
106
+ # image: mysql:8.0
107
+ # host: 192.168.0.2
108
+ # port: 3306
109
+ # env:
110
+ # clear:
111
+ # MYSQL_ROOT_HOST: '%'
112
+ # secret:
113
+ # - MYSQL_ROOT_PASSWORD
114
+ # files:
115
+ # - config/mysql/production.cnf:/etc/mysql/my.cnf
116
+ # - db/production.sql:/docker-entrypoint-initdb.d/setup.sql
117
+ # directories:
118
+ # - data:/var/lib/mysql
119
+ # redis:
120
+ # image: redis:7.0
121
+ # host: 192.168.0.2
122
+ # port: 6379
123
+ # directories:
124
+ # - data:/data