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:
|
postgres:
|
||||||
image: postgres:15-alpine
|
image: postgres:15-alpine
|
||||||
container_name: tienda_ilusion_postgres_staging
|
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_file:
|
||||||
- .env.staging
|
- .env.staging
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_staging_data:/var/lib/postgresql/data
|
- postgres_staging_data:/var/lib/postgresql/data
|
||||||
ports:
|
ports:
|
||||||
- "5433:5432" # Puerto diferente para no conflictuar con prod
|
- "5433:5432"
|
||||||
networks:
|
networks:
|
||||||
- tienda_staging_network
|
- tienda_staging_network
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -35,9 +31,6 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- DJANGO_ENV=staging
|
- DJANGO_ENV=staging
|
||||||
- DB_HOST=postgres
|
- 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:
|
volumes:
|
||||||
- ./tienda_ilusion:/app/
|
- ./tienda_ilusion:/app/
|
||||||
- static_staging_volume:/app/staticfiles
|
- static_staging_volume:/app/staticfiles
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import os
|
|||||||
from .base import *
|
from .base import *
|
||||||
|
|
||||||
# SECURITY WARNING: DEBUG is False to simulate production behavior
|
# 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 for staging (use a fixed key for local staging, not for real production)
|
||||||
SECRET_KEY = os.environ.get(
|
SECRET_KEY = os.environ.get(
|
||||||
@@ -21,9 +21,9 @@ SECRET_KEY = os.environ.get(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Allow localhost for staging
|
# 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 settings for staging - permissive for localhost testing
|
||||||
CORS_ALLOWED_ORIGINS = os.environ.get(
|
CORS_ALLOWED_ORIGINS = os.environ.get(
|
||||||
@@ -52,9 +52,11 @@ CORS_EXPOSE_HEADERS = ["Content-Type", "X-CSRFToken"]
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "django.db.backends.postgresql",
|
"ENGINE": "django.db.backends.postgresql",
|
||||||
"NAME": os.environ.get("DB_NAME", "tienda_ilusion_staging"),
|
"NAME": os.environ.get("POSTGRES_DB", "tienda_ilusion_staging"),
|
||||||
"USER": os.environ.get("DB_USER", "tienda_ilusion_user"),
|
"USER": os.environ.get("POSTGRES_USER", "tienda_ilusion_user"),
|
||||||
"PASSWORD": os.environ.get("DB_PASSWORD", "staging_local_password"),
|
"PASSWORD": os.environ.get(
|
||||||
|
"POSTGRES_PASSWORD", "staging_local_password"
|
||||||
|
),
|
||||||
"HOST": os.environ.get("DB_HOST", "localhost"),
|
"HOST": os.environ.get("DB_HOST", "localhost"),
|
||||||
"PORT": os.environ.get("DB_PORT", "5432"),
|
"PORT": os.environ.get("DB_PORT", "5432"),
|
||||||
"CONN_MAX_AGE": 600, # Persistent connections
|
"CONN_MAX_AGE": 600, # Persistent connections
|
||||||
@@ -117,7 +119,9 @@ WHITENOISE_AUTOREFRESH = (
|
|||||||
)
|
)
|
||||||
WHITENOISE_USE_FINDERS = False # Use collected static files only
|
WHITENOISE_USE_FINDERS = False # Use collected static files only
|
||||||
WHITENOISE_MANIFEST_STRICT = False # More permissive in staging
|
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
|
# Staging logging - similar to production but more verbose
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
@@ -148,7 +152,7 @@ LOGGING = {
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"handlers": ["console", "file"],
|
"handlers": ["console", "file"],
|
||||||
"level": "INFO",
|
"level": "DEBUG",
|
||||||
},
|
},
|
||||||
"loggers": {
|
"loggers": {
|
||||||
"django": {
|
"django": {
|
||||||
@@ -163,7 +167,7 @@ LOGGING = {
|
|||||||
},
|
},
|
||||||
"django.db.backends": {
|
"django.db.backends": {
|
||||||
"handlers": ["console"],
|
"handlers": ["console"],
|
||||||
"level": "INFO", # Show SQL queries in staging for debugging
|
"level": "DEBUG", # Show SQL queries in staging for debugging
|
||||||
"propagate": False,
|
"propagate": False,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -177,7 +181,10 @@ pathlib.Path(logs_dir).mkdir(parents=True, exist_ok=True)
|
|||||||
|
|
||||||
# Admin email notifications
|
# Admin email notifications
|
||||||
ADMINS = [
|
ADMINS = [
|
||||||
("Staging Admin", os.environ.get("ADMIN_EMAIL", "admin@tiendailusion.local")),
|
(
|
||||||
|
"Staging Admin",
|
||||||
|
os.environ.get("ADMIN_EMAIL", "admin@tiendailusion.local"),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
MANAGERS = ADMINS
|
MANAGERS = ADMINS
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user