prepare some things for preproduction

This commit is contained in:
Arthur Vuillard 2023-05-30 14:30:38 +02:00
parent 26f7c313fc
commit 92d254da20
3 changed files with 50 additions and 11 deletions

View file

@ -12,24 +12,26 @@ https://docs.djangoproject.com/en/4.1/ref/settings/
import os import os
from pathlib import Path from pathlib import Path
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
BASE_URL = "http://127.0.0.1:8000" # to be moved to settings/dev.py BASE_URL = os.getenv("BASE_URL", "http://127.0.0.1:8000")
BASE_URL = os.getenv("BASE_URL")
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-f66vu+dj79c(5u(w2i0indkrlf$qtt!b$dmotnm%5!0a*9+=my" SECRET_KEY = os.geteng("SECRET_KEY", "django-insecure-f66vu+dj79c(5u(w2i0indkrlf$qtt!b$dmotnm%5!0a*9+=my")
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = os.getenv(DEBUG, "True") == "True"
ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["localhost", "127.0.0.1"]
if os.getenv("ALLOWED_HOSTS"):
ALLOWED_HOSTS += os.getenv("ALLOWED_HOSTS").split(",")
# Application definition # Application definition
@ -145,3 +147,33 @@ MEDIA_ROOT = os.getenv("MEDIA_ROOT", BASE_DIR / "media")
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
# SENTRY settings
# For production logs
SENTRY_DSN = os.getenv("SENTRY_DSN")
if SENTRY_DSN:
sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=[DjangoIntegration()],
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production,
traces_sample_rate=1.0,
# If you wish to associate users to errors (assuming you are using
# django.contrib.auth) you may enable sending PII data.
send_default_pii=True,
environment=os.getenv("SENTRY_ENV", "production"),
)
# Email settings
EMAIL_BACKEND = os.getenv(
"EMAIL_BACKEND", "django.core.mail.backends.console.EmailBackend"
)
EMAIL_HOST = os.getenv("EMAIL_HOST")
EMAIL_PORT = int(os.getenv("EMAIL_PORT", "587"))
DEFAULT_FROM_EMAIL = os.getenv("DJANGO_DEFAULT_FROM_EMAIL")
DEFAULT_FROM_EMAIL_NAME = os.getenv("DJANGO_DEFAULT_FROM_EMAIL_NAME")
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
EMAIL_USE_TLS = os.getenv("EMAIL_USE_TLS", "True") == "True"

View file

@ -9,6 +9,7 @@ classifiers = ["License :: OSI Approved :: GNU General Public License v3 or late
dependencies = [ dependencies = [
"django>=4,<5", "django>=4,<5",
"psycopg2-binary>=2,<3", "psycopg2-binary>=2,<3",
"sentry-sdk<1",
] ]
[build-system] [build-system]

View file

@ -1,14 +1,20 @@
# #
# This file is autogenerated by pip-compile with Python 3.10 # This file is autogenerated by pip-compile with Python 3.11
# by the following command: # by the following command:
# #
# pip-compile # pip-compile
# #
asgiref==3.6.0 asgiref==3.7.2
# via django # via django
django==4.2 certifi==2023.5.7
# via sentry-sdk
django==4.2.1
# via la-chariotte (pyproject.toml) # via la-chariotte (pyproject.toml)
psycopg2-binary==2.9.6 psycopg2-binary==2.9.6
# via la-chariotte (pyproject.toml) # via la-chariotte (pyproject.toml)
sqlparse==0.4.3 sentry-sdk==0.20.3
# via la-chariotte (pyproject.toml)
sqlparse==0.4.4
# via django # via django
urllib3==2.0.2
# via sentry-sdk