From 1733fa00104a4b7e196cabc45a3490b39ccad04a Mon Sep 17 00:00:00 2001 From: Eunsoo Shin Date: Sun, 22 Sep 2024 18:27:57 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=B3=20new=20platform-dev=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ backend/Dockerfile.dev | 12 ++----- backend/Platform/settings/staging.py | 48 ++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 backend/Platform/settings/staging.py diff --git a/.gitignore b/.gitignore index 6e93e17..a65fba3 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ docker-compose.yml # Uploaded media files backend/accounts/mediafiles + +.env \ No newline at end of file diff --git a/backend/Dockerfile.dev b/backend/Dockerfile.dev index ae30a39..28abdfa 100644 --- a/backend/Dockerfile.dev +++ b/backend/Dockerfile.dev @@ -1,11 +1,7 @@ -FROM pennlabs/django-base:b269ea1613686b1ac6370154debbb741b012de1a-3.9.14 +FROM pennlabs/django-base:b269ea1613686b1ac6370154debbb741b012de1a-3.11 LABEL maintainer="Penn Labs" -# Update PGP key for NGINX -# https://blog.nginx.org/blog/updating-pgp-key-for-nginx-software -RUN wget -O/etc/apt/trusted.gpg.d/nginx.asc https://nginx.org/keys/nginx_signing.key - # Copy project dependencies COPY Pipfile* /app/ @@ -15,10 +11,8 @@ RUN pipenv install --system # Copy project files COPY . /app/ -ENV DJANGO_SETTINGS_MODULE Platform.settings.production +ENV DJANGO_SETTINGS_MODULE Platform.settings.staging ENV SECRET_KEY 'temporary key just to build the docker image' -ENV IDENTITY_RSA_PRIVATE_KEY 'temporary private key just to build the docker image' -ENV OIDC_RSA_PRIVATE_KEY 'temporary private key just to build the docker image' # Collect static files -RUN python3 /app/manage.py collectstatic --noinput +RUN python3 /app/manage.py collectstatic --noinput \ No newline at end of file diff --git a/backend/Platform/settings/staging.py b/backend/Platform/settings/staging.py new file mode 100644 index 0000000..ad34fa4 --- /dev/null +++ b/backend/Platform/settings/staging.py @@ -0,0 +1,48 @@ +import os + +import sentry_sdk +from django.core.exceptions import ImproperlyConfigured +from sentry_sdk.integrations.django import DjangoIntegration + +from Platform.settings.base import * # noqa +from Platform.settings.base import DOMAINS + + +DEBUG = False + +# Honour the 'X-Forwarded-Proto' header for request.is_secure() +SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") + +# Allow production host headers +ALLOWED_HOSTS = DOMAINS + +# SECRET_KEY = os.environ.get("SECRET_KEY", None) + +# IDENTITY_RSA_PRIVATE_KEY = os.environ.get("IDENTITY_RSA_PRIVATE_KEY", None) + +# OIDC_RSA_PRIVATE_KEY = os.environ.get("OIDC_RSA_PRIVATE_KEY", None) + +# Sentry settings +SENTRY_URL = os.environ.get("SENTRY_URL", "") +sentry_sdk.init(dsn=SENTRY_URL, integrations=[DjangoIntegration()]) + +# CORS settings +CORS_ALLOW_ALL_ORIGINS = True +CORS_ALLOW_METHODS = ["GET", "POST"] +CORS_URLS_REGEX = r"^(/options/)|(/accounts/token/)$" + +# Email client settings +EMAIL_HOST = os.getenv("SMTP_HOST") +EMAIL_PORT = int(os.getenv("SMTP_PORT", 587)) +EMAIL_HOST_USER = os.getenv("SMTP_USERNAME") +EMAIL_HOST_PASSWORD = os.getenv("SMTP_PASSWORD") +EMAIL_USE_TLS = True + +IS_DEV_LOGIN = os.environ.get("DEV_LOGIN", "False") in ["True", "TRUE", "true"] + +# AWS S3 +DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" +AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID") +AWS_ACCESS_SECRET_ID = os.getenv("AWS_SECRET_ACCESS_KEY") +AWS_STORAGE_BUCKET_NAME = os.getenv("AWS_STORAGE_BUCKET_NAME") +AWS_QUERYSTRING_AUTH = False