Browse Source

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
pull/1876/head
Rachael Booth 1 year ago committed by GitHub
parent
commit
9fd04fa9dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Dockerfile
  2. 13
      app/services/storage/s3_service.rb
  3. 2
      config/initializers/rack_attack.rb
  4. 2
      config/initializers/sidekiq.rb

2
Dockerfile

@ -10,7 +10,7 @@ RUN apk add --update --no-cache tzdata && \
# build-base: compilation tools for bundle # build-base: compilation tools for bundle
# yarn: node package manager # yarn: node package manager
# postgresql-dev: postgres driver and libraries # 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 # Bundler version should be the same version as what the Gemfile.lock was bundled with
RUN gem install bundler:2.3.14 --no-document RUN gem install bundler:2.3.14 --no-document

13
app/services/storage/s3_service.rb

@ -54,11 +54,14 @@ module Storage
end end
def create_client def create_client
credentials = credentials = if PlatformHelper.is_paas?
Aws::Credentials.new( Aws::Credentials.new(
@configuration.access_key_id, @configuration.access_key_id,
@configuration.secret_access_key, @configuration.secret_access_key,
) )
else
Aws::ECSCredentials.new
end
Aws::S3::Client.new( Aws::S3::Client.new(
region: @configuration.region, region: @configuration.region,
credentials:, credentials:,

2
config/initializers/rack_attack.rb

@ -12,7 +12,7 @@ elsif Rails.env.review?
redis_url = configuration_service.redis_uris.to_a[0][1] redis_url = configuration_service.redis_uris.to_a[0][1]
Rack::Attack.cache.store = ActiveSupport::Cache::RedisCacheStore.new(url: redis_url) Rack::Attack.cache.store = ActiveSupport::Cache::RedisCacheStore.new(url: redis_url)
else 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) Rack::Attack.cache.store = ActiveSupport::Cache::RedisCacheStore.new(url: redis_url)
end end

2
config/initializers/sidekiq.rb

@ -4,7 +4,7 @@ require "sidekiq/cron/web"
configuration_service = PlatformHelper.is_paas? ? Configuration::PaasConfigurationService.new : Configuration::EnvConfigurationService.new configuration_service = PlatformHelper.is_paas? ? Configuration::PaasConfigurationService.new : Configuration::EnvConfigurationService.new
if Rails.env.staging? || Rails.env.production? 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| Sidekiq.configure_server do |config|
config.redis = { url: redis_url } config.redis = { url: redis_url }

Loading…
Cancel
Save