Make S3 service configurable #190
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR refactors environment variables to allow configuration of alternative S3-compatible services for presentation storage through the config offered by ExAws.S3. It also adds
get_slide_urls/1andget_slide_urls/2functions to theClaper.Presentationscontext module to encapsulate the logic to produce these URL depending on storage config. This results in small refactors of the "manage" and "presenter" live views.I was not able to set up Minio locally successfully but was able to make this work against a Cloudflare R2 bucket. Cloudflare offers a public URL that's different from the S3-compatible endpoint, which is why I also added the
S3_PUBLIC_URLenv var. If not supplied, the code is intended to default to either the regular AWS or the supplied S3_SCHEME, S3_HOST and S3_PORT URL.The PR also includes a commit that deletes some dead code: we're not using the direct upload to S3 in
app.jsat the moment and we're also not using the code inlib/utils. Mogrify also goes as it was only being used in one of these deleted modules. We can revert some of the deletions if you feel strongly about keeping some of this code around.Open questions
I don't know much Kubernetes so not sure what to do about the code in the
charts/folder. I suppose the new variables should also be added to the template config YAML file? Do we still need this code or can we delete it?I attempted to add a test to the new
get_slide_urls/nfunctions, but I had to end up messing around withApplication.put_env/4in a way that seemed sketchy so I gave up. I was also not feeling like the tests were adding much. Let me know if you'd prefer that I add some tests.Would you like me to add a related PR to the docs site explaining the new S3 config affordances?
When I test locally, by adding an event with a presentation, I get a duplicate event ID error like the one we're targeting in Improve event live listing #185 when the presentation is done converting/uploading. I don't think this is caused by this PR. My suggestion is that we look into fixing that in a different PR (or maybe in Improve event live listing #185) to avoid increasing the scope of this one. Just wanted to flag this in case you want to take a look.
Testing
I tested by configuring an R2 bucket and setting my env vars to the right values. If you can test against a local Minio or similar, that'd be great so that we are more certain the current design works across services.
mix teststill also runs successfully.