Skip to content

Commit d7780ba

Browse files
authored
Upload staticfiles to S3 (#12220)
Django 4.2 deprecated the way that storages are handled and introduced `STORAGES` setting. Then Django 5.2 removed the old pattern and our staticfiles were broken after the upgrade. This commit makes a very simple usage of `STORAGES` to define the `staticfiles` storage so these files go to S3. Note that I'm not changing the underlying configuration of the other storages we use (build media, build tools, etc) for now; but we could upgrade our code to follow the new pattern if we want to. I tested this from `web-extra` and now the message is different: ``` docs@web-extra-i-0ef973eb0da33af39(org):~/checkouts/readthedocs.org$ django-admin collectstatic You have requested to collect static files at the destination location as specified in your settings. This will overwrite existing files! Are you sure you want to do this? Type 'yes' to continue, or 'no' to cancel: yes 329 static files copied. docs@web-extra-i-0ef973eb0da33af39(org):~/checkouts/readthedocs.org$ ``` Besides, I can see the ext-theme files in the static S3 bucket now. Closes #12211
1 parent 4add65f commit d7780ba

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

readthedocs/settings/base.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,15 @@ def GITHUB_APP_CLIENT_ID(self):
10301030
# Used by readthedocs.aws.security_token_service.
10311031
AWS_STS_ASSUME_ROLE_ARN = "arn:aws:iam::1234:role/SomeRole"
10321032

1033+
@property
1034+
def STORAGES(self):
1035+
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html
1036+
return {
1037+
"staticfiles": {
1038+
"BACKEND": self.RTD_STATICFILES_STORAGE,
1039+
},
1040+
}
1041+
10331042
@property
10341043
def USING_AWS(self):
10351044
"""Return True if we are using AWS as our storage/cloud provider."""

requirements/deploy.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ django-safemigrate==5.3
166166
# via -r requirements/pip.txt
167167
django-simple-history==3.8.0
168168
# via -r requirements/pip.txt
169-
django-storages[boto3]==1.14.6
169+
django-storages[s3]==1.14.6
170170
# via -r requirements/pip.txt
171171
django-structlog==2.2.0
172172
# via -r requirements/pip.txt

requirements/docker.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ django-safemigrate==5.3
174174
# via -r requirements/pip.txt
175175
django-simple-history==3.8.0
176176
# via -r requirements/pip.txt
177-
django-storages[boto3]==1.14.6
177+
django-storages[s3]==1.14.6
178178
# via -r requirements/pip.txt
179179
django-structlog==2.2.0
180180
# via -r requirements/pip.txt

requirements/pip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ django-cors-headers
116116
# User agent parsing - used for analytics purposes
117117
user-agents
118118

119-
django-storages[boto3]
119+
django-storages[s3]
120120

121121

122122
# Required only in development and linting

requirements/pip.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ django-safemigrate==5.3
129129
# via -r requirements/pip.in
130130
django-simple-history==3.8.0
131131
# via -r requirements/pip.in
132-
django-storages[boto3]==1.14.6
132+
django-storages[s3]==1.14.6
133133
# via -r requirements/pip.in
134134
django-structlog==2.2.0
135135
# via -r requirements/pip.in

requirements/testing.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ django-safemigrate==5.3
173173
# via -r requirements/pip.txt
174174
django-simple-history==3.8.0
175175
# via -r requirements/pip.txt
176-
django-storages[boto3]==1.14.6
176+
django-storages[s3]==1.14.6
177177
# via -r requirements/pip.txt
178178
django-structlog==2.2.0
179179
# via -r requirements/pip.txt

0 commit comments

Comments
 (0)