From 7bc63e6e815eb5e1ee7d7e8f370783f8d44d2c54 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 15 Feb 2021 18:23:50 +0000 Subject: [PATCH] Re-add db2fog Turns out it works with Rails 5 --- Gemfile | 2 ++ Gemfile.lock | 30 ++++++++++++++++++++++++++++++ config/initializers/db2fog.rb | 15 +++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 config/initializers/db2fog.rb diff --git a/Gemfile b/Gemfile index c332cac4ab..80f4e20c3e 100644 --- a/Gemfile +++ b/Gemfile @@ -20,6 +20,8 @@ gem 'rails-i18n' gem 'rails_safe_tasks', '~> 1.0' gem "activerecord-import" +gem "db2fog", github: "openfoodfoundation/db2fog", branch: "rails-5" +gem "fog-aws", ">= 0.6.0" gem "catalog", path: "./engines/catalog" gem 'dfc_provider', path: './engines/dfc_provider' diff --git a/Gemfile.lock b/Gemfile.lock index a7fedccba3..e3d7d1e8ca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,6 +4,16 @@ GIT specs: custom_error_message (1.1.1) +GIT + remote: https://github.com/openfoodfoundation/db2fog.git + revision: 8ceef362c64e6573d62d26db5ebb0c0f33cd3d61 + branch: rails-5 + specs: + db2fog (0.9.1) + activerecord (>= 3.2.0, < 6.0) + fog-core (~> 1.0) + rails (>= 3.2.0, < 6.0) + GIT remote: https://github.com/openfoodfoundation/ofn-qz.git revision: 467f6ea1c44529c7c91cac4c8211bbd863588c0b @@ -202,6 +212,7 @@ GEM docile (1.3.4) erubis (2.7.0) eventmachine (1.2.7) + excon (0.79.0) execjs (2.7.0) factory_bot (5.2.0) activesupport (>= 4.2.0) @@ -214,6 +225,22 @@ GEM ffi (1.13.1) figaro (1.2.0) thor (>= 0.14.0, < 2) + fog-aws (2.0.1) + fog-core (~> 1.38) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-core (1.45.0) + builder + excon (~> 0.58) + formatador (~> 0.2) + fog-json (1.2.0) + fog-core + multi_json (~> 1.10) + fog-xml (0.1.3) + fog-core + nokogiri (>= 1.5.11, < 2.0.0) + formatador (0.2.5) foundation-icons-sass-rails (3.0.0) railties (>= 3.1.1) sass-rails (>= 3.1.1) @@ -243,6 +270,7 @@ GEM i18n (>= 0.6.6) immigrant (0.3.6) activerecord (>= 3.0) + ipaddress (0.8.3) jquery-migrate-rails (1.2.1) jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) @@ -588,6 +616,7 @@ DEPENDENCIES daemons dalli database_cleaner + db2fog! ddtrace debugger-linecache delayed_job_active_record @@ -600,6 +629,7 @@ DEPENDENCIES factory_bot_rails (= 5.2.0) ffaker figaro + fog-aws (>= 0.6.0) foundation-icons-sass-rails foundation-rails (= 5.5.2.1) fuubar (~> 2.5.1) diff --git a/config/initializers/db2fog.rb b/config/initializers/db2fog.rb new file mode 100644 index 0000000000..ba5b9c7e1d --- /dev/null +++ b/config/initializers/db2fog.rb @@ -0,0 +1,15 @@ +require_relative 'spree' + +# See: https://github.com/itbeaver/db2fog +DB2Fog.config = { + :aws_access_key_id => Spree::Config[:s3_access_key], + :aws_secret_access_key => Spree::Config[:s3_secret], + :directory => ENV['S3_BACKUPS_BUCKET'], + :provider => 'AWS' +} + +region = ENV['S3_BACKUPS_REGION'] || ENV['S3_REGION'] + +# If no region is defined we leave this config key undefined (instead of nil), +# so that db2fog correctly applies it's default +DB2Fog.config[:region] = region if region