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"] %>