From 271bc7c662ab59f562be01470e9b4fafed107a90 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Mon, 27 May 2024 20:56:03 +0100 Subject: Removes most celery, storages and sentry config Comments out in the settings files. Leaves a couple of imports of celery, but we're not removing the requirements on celery so should be fine, it will be installed. Comments out storages and sentry code. Leaves it all in Dockerfile and compose, but this change is aimed at getting Django running WITHOUT docker and compose. --- config/settings/production.py | 130 ++++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 68 deletions(-) (limited to 'config/settings/production.py') diff --git a/config/settings/production.py b/config/settings/production.py index a44c994..63afa6d 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -1,11 +1,5 @@ # ruff: noqa: E501 -import logging -import sentry_sdk -from sentry_sdk.integrations.celery import CeleryIntegration -from sentry_sdk.integrations.django import DjangoIntegration -from sentry_sdk.integrations.logging import LoggingIntegration -from sentry_sdk.integrations.redis import RedisIntegration from .base import * # noqa: F403 from .base import DATABASES @@ -65,47 +59,47 @@ SECURE_CONTENT_TYPE_NOSNIFF = env.bool( default=True, ) -# 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") -# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings -AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY") -# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings -AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_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" -# STATIC & MEDIA -# ------------------------ -STORAGES = { - "default": { - "BACKEND": "django.core.files.storage.FileSystemStorage", - }, - "staticfiles": { - "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", - }, -} -MEDIA_URL = f"https://{aws_s3_domain}/media/" -COLLECTFAST_STRATEGY = "collectfast.strategies.boto3.Boto3Strategy" -STATIC_URL = f"https://{aws_s3_domain}/static/" +# # 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") +# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings +# AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY") +# # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings +# AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_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" +# # STATIC & MEDIA +# # ------------------------ +# STORAGES = { +# "default": { +# "BACKEND": "django.core.files.storage.FileSystemStorage", +# }, +# "staticfiles": { +# "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", +# }, +# } +# MEDIA_URL = f"https://{aws_s3_domain}/media/" +# COLLECTFAST_STRATEGY = "collectfast.strategies.boto3.Boto3Strategy" +# STATIC_URL = f"https://{aws_s3_domain}/static/" # EMAIL # ------------------------------------------------------------------------------ @@ -180,27 +174,27 @@ LOGGING = { }, } -# Sentry -# ------------------------------------------------------------------------------ -SENTRY_DSN = env("SENTRY_DSN") -SENTRY_LOG_LEVEL = env.int("DJANGO_SENTRY_LOG_LEVEL", logging.INFO) - -sentry_logging = LoggingIntegration( - level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs - event_level=logging.ERROR, # Send errors as events -) -integrations = [ - sentry_logging, - DjangoIntegration(), - CeleryIntegration(), - RedisIntegration(), -] -sentry_sdk.init( - dsn=SENTRY_DSN, - integrations=integrations, - environment=env("SENTRY_ENVIRONMENT", default="production"), - traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=0.0), -) +# # Sentry +# # ------------------------------------------------------------------------------ +# SENTRY_DSN = env("SENTRY_DSN") +# SENTRY_LOG_LEVEL = env.int("DJANGO_SENTRY_LOG_LEVEL", logging.INFO) + +# sentry_logging = LoggingIntegration( +# level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs +# event_level=logging.ERROR, # Send errors as events +# ) +# integrations = [ +# sentry_logging, +# DjangoIntegration(), +# CeleryIntegration(), +# RedisIntegration(), +# ] +# sentry_sdk.init( +# dsn=SENTRY_DSN, +# integrations=integrations, +# environment=env("SENTRY_ENVIRONMENT", default="production"), +# traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=0.0), +# ) # Your stuff... -- cgit v1.2.3