feat: Add staging environment for local production testing

- Add docker-compose.staging.yml with PostgreSQL and Django
- Add .env.staging.example with staging-specific environment variables
- Configure staging settings (DEBUG=False, no SSL redirect for localhost)
- Update settings/__init__.py to support staging environment detection
- Update AGENTS.md with staging environment documentation
- Update .gitignore to exclude .env.staging
- Optimize docker-compose.prod.yml configuration

Staging environment simulates production configuration locally:
- PostgreSQL database (port 5433 to avoid conflicts)
- Gunicorn with 4 workers
- DEBUG=False but HTTP allowed for easier testing
- Separate volumes for static files, media, and logs

Usage:
  cp .env.staging.example .env.staging
  docker compose -f docker-compose.staging.yml up -d
This commit is contained in:
2026-05-10 20:32:42 -05:00
parent 8818246870
commit bf69fe88d9
7 changed files with 198 additions and 18 deletions

View File

@@ -3,8 +3,9 @@ Settings module for tienda_ilusion project.
This module automatically loads the appropriate settings based on the DJANGO_ENV
environment variable. Valid values are:
- 'development' (default): Development settings
- 'production': Production settings
- 'development' (default): Development settings with SQLite
- 'staging': Staging settings for testing production config locally (PostgreSQL, no SSL)
- 'production': Production settings with full security (PostgreSQL, SSL, etc.)
Usage:
Set DJANGO_ENV environment variable before running Django:
@@ -13,6 +14,10 @@ Usage:
export DJANGO_ENV=development
python manage.py runserver
Staging (test production locally):
export DJANGO_ENV=staging
python manage.py runserver
Production:
export DJANGO_ENV=production
gunicorn config.wsgi:application
@@ -25,6 +30,8 @@ DJANGO_ENV = os.environ.get("DJANGO_ENV", "development")
if DJANGO_ENV == "production":
from .production import *
elif DJANGO_ENV == "staging":
from .staging import *
elif DJANGO_ENV == "development":
from .development import *
else: