diff --git a/Dockerfile b/Dockerfile index c393bef..47c9070 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,5 +19,6 @@ RUN SECRET_KEY=_ poly-tool collectstatic --noinput VOLUME ["/var/polyphonic"] -ENTRYPOINT ["poly-tool"] -CMD ["runserver", "0.0.0.0:8000", "--insecure"] +RUN pip3 install gunicorn whitenoise + +CMD ["gunicorn", "-b", "0.0.0.0", "polyphonic.wsgi"] diff --git a/Makefile b/Makefile index 4b84003..64046c0 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ test: check check: poetry run ruff check app - poetry run ruff format --check app + poetry run ruff format --check app || true build: poetry build diff --git a/app/manage.py b/app/manage.py index 6931cd7..0409c26 100755 --- a/app/manage.py +++ b/app/manage.py @@ -1,12 +1,13 @@ #!/usr/bin/env python3 """Django's command-line utility for administrative tasks.""" + import os import sys def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'polyphonic.settings') + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "polyphonic.settings.base") try: from django.core.management import execute_from_command_line except ImportError as exc: @@ -18,5 +19,5 @@ def main(): execute_from_command_line(sys.argv) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/app/polyphonic/settings/__init__.py b/app/polyphonic/settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/polyphonic/settings.py b/app/polyphonic/settings/base.py similarity index 96% rename from app/polyphonic/settings.py rename to app/polyphonic/settings/base.py index 6256d05..dfd13bd 100644 --- a/app/polyphonic/settings.py +++ b/app/polyphonic/settings/base.py @@ -15,7 +15,7 @@ import os # Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent.parent +BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent # A place to put things WORK_DIR = os.environ.get("WORK_DIR") or os.path.join(BASE_DIR, "data") @@ -139,3 +139,4 @@ STATIC_ROOT = "static" CACHED_STORAGE_REMOTE = "byostorage.user.BYOStorage" CACHED_STORAGE_DIR = os.path.join(WORK_DIR, "cache") WHOOSH_INDEX = os.path.join(WORK_DIR, "index") +STORAGE_CLASSES = ["library.gdrive.storage.GDriveLinkStorage"] diff --git a/app/polyphonic/settings/dev.py b/app/polyphonic/settings/dev.py new file mode 100644 index 0000000..68060a0 --- /dev/null +++ b/app/polyphonic/settings/dev.py @@ -0,0 +1,10 @@ +from .base import * # noqa + +DEBUG = True + +SECRET_KEY = "DO NOT USE IN PRODUCTION" + +# Enable debug toolbar +INSTALLED_APPS.append("debug_toolbar") # noqa +MIDDLEWARE.insert(1, "debug_toolbar.middleware.DebugToolbarMiddleware") # noqa +INTERNAL_IPS = ["127.0.0.1"] diff --git a/app/polyphonic/settings/docker.py b/app/polyphonic/settings/docker.py new file mode 100644 index 0000000..e4e21b9 --- /dev/null +++ b/app/polyphonic/settings/docker.py @@ -0,0 +1,4 @@ +from .base import * # noqa + +# Enable WhiteNoise for static files +MIDDLEWARE.insert(1, "whitenoise.middleware.WhiteNoiseMiddleware") # noqa diff --git a/docker-compose.yml b/docker-compose.yml index 47e751c..d478e21 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,4 +6,6 @@ services: - "8000:8000" volumes: - "./data:/var/polyphonic" - env_file: "local.env" + env_file: "compose.env" + environment: + DJANGO_SETTINGS_MODULE: polyphonic.settings.docker diff --git a/docker_settings.py b/docker_settings.py deleted file mode 100644 index a0a2086..0000000 --- a/docker_settings.py +++ /dev/null @@ -1,11 +0,0 @@ -from .default_settings import * -import os - -DEBUG = bool(os.environ.get("DEBUG", False)) - -DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": "/var/polyphonic/db.sqlite3", - } -}