mirror of https://github.com/rails/rails
Don’t configure Kamal storage volume if not needed
Configuring a persistent storage volume in Kamal is needed only for sqlite or Active Storage. If using a different database or the --skip-active-storage option, this configuration can be skipped.
This commit is contained in:
parent
965b8c372a
commit
3156e50838
|
@ -366,6 +366,10 @@ module Rails
|
|||
options[:skip_active_storage]
|
||||
end
|
||||
|
||||
def skip_storage? # :doc:
|
||||
skip_active_storage? && !sqlite3?
|
||||
end
|
||||
|
||||
def skip_action_cable? # :doc:
|
||||
options[:skip_action_cable]
|
||||
end
|
||||
|
@ -784,7 +788,7 @@ module Rails
|
|||
def dockerfile_chown_directories
|
||||
directories = %w(log tmp)
|
||||
|
||||
directories << "storage" unless skip_active_storage? && !sqlite3?
|
||||
directories << "storage" unless skip_storage?
|
||||
directories << "db" unless skip_active_record?
|
||||
|
||||
directories.sort
|
||||
|
|
|
@ -31,11 +31,13 @@ env:
|
|||
# clear:
|
||||
# DB_HOST: 192.168.0.2
|
||||
|
||||
<% unless skip_storage? %>
|
||||
# Use a persistent storage volume for sqlite database files and local Active Storage files.
|
||||
# Recommended to change this to a mounted volume path that is backed up off server.
|
||||
volumes:
|
||||
- "<%= app_name %>_storage:/rails/storage"
|
||||
|
||||
<% end %>
|
||||
# Bridge fingerprinted assets, like JS and CSS, between versions to avoid
|
||||
# hitting 404 on in-flight requests. Combines all files from new and old
|
||||
# version inside the asset_path.
|
||||
|
|
|
@ -668,6 +668,34 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
|||
assert_no_file ".env.erb"
|
||||
end
|
||||
|
||||
def test_inclusion_of_kamal_storage_volume
|
||||
run_generator_and_bundler [destination_root]
|
||||
|
||||
assert_file "config/deploy.yml" do |content|
|
||||
assert_match(%r{storage:/rails/storage}, content)
|
||||
end
|
||||
end
|
||||
|
||||
def test_inclusion_of_kamal_storage_volume_if_only_skip_active_storage_is_given
|
||||
run_generator_and_bundler [destination_root, "--skip-active-storage"]
|
||||
|
||||
assert_file "config/deploy.yml" do |content|
|
||||
assert_match(%r{storage:/rails/storage}, content)
|
||||
end
|
||||
end
|
||||
|
||||
def test_kamal_storage_volume_is_skipped_if_required
|
||||
run_generator_and_bundler [
|
||||
destination_root,
|
||||
"--skip-active-storage",
|
||||
"--database=postgresql"
|
||||
]
|
||||
|
||||
assert_file "config/deploy.yml" do |content|
|
||||
assert_no_match(%r{storage:/rails/storage}, content)
|
||||
end
|
||||
end
|
||||
|
||||
def test_usage_read_from_file
|
||||
assert_called(File, :read, returns: "USAGE FROM FILE") do
|
||||
assert_equal "USAGE FROM FILE", Rails::Generators::AppGenerator.desc
|
||||
|
|
Loading…
Reference in New Issue