From 2037c6b87564772c7ac3f3ece3e4b2df5bc44cdc Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 28 May 2024 15:15:44 +0100 Subject: Should be a buildable Django container --- config/settings/base.py | 60 ++++++++++++++++++------------------- config/settings/local-bak.py | 69 ++++++++++++++++++++++++++++++++++++++++++ config/settings/local.py | 70 ------------------------------------------- config/settings/production.py | 15 +++++----- 4 files changed, 106 insertions(+), 108 deletions(-) create mode 100644 config/settings/local-bak.py delete mode 100644 config/settings/local.py (limited to 'config') diff --git a/config/settings/base.py b/config/settings/base.py index 9414953..09a748f 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -317,36 +317,36 @@ SOCIALACCOUNT_FORMS = {"signup": "pyblackbird_cc.users.forms.UserSocialSignupFor # STORAGES # ------------------------------------------------------------------------------ -# # https://django-storages.readthedocs.io/en/latest/#installation -# INSTALLED_APPS += ["storages"] -# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings -# # AWS_ACCESS_KEY_ID = env("DJANGO_AWS_ACCESS_KEY_ID") -# AWS_ACCESS_KEY_ID = env("SPACES_KEY") -# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings -# # AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY") -# AWS_SECRET_ACCESS_KEY = env("SPACES_SECRET") -# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings -# # AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME") -# AWS_STORAGE_BUCKET_NAME = env("SPACES_BUCKET_NAME") -# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings -# AWS_QUERYSTRING_AUTH = False -# # DO NOT change these unless you know what you're doing. -# _AWS_EXPIRY = 60 * 60 * 24 * 7 -# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings -# AWS_S3_OBJECT_PARAMETERS = { -# "CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate", -# } -# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings -# AWS_S3_MAX_MEMORY_SIZE = env.int( -# "DJANGO_AWS_S3_MAX_MEMORY_SIZE", -# default=100_000_000, # 100MB -# ) -# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings -# AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None) -# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#cloudfront -# AWS_S3_CUSTOM_DOMAIN = env("DJANGO_AWS_S3_CUSTOM_DOMAIN", default=None) -# aws_s3_domain = AWS_S3_CUSTOM_DOMAIN or f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com" -# AWS_S3_ENDPOINT_URL = env("SPACES_ENDPOINT_URL") +# https://django-storages.readthedocs.io/en/latest/#installation +INSTALLED_APPS += ["storages"] +# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings +# AWS_ACCESS_KEY_ID = env("DJANGO_AWS_ACCESS_KEY_ID") +AWS_ACCESS_KEY_ID = env("SPACES_KEY") +# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings +# AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY") +AWS_SECRET_ACCESS_KEY = env("SPACES_SECRET") +# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings +# AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME") +AWS_STORAGE_BUCKET_NAME = env("SPACES_BUCKET_NAME") +# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings +AWS_QUERYSTRING_AUTH = False +# DO NOT change these unless you know what you're doing. +_AWS_EXPIRY = 60 * 60 * 24 * 7 +# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings +AWS_S3_OBJECT_PARAMETERS = { + "CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate", +} +# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings +AWS_S3_MAX_MEMORY_SIZE = env.int( + "DJANGO_AWS_S3_MAX_MEMORY_SIZE", + default=100_000_000, # 100MB +) +# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings +AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None) +# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#cloudfront +AWS_S3_CUSTOM_DOMAIN = env("DJANGO_AWS_S3_CUSTOM_DOMAIN", default=None) +aws_s3_domain = AWS_S3_CUSTOM_DOMAIN or f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com" +AWS_S3_ENDPOINT_URL = env("STATIC_ENDPOINT_URL") # Your stuff... # ------------------------------------------------------------------------------ diff --git a/config/settings/local-bak.py b/config/settings/local-bak.py new file mode 100644 index 0000000..afcdb3f --- /dev/null +++ b/config/settings/local-bak.py @@ -0,0 +1,69 @@ +# ruff: noqa: E501 +from .base import * # noqa: F403 +from .base import env + +# GENERAL +# ------------------------------------------------------------------------------ +# https://docs.djangoproject.com/en/dev/ref/settings/#debug +DEBUG = True +# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key +SECRET_KEY = env( + "DJANGO_SECRET_KEY", + default="4MZuqVXy7rToppiUhiTBxzlQH8OxPDDmu4rsTqFiyAyLF50WPBVzX5ZFBLpwJPyY", +) +# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts +ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"] # noqa: S104 + +# CACHES +# ------------------------------------------------------------------------------ +# https://docs.djangoproject.com/en/dev/ref/settings/#caches +CACHES = { + "default": { + "BACKEND": "django.core.cache.backends.locmem.LocMemCache", + "LOCATION": "", + }, +} + +# EMAIL +# ------------------------------------------------------------------------------ +# https://docs.djangoproject.com/en/dev/ref/settings/#email-host +EMAIL_HOST = env("EMAIL_HOST", default="mailpit") +# https://docs.djangoproject.com/en/dev/ref/settings/#email-port +EMAIL_PORT = 1025 + +# WhiteNoise +# ------------------------------------------------------------------------------ +# http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development +#INSTALLED_APPS = ["whitenoise.runserver_nostatic", *INSTALLED_APPS] + + +# django-debug-toolbar +# ------------------------------------------------------------------------------ +# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#prerequisites +#INSTALLED_APPS += ["debug_toolbar"] +# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#middleware +#MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"] +# https://django-debug-toolbar.readthedocs.io/en/latest/configuration.html#debug-toolbar-config +# DEBUG_TOOLBAR_CONFIG = { +# # "DISABLE_PANELS": ["debug_toolbar.panels.redirects.RedirectsPanel"], +# "SHOW_TEMPLATE_CONTEXT": True, +# } +# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips +INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"] +if env("USE_DOCKER") == "yes": + import socket + + hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) + INTERNAL_IPS += [".".join(ip.split(".")[:-1] + ["1"]) for ip in ips] + +# django-extensions +# ------------------------------------------------------------------------------ +# https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration +# INSTALLED_APPS += ["django_extensions"] +# Celery +# ------------------------------------------------------------------------------ + +# https://docs.celeryq.dev/en/stable/userguide/configuration.html#task-eager-propagates +CELERY_TASK_EAGER_PROPAGATES = True +# Your stuff... +# ------------------------------------------------------------------------------ diff --git a/config/settings/local.py b/config/settings/local.py deleted file mode 100644 index 8abae6f..0000000 --- a/config/settings/local.py +++ /dev/null @@ -1,70 +0,0 @@ -# ruff: noqa: E501 -from .base import * # noqa: F403 -from .base import INSTALLED_APPS -from .base import env - -# GENERAL -# ------------------------------------------------------------------------------ -# https://docs.djangoproject.com/en/dev/ref/settings/#debug -DEBUG = True -# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key -SECRET_KEY = env( - "DJANGO_SECRET_KEY", - default="4MZuqVXy7rToppiUhiTBxzlQH8OxPDDmu4rsTqFiyAyLF50WPBVzX5ZFBLpwJPyY", -) -# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts -ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"] # noqa: S104 - -# CACHES -# ------------------------------------------------------------------------------ -# https://docs.djangoproject.com/en/dev/ref/settings/#caches -CACHES = { - "default": { - "BACKEND": "django.core.cache.backends.locmem.LocMemCache", - "LOCATION": "", - }, -} - -# EMAIL -# ------------------------------------------------------------------------------ -# https://docs.djangoproject.com/en/dev/ref/settings/#email-host -EMAIL_HOST = env("EMAIL_HOST", default="mailpit") -# https://docs.djangoproject.com/en/dev/ref/settings/#email-port -EMAIL_PORT = 1025 - -# WhiteNoise -# ------------------------------------------------------------------------------ -# http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development -#INSTALLED_APPS = ["whitenoise.runserver_nostatic", *INSTALLED_APPS] - - -# django-debug-toolbar -# ------------------------------------------------------------------------------ -# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#prerequisites -#INSTALLED_APPS += ["debug_toolbar"] -# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#middleware -#MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"] -# https://django-debug-toolbar.readthedocs.io/en/latest/configuration.html#debug-toolbar-config -# DEBUG_TOOLBAR_CONFIG = { -# # "DISABLE_PANELS": ["debug_toolbar.panels.redirects.RedirectsPanel"], -# "SHOW_TEMPLATE_CONTEXT": True, -# } -# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips -INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"] -if env("USE_DOCKER") == "yes": - import socket - - hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) - INTERNAL_IPS += [".".join(ip.split(".")[:-1] + ["1"]) for ip in ips] - -# django-extensions -# ------------------------------------------------------------------------------ -# https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration -# INSTALLED_APPS += ["django_extensions"] -# Celery -# ------------------------------------------------------------------------------ - -# https://docs.celeryq.dev/en/stable/userguide/configuration.html#task-eager-propagates -CELERY_TASK_EAGER_PROPAGATES = True -# Your stuff... -# ------------------------------------------------------------------------------ diff --git a/config/settings/production.py b/config/settings/production.py index 63afa6d..1c04152 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -3,7 +3,6 @@ from .base import * # noqa: F403 from .base import DATABASES -from .base import INSTALLED_APPS from .base import env # GENERAL @@ -124,16 +123,16 @@ ADMIN_URL = env("DJANGO_ADMIN_URL") # Anymail # ------------------------------------------------------------------------------ # https://anymail.readthedocs.io/en/stable/installation/#installing-anymail -INSTALLED_APPS += ["anymail"] +#INSTALLED_APPS += ["anymail"] # https://docs.djangoproject.com/en/dev/ref/settings/#email-backend # https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference # https://anymail.readthedocs.io/en/stable/esps/mailgun/ -EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend" -ANYMAIL = { - "MAILGUN_API_KEY": env("MAILGUN_API_KEY"), - "MAILGUN_SENDER_DOMAIN": env("MAILGUN_DOMAIN"), - "MAILGUN_API_URL": env("MAILGUN_API_URL", default="https://api.mailgun.net/v3"), -} +# EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend" +# ANYMAIL = { +# "MAILGUN_API_KEY": env("MAILGUN_API_KEY"), +# "MAILGUN_SENDER_DOMAIN": env("MAILGUN_DOMAIN"), +# "MAILGUN_API_URL": env("MAILGUN_API_URL", default="https://api.mailgun.net/v3"), +#} # LOGGING -- cgit v1.2.3