chore: configuración de infraestructura y dependencias
- 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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user