From 558fd6c862d552d554d929f4b37c43d12553caf4 Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Thu, 25 Jul 2024 16:21:45 +0200 Subject: [PATCH] try to add config for s3 --- config/settings/base.py | 1 - config/settings/dev.py | 3 +++ config/settings/staging.py | 22 +++++++++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/config/settings/base.py b/config/settings/base.py index 68137739b..551902475 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -64,7 +64,6 @@ "compressor.finders.CompressorFinder", ] -STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" STATICFILES_FINDERS += ["compressor.finders.CompressorFinder"] diff --git a/config/settings/dev.py b/config/settings/dev.py index ecd539a61..4cad3cb26 100644 --- a/config/settings/dev.py +++ b/config/settings/dev.py @@ -22,6 +22,7 @@ # For Docker env (and debug toolbar in particular) import socket + _, _, ips = socket.gethostbyname_ex(socket.gethostname()) INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + ["127.0.0.1"] @@ -90,3 +91,5 @@ "results": True, "store_none": True, } # Huey implementation to use. + +STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" diff --git a/config/settings/staging.py b/config/settings/staging.py index 6e905d009..8f531be86 100644 --- a/config/settings/staging.py +++ b/config/settings/staging.py @@ -7,6 +7,26 @@ env = environ.Env() +STORAGES = { + "default": { + "BACKEND": "storages.backends.s3.S3Storage", + # "BACKEND": "lemarche.utils.s3boto.S3BotoStorage", + "OPTIONS": { + "bucket_name": S3_STORAGE_BUCKET_NAME, # noqa + "access_key": S3_STORAGE_ACCESS_KEY_ID, # noqa + "secret_key": S3_STORAGE_SECRET_ACCESS_KEY, # noqa + "endpoint_url": f"https://{S3_STORAGE_ENDPOINT_DOMAIN}", # noqa + "region_name": S3_STORAGE_BUCKET_REGION, # noqa + "file_overwrite": False, + "location": env.str("S3_LOCATION", ""), + }, + }, + "staticfiles": { + "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", + }, +} + + ALLOWED_HOSTS = [ "127.0.0.1", "staging.inclusion.beta.gouv.fr", @@ -24,7 +44,7 @@ SECURE_SSL_REDIRECT = env.bool("SECURE_SSL_REDIRECT", True) MEDIA_URL = f"https://{S3_STORAGE_ENDPOINT_DOMAIN}/" # noqa -DEFAULT_FILE_STORAGE = "lemarche.utils.s3boto.S3BotoStorage" +# DEFAULT_FILE_STORAGE = "lemarche.utils.s3boto.S3BotoStorage" # Sentry