mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 08:56:52 +00:00
Feature/ssl integration (#1)
* feat: update E2E testing configuration to use ssl * fix: add IPv6 loopback support to mkcert generation command in CI workflow * feat: centralize SSL certificate generation into a reusable workflow job * fix: use static ip in mkcert command * fix: correct mkcert command args * feat: implement certificate caching in CI workflow to persist SSL files across jobs * refactor: optimize CI workflow caching * ci: implement certificate caching in workflow * fix: correct certificate caching keys and fix environment file paths in CI workflows * fix: correct environment file paths and parallelize frontend dependency installation in CI workflow * test: set TZ environment variable to Asia/Kolkata in vitest configuration * fix: force en-US locale in Intl formatters to ensure consistent date and time output * fix: update MAILPIT_API_URL protocol from https to http in e2e environment example * chore: set test timezone to Asia/Kolkata * ci: add sll support and enhance e2e workflow * ci: improve compatibility for docker-compose execution * refactor: improve container orchestration detection and fallback logic in e2e test script * feat: add container runtime validation and force docker usage in CI environment * feat: add caching for Playwright dependencies in CI workflow * chore: update restart policy to unless-stopped for postgres and mailpit services in e2e docker-compose --------- Co-authored-by: ramvignesh-b <ramvignesh-b@github.com>
This commit is contained in:
+14
-11
@@ -19,12 +19,17 @@ import environ
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
# Load environment variables
|
||||
# Load dotenv files
|
||||
env = environ.Env()
|
||||
# Allow overriding the .env file path (useful for E2E testing/CI)
|
||||
env_file = os.environ.get("PIKU_ENV_FILE", os.path.join(BASE_DIR.parent, ".env"))
|
||||
env_file = os.path.join(BASE_DIR.parent, ".env")
|
||||
if os.path.exists(env_file):
|
||||
environ.Env.read_env(env_file)
|
||||
environ.Env.read_env(env_file, overwrite=False)
|
||||
|
||||
|
||||
SSL_ENABLED = env("SSL_ENABLED") == "true"
|
||||
FRONTEND_URL = f"https://{env('FRONTEND_DOMAIN')}" if SSL_ENABLED else f"http://{env('FRONTEND_DOMAIN')}"
|
||||
if env("FRONTEND_PORT"):
|
||||
FRONTEND_URL += f":{env('FRONTEND_PORT')}"
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
|
||||
@@ -35,7 +40,7 @@ SECRET_KEY = env("SECRET_KEY")
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = env("DEBUG")
|
||||
|
||||
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS") or []
|
||||
ALLOWED_HOSTS = [env("FRONTEND_DOMAIN")]
|
||||
|
||||
|
||||
# Application definition
|
||||
@@ -45,10 +50,12 @@ INSTALLED_APPS = [
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.staticfiles",
|
||||
"django_extensions",
|
||||
"rest_framework",
|
||||
"corsheaders",
|
||||
"users",
|
||||
"letters",
|
||||
"scripts",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@@ -81,7 +88,7 @@ DATABASES = {
|
||||
}
|
||||
}
|
||||
|
||||
CORS_ALLOWED_ORIGINS = env.list("CORS_ALLOWED_ORIGINS")
|
||||
CORS_ALLOWED_ORIGINS = [FRONTEND_URL]
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
|
||||
AUTH_USER_MODEL = "users.User"
|
||||
@@ -106,7 +113,7 @@ NOTE: COOKIE_SAMESITE: Lax is used to allow cross-site redirection, like links
|
||||
AUTH_COOKIE = {
|
||||
"NAME": "refresh_token",
|
||||
"DOMAIN": None,
|
||||
"SECURE": not DEBUG,
|
||||
"SECURE": SSL_ENABLED,
|
||||
"HTTPONLY": True,
|
||||
"SAMESITE": "Lax",
|
||||
}
|
||||
@@ -116,12 +123,8 @@ EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
|
||||
EMAIL_HOST = env("EMAIL_HOST")
|
||||
EMAIL_PORT = env("EMAIL_PORT")
|
||||
EMAIL_USE_TLS = not DEBUG
|
||||
EMAIL_HOST_USER = env("EMAIL_HOST_USER")
|
||||
EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD")
|
||||
FROM_EMAIL = env("FROM_EMAIL")
|
||||
|
||||
FRONTEND_URL = env("FRONTEND_URL")
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators
|
||||
|
||||
Reference in New Issue
Block a user