From 27b68a9ac28344bd422461e70116a2ce9f39645c Mon Sep 17 00:00:00 2001 From: aserrador Date: Mon, 22 Jun 2026 11:35:47 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20configuraci=C3=B3n=20de=20infraestruct?= =?UTF-8?q?ura=20y=20dependencias?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - docker-compose.staging.yml: env vars a env_file, limpia defaults duplicados - docker-compose.prod.yml: descomenta y activa servicio nginx - staging.py: DEBUG=True, POSTGRES_* env vars, logging DEBUG - pyproject.toml + poetry.lock: agrega pillow y whitenoise --- docker-compose.staging.yml | 9 +------ tienda_ilusion/config/settings/staging.py | 29 ++++++++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml index e8d64c5..70d382e 100644 --- a/docker-compose.staging.yml +++ b/docker-compose.staging.yml @@ -2,16 +2,12 @@ services: postgres: image: postgres:15-alpine container_name: tienda_ilusion_postgres_staging - environment: - - POSTGRES_USER=${DB_USER:-tienda_ilusion_user} - - POSTGRES_DB=${DB_NAME:-tienda_ilusion_staging} - - POSTGRES_PASSWORD=${DB_PASSWORD:-staging_local_password} env_file: - .env.staging volumes: - postgres_staging_data:/var/lib/postgresql/data ports: - - "5433:5432" # Puerto diferente para no conflictuar con prod + - "5433:5432" networks: - tienda_staging_network restart: unless-stopped @@ -35,9 +31,6 @@ services: environment: - DJANGO_ENV=staging - DB_HOST=postgres - - DB_USER=${DB_USER:-tienda_ilusion_user} - - DB_NAME=${DB_NAME:-tienda_ilusion_staging} - - DB_PASSWORD=${DB_PASSWORD:-staging_local_password} volumes: - ./tienda_ilusion:/app/ - static_staging_volume:/app/staticfiles diff --git a/tienda_ilusion/config/settings/staging.py b/tienda_ilusion/config/settings/staging.py index 651efb1..f475319 100644 --- a/tienda_ilusion/config/settings/staging.py +++ b/tienda_ilusion/config/settings/staging.py @@ -12,7 +12,7 @@ import os from .base import * # SECURITY WARNING: DEBUG is False to simulate production behavior -DEBUG = False +DEBUG = True # SECRET_KEY for staging (use a fixed key for local staging, not for real production) SECRET_KEY = os.environ.get( @@ -21,9 +21,9 @@ SECRET_KEY = os.environ.get( ) # Allow localhost for staging -ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "localhost,127.0.0.1,0.0.0.0").split( - "," -) +ALLOWED_HOSTS = os.environ.get( + "ALLOWED_HOSTS", "localhost,127.0.0.1,0.0.0.0" +).split(",") # CORS settings for staging - permissive for localhost testing CORS_ALLOWED_ORIGINS = os.environ.get( @@ -52,9 +52,11 @@ CORS_EXPOSE_HEADERS = ["Content-Type", "X-CSRFToken"] DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", - "NAME": os.environ.get("DB_NAME", "tienda_ilusion_staging"), - "USER": os.environ.get("DB_USER", "tienda_ilusion_user"), - "PASSWORD": os.environ.get("DB_PASSWORD", "staging_local_password"), + "NAME": os.environ.get("POSTGRES_DB", "tienda_ilusion_staging"), + "USER": os.environ.get("POSTGRES_USER", "tienda_ilusion_user"), + "PASSWORD": os.environ.get( + "POSTGRES_PASSWORD", "staging_local_password" + ), "HOST": os.environ.get("DB_HOST", "localhost"), "PORT": os.environ.get("DB_PORT", "5432"), "CONN_MAX_AGE": 600, # Persistent connections @@ -117,7 +119,9 @@ WHITENOISE_AUTOREFRESH = ( ) WHITENOISE_USE_FINDERS = False # Use collected static files only WHITENOISE_MANIFEST_STRICT = False # More permissive in staging -WHITENOISE_MAX_AGE = 600 # 10 minutes cache for staging (allows easier testing) +WHITENOISE_MAX_AGE = ( + 600 # 10 minutes cache for staging (allows easier testing) +) # Staging logging - similar to production but more verbose LOGGING = { @@ -148,7 +152,7 @@ LOGGING = { }, "root": { "handlers": ["console", "file"], - "level": "INFO", + "level": "DEBUG", }, "loggers": { "django": { @@ -163,7 +167,7 @@ LOGGING = { }, "django.db.backends": { "handlers": ["console"], - "level": "INFO", # Show SQL queries in staging for debugging + "level": "DEBUG", # Show SQL queries in staging for debugging "propagate": False, }, }, @@ -177,7 +181,10 @@ pathlib.Path(logs_dir).mkdir(parents=True, exist_ok=True) # Admin email notifications ADMINS = [ - ("Staging Admin", os.environ.get("ADMIN_EMAIL", "admin@tiendailusion.local")), + ( + "Staging Admin", + os.environ.get("ADMIN_EMAIL", "admin@tiendailusion.local"), + ), ] MANAGERS = ADMINS