From 9fd04fa9dd9a39681fbd89ec6fcc348660df50b6 Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Tue, 29 Aug 2023 14:36:23 +0100 Subject: [PATCH] Infra migration updates (#1872) * Update postgresql version in dockerfile * CLDC-2690: Update s3 service to use ECS credential provider when not on PaaS * Temporary fix for redis config when not on PaaS * Fix rubocop offences --- Dockerfile | 2 +- app/services/storage/s3_service.rb | 13 ++++++++----- config/initializers/rack_attack.rb | 2 +- config/initializers/sidekiq.rb | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index e4c3617c1..bdba399ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN apk add --update --no-cache tzdata && \ # build-base: compilation tools for bundle # yarn: node package manager # postgresql-dev: postgres driver and libraries -RUN apk add --no-cache build-base=0.5-r3 yarn=1.22.19-r0 postgresql13-dev=13.11-r0 git=2.40.1-r0 bash=5.2.15-r5 +RUN apk add --no-cache build-base=0.5-r3 yarn=1.22.19-r0 postgresql13-dev=13.12-r0 git=2.40.1-r0 bash=5.2.15-r5 # Bundler version should be the same version as what the Gemfile.lock was bundled with RUN gem install bundler:2.3.14 --no-document diff --git a/app/services/storage/s3_service.rb b/app/services/storage/s3_service.rb index c972225a1..5c6f5ff45 100644 --- a/app/services/storage/s3_service.rb +++ b/app/services/storage/s3_service.rb @@ -54,11 +54,14 @@ module Storage end def create_client - credentials = - Aws::Credentials.new( - @configuration.access_key_id, - @configuration.secret_access_key, - ) + credentials = if PlatformHelper.is_paas? + Aws::Credentials.new( + @configuration.access_key_id, + @configuration.secret_access_key, + ) + else + Aws::ECSCredentials.new + end Aws::S3::Client.new( region: @configuration.region, credentials:, diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb index 9b201b054..3dd573b41 100644 --- a/config/initializers/rack_attack.rb +++ b/config/initializers/rack_attack.rb @@ -12,7 +12,7 @@ elsif Rails.env.review? redis_url = configuration_service.redis_uris.to_a[0][1] Rack::Attack.cache.store = ActiveSupport::Cache::RedisCacheStore.new(url: redis_url) else - redis_url = configuration_service.redis_uris[:"dluhc-core-#{Rails.env}-redis"] + redis_url = PlatformHelper.is_paas? ? configuration_service.redis_uris[:"dluhc-core-#{Rails.env}-redis"] : configuration_service.redis_uris.to_a[0][1] Rack::Attack.cache.store = ActiveSupport::Cache::RedisCacheStore.new(url: redis_url) end diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index bc1b578ef..74e6ce9a2 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -4,7 +4,7 @@ require "sidekiq/cron/web" configuration_service = PlatformHelper.is_paas? ? Configuration::PaasConfigurationService.new : Configuration::EnvConfigurationService.new if Rails.env.staging? || Rails.env.production? - redis_url = configuration_service.redis_uris[:"dluhc-core-#{Rails.env}-redis"] + redis_url = PlatformHelper.is_paas? ? configuration_service.redis_uris[:"dluhc-core-#{Rails.env}-redis"] : configuration_service.redis_uris.to_a[0][1] Sidekiq.configure_server do |config| config.redis = { url: redis_url }