From 16618da1173d5c5c870e2ab2a77e7cb9d665c0fd Mon Sep 17 00:00:00 2001 From: Jake Merdich Date: Wed, 1 May 2024 00:37:18 -0400 Subject: [PATCH] Allow relocating media root When self hosting, I make backups of the data I cannot recreate-- a lesson I learned the hard way. Right now, all user files (eg. time lapses) are stored under the hardcoded path `/backend/static_build/media` which is intermingled with the source. I want to back up the user files and database, but not the source (it's easy to re-clone it and recreate the containers). The database can already be redirected to a different file with an environment variable for expert users. This trivial change adds a similar MEDIA_ROOT env var for expert users so that all uploaded files can go to a different place if desired. --- backend/config/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/config/settings.py b/backend/config/settings.py index af75e76da..ea1dca6d6 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -453,7 +453,7 @@ def get_bool(key, default): 'GOOGLE_APPLICATION_CREDENTIALS') MEDIA_URL = '/media/' -MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media') +MEDIA_ROOT = os.environ.get('MEDIA_ROOT', os.path.join(STATIC_ROOT, 'media')) INTERNAL_MEDIA_HOST = os.environ.get('INTERNAL_MEDIA_HOST') PICS_CONTAINER = os.environ.get('PICS_CONTAINER', 'tsd-pics')