Skip to content

Commit

Permalink
Merge pull request #132 from OpenSourcePolitics/fix/object-storage-co…
Browse files Browse the repository at this point in the history
…nfig

Fix the config for the Object Storage URL path builder
  • Loading branch information
Quentinchampenois authored Sep 26, 2023
2 parents d5997a7 + 1839e2d commit 30d958e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,15 @@ THROTTLING_PERIOD=60
# FRIENDLY_SIGNUP_USE_CONFIRMATION_CODES=
# SKIP_FIRST_LOGIN_AUTHORIZATION=

# SCALEWAY_ID - String - required if Active Storage use Scaleway as storage service
SCALEWAY_ID=
# SCALEWAY_TOKEN - String - required if SCALEWAY_ID is set
SCALEWAY_TOKEN=
# SCALEWAY_BUCKET_NAME - String - required if SCALEWAY_ID is set
SCALEWAY_BUCKET_NAME=
# SCALEWAY_REGION - String - optional - default to "fr-par" - set the scaleway storage region
SCALEWAY_REGION=
# OBJECTSTORE_S3_HOST - String - optional - default to "s3.fr-par.scw.cloud" - set the object storage endpoint
OBJECTSTORE_S3_HOST=
# OBJECTSTORE_S3_FORCE_PATH_STYLE - String - optional - default to "true" - When set to true, the bucket name is always left in the request URI and never moved to the host as a sub-domain
OBJECTSTORE_S3_FORCE_PATH_STYLE=
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
config.action_mailer.delivery_method = :letter_opener_web
config.action_mailer.default_url_options = { port: 3000 }
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
config.active_storage.service = Rails.application.secrets.dig(:scaleway, :id).blank? ? :local : :scaleway

config.action_mailer.perform_caching = false

Expand Down
2 changes: 2 additions & 0 deletions config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ default: &default
id: <%= ENV["SCALEWAY_ID"] %>
token: <%= ENV["SCALEWAY_TOKEN"] %>
bucket_name: <%= ENV["SCALEWAY_BUCKET_NAME"] %>
region: <%= ENV.fetch("SCALEWAY_REGION", "fr-par") %>
endpoint: <%= ENV.fetch("OBJECTSTORE_S3_HOST", "s3.fr-par.scw.cloud") %>
force_path_style: <%= ENV.fetch("OBJECTSTORE_S3_FORCE_PATH_STYLE", "true") %>
helpscout:
user:
main: <%= ENV["HELP_SCOUT_BEACON_USER_SIDE_ID_MAIN"] %>
Expand Down
3 changes: 2 additions & 1 deletion config/storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ scaleway:
endpoint: https://<%= Rails.application.secrets.dig(:scaleway, :endpoint) %>
access_key_id: <%= Rails.application.secrets.dig(:scaleway, :id) %>
secret_access_key: <%= Rails.application.secrets.dig(:scaleway, :token) %>
region: fr-par
region: <%= Rails.application.secrets.dig(:scaleway, :region) %>
bucket: <%= Rails.application.secrets.dig(:scaleway, :bucket_name) %>
force_path_style: <%= Rails.application.secrets.dig(:scaleway, :force_path_style) %>

# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
Expand Down

0 comments on commit 30d958e

Please sign in to comment.