I need some direction on how best to run multi-environments with Craft assets and static asset builds (JS, CSS, etc) going to S3.

I have three environments: dev, staging, and production. Each have their own separate databases that I can sync, for example from production to staging, etc. Currently, Craft's assets and static assets like JS, CSS, etc are together in one S3 bucket for their own environment. Craft's image assets get optimized and cropped via Sharp.js and served out of Cloudfront.

Originally I was thinking of having a bucket for each environment, but then realized that if I sync staging's db from production, then those asset indexes are related to production's bucket. If I reindex staging's assets, Craft won't understand the assets in staging's bucket, and so images go missing on staging.

If I use one bucket for both staging and production, then that means deleting images on staging could remove images in use on production.

How are other people handling this? All other SE posts I found didn't seem to address this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.