diff options
author | Andrew Godwin | 2022-12-16 19:51:19 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-12-16 19:51:19 -0700 |
commit | 4a28e1708e1cd6d9cbbfe41d94ff9d7f646f6c94 (patch) | |
tree | 88b387b98a437391c6362ff260452dc5994cefd9 | |
parent | 770f6728f60b50a8bed3f73e3b052f1a57f1262d (diff) | |
download | takahe-4a28e1708e1cd6d9cbbfe41d94ff9d7f646f6c94.tar.gz takahe-4a28e1708e1cd6d9cbbfe41d94ff9d7f646f6c94.tar.bz2 takahe-4a28e1708e1cd6d9cbbfe41d94ff9d7f646f6c94.zip |
Make the collectstatic hack slightly better
-rw-r--r-- | core/uris.py | 11 | ||||
-rw-r--r-- | docker/Dockerfile | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/core/uris.py b/core/uris.py index 81f53b6..b55514f 100644 --- a/core/uris.py +++ b/core/uris.py @@ -1,3 +1,4 @@ +import sys from urllib.parse import urljoin from django.conf import settings @@ -41,7 +42,15 @@ class StaticAbsoluteUrl(RelativeAbsoluteUrl): """ def __init__(self, path: str): - static_url = staticfiles_storage.url(path) + try: + static_url = staticfiles_storage.url(path) + except ValueError: + # Suppress static issues during the first collectstatic + # Yes, I know it's a big hack! Pull requests welcome :) + if "collectstatic" in sys.argv: + super().__init__("https://example.com/") + return + raise if "://" in static_url: super().__init__(static_url) else: diff --git a/docker/Dockerfile b/docker/Dockerfile index 13d25a3..a99c4f5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -32,7 +32,7 @@ COPY . /takahe WORKDIR /takahe -RUN TAKAHE_DATABASE_SERVER="postgres://x@example.com/x" TAKAHE_DEBUG=true python3 manage.py collectstatic --noinput +RUN TAKAHE_DATABASE_SERVER="postgres://x@example.com/x" python3 manage.py collectstatic --noinput EXPOSE 8000 |