Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add STATICFILES_STORAGE with compressor support #2745

Merged
merged 4 commits into from
Aug 14, 2020

Conversation

Andrew-Chen-Wang
Copy link
Contributor

@Andrew-Chen-Wang Andrew-Chen-Wang commented Aug 13, 2020

Fixes #2739

Description

COMPRESSOR_STORAGE should be set to STATICFILES_STORAGE if not using whitenoise and using something like AWS S3.

Rationale

Compressor cache is stored in the AWS bucket in a separate file structure. For example, without this PR, the files would not have an ACL of public-read:

- CACHE
- static
- media

With this PR:

- static
    - CACHE
- media

The static files storage is set to S3, but the utils (in cookiecutter.project_slug.utils.storages) are set up only for the original collectstatic command, not for compressor support. Thus, compressor would store stuff inside its own directory that did not have public-read.

Use case(s) / visualization(s)

Allow compressor directory of CACHE to be publicly viewable in storage buckets.

Django compressor also recommends the `COMPRESS_ROOT` be the STATIC_ROOT. This also makes sure the utils is set up properly so that the CACHE directory is actually publicly available (it'll be inside the static directory as a subdirectory).
@Andrew-Chen-Wang
Copy link
Contributor Author

You can view this implementation at https://github.com/Donate-Anything/Donate-Anything and view the current website at https://donate-anything.org/. Posting this comment to double check that the files are actually publicly available and the listed project structure from the initial comment is correct.

(I keep getting some favicon.ico error when accessing the admin. I will file a new issue for that, too, although it doesn't happen... often to say the least. I'm not entirely sure why this happens since Sentry doesn't pick up on it but my email logging does).

* This is in addition to the PR for compressor support with AWS S3 and Google Cloud buckets
Copy link
Member

@browniebroke browniebroke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @Andrew-Chen-Wang, this is a nice one to fix!

@browniebroke browniebroke merged commit e532fb3 into cookiecutter:master Aug 14, 2020
@Andrew-Chen-Wang Andrew-Chen-Wang deleted the patch-3 branch August 14, 2020 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compressor CACHE not publicly available on S3
2 participants