PERF: Cleanup unneeded S3 assets after deploys (#151)

This commit is contained in:
David Taylor 2022-11-17 12:11:28 +00:00 committed by GitHub
parent be0a4ef620
commit b2e7546e09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -104,8 +104,9 @@ class DockerManager::Upgrader
less_memory_flags = "RUBY_GC_MALLOC_LIMIT_MAX=20971520 RUBY_GC_OLDMALLOC_LIMIT_MAX=20971520 RUBY_GC_HEAP_GROWTH_MAX_SLOTS=50000 RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=0.9 "
run("#{less_memory_flags} bundle exec rake themes:update assets:precompile")
# if assets are served from S3, upload newly created ones to the bucket
if ENV["DISCOURSE_USE_S3"] && ENV["DISCOURSE_S3_BUCKET"] && ENV["DISCOURSE_S3_CDN_URL"]
using_s3_assets = ENV["DISCOURSE_USE_S3"] && ENV["DISCOURSE_S3_BUCKET"] && ENV["DISCOURSE_S3_CDN_URL"]
if using_s3_assets
run("#{less_memory_flags} bundle exec rake s3:upload_assets")
end
@ -124,6 +125,11 @@ class DockerManager::Upgrader
percent(90)
log("Running post deploy migrations")
run("bundle exec rake multisite:migrate")
if using_s3_assets
run("bundle exec rake s3:expire_missing_assets")
end
log_version_upgrade
percent(100)
log("DONE")