How to Configure Cloudflare R2 for your Discourse Community

For multisite, for my understandingwhat you are are already doing, you want only one instance using R2. If your settings are in admin settings. You need to use USE_DB_S3_CONFIG=true with RAILS_DB=default for it and will work like a charm

hooks:
  after_assets_precompile:
    - exec:
        cd: $home
        cmd:
          - sudo -E -u discourse RAILS_DB=default USE_DB_S3_CONFIG=true bundle exec rake s3:upload_assets
          - sudo -E -u discourse RAILS_DB=default USE_DB_S3_CONFIG=true bundle exec rake s3:expire_missing_assets

For migration of uploads you need to export these variables like below or one by one.

RAILS_DB=default \
DISCOURSE_S3_REGION=auto \
DISCOURSE_S3_ENDPOINT=https://<account-id>.r2.cloudflarestorage.com \
DISCOURSE_S3_BUCKET=discourse-files \
DISCOURSE_S3_ACCESS_KEY_ID=<your-access-key> \
DISCOURSE_S3_SECRET_ACCESS_KEY=<your-secret-key> \
rake uploads:migrate_to_s3

If you are planning on putting it in app.yml make sure to use DISCOURSE_S3_BUCKET because there is typos in R2 section of Configure an S3 compatible object storage provider for uploads