From b3bc0bb2ff69147cc7c10e5bea2eb4b22904a547 Mon Sep 17 00:00:00 2001 From: Hosmel Quintana Date: Sun, 7 Dec 2025 09:28:58 -0600 Subject: [PATCH 1/4] allow configuring Active Storage service and add AWS S3 definition --- README.md | 17 +++++++++++++++++ config/environments/production.rb | 3 +++ config/storage.oss.yml | 9 +++++++++ 3 files changed, 29 insertions(+) diff --git a/README.md b/README.md index 07f55614e..87a4658a0 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,23 @@ After the first deploy is done, any subsequent steps won't need to do that initi bin/kamal deploy ``` +## File storage (Active Storage) + +Production uses the local disk service by default. To use any other service defined in `config/storage.yml`, set `ACTIVE_STORAGE_SERVICE`. + +To use the included `aws` service, set: + +- `ACTIVE_STORAGE_SERVICE=aws` +- `AWS_ACCESS_KEY_ID` +- `AWS_BUCKET` (defaults to `fizzy-#{Rails.env}-activestorage`) +- `AWS_REGION` (defaults to `us-east-1`) +- `AWS_SECRET_ACCESS_KEY` + +Optional for S3-compatible endpoints: + +- `AWS_ENDPOINT` +- `AWS_FORCE_PATH_STYLE=true` + ## Development ### Setting up diff --git a/config/environments/production.rb b/config/environments/production.rb index 7b29a00d1..d211490d1 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -40,6 +40,9 @@ Rails.application.configure do "Cache-Control" => "public, max-age=#{1.year.to_i}" } + # Select Active Storage service via env var; default to local disk. + config.active_storage.service = ENV.fetch("ACTIVE_STORAGE_SERVICE", nil).presence&.to_sym || :local + # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = "http://assets.example.com" diff --git a/config/storage.oss.yml b/config/storage.oss.yml index e50debd34..0c9430a88 100644 --- a/config/storage.oss.yml +++ b/config/storage.oss.yml @@ -16,3 +16,12 @@ devminio: region: us-east-1 # default region required for signer access_key_id: minioadmin secret_access_key: minioadmin + +aws: + service: S3 + access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %> + bucket: <%= ENV["AWS_BUCKET"] || "fizzy-#{Rails.env}-activestorage" %> + endpoint: <%= ENV["AWS_ENDPOINT"] %> + force_path_style: <%= ENV["AWS_FORCE_PATH_STYLE"] == "true" %> + region: <%= ENV.fetch("AWS_REGION", "us-east-1") %> + secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %> From ac1f935d532fc0f6ce061f4ca9fc300832e9ef3a Mon Sep 17 00:00:00 2001 From: Hosmel Quintana Date: Fri, 5 Dec 2025 10:06:01 -0600 Subject: [PATCH 2/4] Update config/environments/production.rb Co-authored-by: Alex Ghiculescu --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index d211490d1..68cd831ce 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -41,7 +41,7 @@ Rails.application.configure do } # Select Active Storage service via env var; default to local disk. - config.active_storage.service = ENV.fetch("ACTIVE_STORAGE_SERVICE", nil).presence&.to_sym || :local + config.active_storage.service = ENV.fetch("ACTIVE_STORAGE_SERVICE", "local").to_sym # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = "http://assets.example.com" From 2eeeda9bad793a15eaf8f232435c6dee087dd366 Mon Sep 17 00:00:00 2001 From: Hosmel Quintana Date: Fri, 5 Dec 2025 11:57:19 -0600 Subject: [PATCH 3/4] rename Active Storage service to s3 and add checksum env --- README.md | 18 ++++++++++-------- config/storage.oss.yml | 16 +++++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 87a4658a0..20fdf7936 100644 --- a/README.md +++ b/README.md @@ -99,18 +99,20 @@ bin/kamal deploy Production uses the local disk service by default. To use any other service defined in `config/storage.yml`, set `ACTIVE_STORAGE_SERVICE`. -To use the included `aws` service, set: +To use the included `s3` service, set: -- `ACTIVE_STORAGE_SERVICE=aws` -- `AWS_ACCESS_KEY_ID` -- `AWS_BUCKET` (defaults to `fizzy-#{Rails.env}-activestorage`) -- `AWS_REGION` (defaults to `us-east-1`) -- `AWS_SECRET_ACCESS_KEY` +- `ACTIVE_STORAGE_SERVICE=s3` +- `S3_ACCESS_KEY_ID` +- `S3_BUCKET` (defaults to `fizzy-#{Rails.env}-activestorage`) +- `S3_REGION` (defaults to `us-east-1`) +- `S3_SECRET_ACCESS_KEY` Optional for S3-compatible endpoints: -- `AWS_ENDPOINT` -- `AWS_FORCE_PATH_STYLE=true` +- `S3_ENDPOINT` +- `S3_FORCE_PATH_STYLE=true` +- `S3_REQUEST_CHECKSUM_CALCULATION` (defaults to `when_supported`) +- `S3_RESPONSE_CHECKSUM_VALIDATION` (defaults to `when_supported`) ## Development diff --git a/config/storage.oss.yml b/config/storage.oss.yml index 0c9430a88..37052e6c5 100644 --- a/config/storage.oss.yml +++ b/config/storage.oss.yml @@ -17,11 +17,13 @@ devminio: access_key_id: minioadmin secret_access_key: minioadmin -aws: +s3: service: S3 - access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %> - bucket: <%= ENV["AWS_BUCKET"] || "fizzy-#{Rails.env}-activestorage" %> - endpoint: <%= ENV["AWS_ENDPOINT"] %> - force_path_style: <%= ENV["AWS_FORCE_PATH_STYLE"] == "true" %> - region: <%= ENV.fetch("AWS_REGION", "us-east-1") %> - secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %> + access_key_id: <%= ENV["S3_ACCESS_KEY_ID"] %> + bucket: <%= ENV["S3_BUCKET"] || "fizzy-#{Rails.env}-activestorage" %> + endpoint: <%= ENV["S3_ENDPOINT"] %> + force_path_style: <%= ENV["S3_FORCE_PATH_STYLE"] == "true" %> + region: <%= ENV.fetch("S3_REGION", "us-east-1") %> + request_checksum_calculation: <%= ENV.fetch("S3_REQUEST_CHECKSUM_CALCULATION", "when_supported") %> + response_checksum_validation: <%= ENV.fetch("S3_RESPONSE_CHECKSUM_VALIDATION", "when_supported") %> + secret_access_key: <%= ENV["S3_SECRET_ACCESS_KEY"] %> From a5396bbb1ae431dcd85338c4032947ca8b384006 Mon Sep 17 00:00:00 2001 From: Kevin McConnell Date: Wed, 10 Dec 2025 14:08:08 +0000 Subject: [PATCH 4/4] Don't overwrite storage service from engine --- config/environments/production.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 68cd831ce..71991aecd 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -41,7 +41,10 @@ Rails.application.configure do } # Select Active Storage service via env var; default to local disk. - config.active_storage.service = ENV.fetch("ACTIVE_STORAGE_SERVICE", "local").to_sym + # Don't overwrite if it's already been set (e.g. by fizzy-saas) + if config.active_storage.service.blank? + config.active_storage.service = ENV.fetch("ACTIVE_STORAGE_SERVICE", "local").to_sym + end # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = "http://assets.example.com"