Catch up to 0.6.0 (#217)

A few tweaks to catch my deployment on Fly.io and/or AWS up to 0.6.0. Mostly quality-of-life fixes
This commit is contained in:
Corry Haines 2022-12-22 12:47:13 -08:00 committed by GitHub
parent 3ebbb79bb5
commit 4657a1eece
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 2 deletions

View File

@ -2,7 +2,11 @@
*.sqlite3 *.sqlite3
.env .env
.git .git
.mypy_cache
.pre-commit-config.yaml .pre-commit-config.yaml
.venv .venv
fly.toml
media media
notes.md notes.md
venv
virtualenv

2
.gitignore vendored
View File

@ -3,6 +3,7 @@
*.psql *.psql
*.pyc *.pyc
*.sqlite3 *.sqlite3
.DS_Store
.idea/* .idea/*
.venv .venv
.vscode .vscode
@ -14,5 +15,6 @@
/static-collected /static-collected
__pycache__/ __pycache__/
api-test.* api-test.*
fly.toml
notes.md notes.md
notes.py notes.py

View File

@ -176,7 +176,7 @@ To use a local directory, specify the media URL as ``local://``.
You must then also specify: You must then also specify:
* ``TAKAHE_MEDIA_ROOT``, the file path to the local media Directory * ``TAKAHE_MEDIA_ROOT``, the file path to the local media Directory
* ``TAKAHE_MEDIA_URL``, a fully-qualified URL prefix that serves that directory * ``TAKAHE_MEDIA_URL``, a fully-qualified URL prefix that serves that directory (must end in a slash)
The media directory must be read-write accessible from every single container The media directory must be read-write accessible from every single container
of Takahē - webserver and workers alike. of Takahē - webserver and workers alike.

View File

@ -102,6 +102,10 @@ class Settings(BaseSettings):
MEDIA_ROOT: str = str(BASE_DIR / "media") MEDIA_ROOT: str = str(BASE_DIR / "media")
MEDIA_BACKEND: MediaBackendUrl | None = None MEDIA_BACKEND: MediaBackendUrl | None = None
#: S3 ACL to apply to all media objects when MEDIA_BACKEND is set to S3. If using a CDN
#: and/or have public access blocked to buckets this will likely need to be 'private'
MEDIA_BACKEND_S3_ACL: str = "public-read"
#: Maximum filesize when uploading images. Increasing this may increase memory utilization #: Maximum filesize when uploading images. Increasing this may increase memory utilization
#: because all images with a dimension greater than 2000px are resized to meet that limit, which #: because all images with a dimension greater than 2000px are resized to meet that limit, which
#: is necessary for compatibility with Mastodons image proxy. #: is necessary for compatibility with Mastodons image proxy.
@ -370,7 +374,7 @@ if SETUP.MEDIA_BACKEND:
DEFAULT_FILE_STORAGE = "core.uploads.TakaheS3Storage" DEFAULT_FILE_STORAGE = "core.uploads.TakaheS3Storage"
AWS_STORAGE_BUCKET_NAME = parsed.path.lstrip("/") AWS_STORAGE_BUCKET_NAME = parsed.path.lstrip("/")
AWS_QUERYSTRING_AUTH = False AWS_QUERYSTRING_AUTH = False
AWS_DEFAULT_ACL = "public-read" AWS_DEFAULT_ACL = SETUP.MEDIA_BACKEND_S3_ACL
if parsed.username is not None: if parsed.username is not None:
AWS_ACCESS_KEY_ID = parsed.username AWS_ACCESS_KEY_ID = parsed.username
AWS_SECRET_ACCESS_KEY = urllib.parse.unquote(parsed.password) AWS_SECRET_ACCESS_KEY = urllib.parse.unquote(parsed.password)