This is what finally worked:
These settings had to be in the app.yml config in order for it to finally run the rakes correctly. When they were just in the /admin/site_settings/ area, it wouldn’t run the rakes correctly. I was getting an errror:
ERROR: Ensure S3 is configured in config/discourse.conf or environment vars
The settings are from here… Configure an S3 compatible object storage provider for uploads
Specifically, I used non-custom Spaces settings with two spaces before each line. …
DISCOURSE_USE_S3: true
DISCOURSE_S3_REGION: whatever
DISCOURSE_S3_ENDPOINT: https://nyc3.digitaloceanspaces.com
DISCOURSE_S3_ACCESS_KEY_ID: myaccesskey
DISCOURSE_S3_SECRET_ACCESS_KEY: mysecretkey
DISCOURSE_S3_CDN_URL: https://nyc3.cdn.digitaloceanspaces.com
DISCOURSE_S3_BUCKET: my-files
DISCOURSE_S3_BACKUP_BUCKET: my-files/my-backups
DISCOURSE_BACKUP_LOCATION: s3
DISCOURSE_S3_INSTALL_CORS_RULE: false
NOTE: DISCOURSE_S3_REGION should literally say “whatever” and not something that could be construed as an actual S3 region (ie. us-west-1).
Also these settings, in the hooks section of the ## Plugins go here area…
after_assets_precompile:
- exec:
cd: $home
cmd:
- sudo -E -u discourse bundle exec rake s3:upload_assets
- sudo -E -u discourse bundle exec rake s3:expire_missing_assets
This is where I ran into an issue last time. Once that’s in place and I rebuilt, I was getting this loading screen when I tried to bring up our forum in a browser.
This is only because it’s looking for assets that haven’t yet been updated. This is where it’s time to run the rakes, from inside the app…
./launcher enter app
rake s3:upload_assets
Once that ran, the items number jumped up and an “assets” folder showed up in our bucket…
Then the forum started loading correctly. These are the only S3 related settings that I have showing in my /admin/site-settings area…
I ran this to upload all of the files and it updated the URLs from the old path to the new (non-CDN).
rake uploads:migrate_to_s3 --trace
The items number more than tripled after that finished.
The only thing I noticed was that old post image paths were using the S3 ENDPOINT URL versus newly posted images were using the S3 CDN URL.
https:/my-storage.sfo3.digitaloceanspaces.com/
vs
https:/my-storage.sfo3.cdn.digitaloceanspaces.com/
I didn’t really care because at least it was all using S3.
But I tried running…
rake posts:rebake

It killed it because it ran out of memory. I tried running this instead…
rake posts:rebake_uncooked_posts
It ran out of memory a few times and restarted itself, then ran out of memory again. Ran it again. Eventually it got through cooking them all.
Once it ran all the way through to 100%, all of the links were finally using the S3 CDN URL path, old and new posts. Over 34062 items at 65.9 GB of storage (a backup is <9 GB).
Really happy that it’s all working off of S3 now, including backups. Speaking of, probably a good time to run one!
Hope this helps someone.
Good luck!





