feat(cdn): add BUCKET_PROVIDER env var for explicit storage provider selection #541
+2,521
−7,099
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.
feat(cdn): add BUCKET_PROVIDER env var for explicit storage provider selection
Summary
Fixes an issue where
isMiniowas alwaystruebecauseminioEndpoint: 'http://localhost:9000'was hardcoded inpgpmDefaults. Whendeepmergecombined defaults with env vars, the defaultminioEndpointpersisted even when not explicitly set, causing S3 to be misconfigured in production.This PR adds a
BUCKET_PROVIDERenv var (s3|minio|gcs) as the single source of truth for provider selection. The provider is propagated through the entire upload chain:pgpm/types→pgpm/env→s3-streamer→graphile-upload-plugin→graphile-settings→explorerKey changes:
BucketProvidertype andproviderfield inCDNOptions'minio'for local dev (preserves existing behavior)BUCKET_PROVIDER=s3in production correctly configures for S3IS_MINIOenv var and hostname heuristics entirelycreateS3Bucketnow requires explicit{ provider }options parameterUpdates since last revision
process.envis only read in env packages (pgpm/env)createS3Bucket(client, bucket)→createS3Bucket(client, bucket, { provider })process.env.BUCKET_PROVIDERreads froms3-utilsgetEnvOptions()at call sites{ provider: 'minio' }instead of setting env varsconsole.log/console.errorwithLoggerincreate-bucket.tsReview & Testing Checklist for Human
createS3Bucketsignature changed - verify no external callers exist outside this repoopts.provider === 'minio' || (opts.provider === undefined && Boolean(opts.minioEndpoint))- verify this backwards-compat fallback is intentional or should be removedBUCKET_PROVIDER=s3and verify MinIO-specific config (endpoint, forcePathStyle) is NOT appliedBUCKET_PROVIDER=minio(or unset, which defaults to minio) works with local MinIORecommended test plan:
BUCKET_PROVIDER=s3against real S3 bucketBUCKET_PROVIDER=minioagainst local MinIOIS_MINIOandprocess.env.BUCKET_PROVIDERto verify cleanup is completeNotes
BUCKET_PROVIDERenv var is not validated at runtime - invalid values will be passed through as-ispnpm-lock.yamlchanges are mostly formatting; the only functional change is adding@pgpmjs/typesas a dependency tographile-upload-plugingcs(Google Cloud Storage) support using the same provider patternLink to Devin run: https://app.devin.ai/sessions/786904f315914f5c9d9c45e6707d7048
Requested by: Dan Lynch (@pyramation)