feat: Implement dynamic Gatekeeper proxy and enhance service health monitoring
- **Implemented Dynamic Gatekeeper (Anubis) Proxy:** - Introduced Anubis as a Gatekeeper proxy layer for services (`web`, `web-staging`, `feedback`, `health`). - Added `docker-gen` setup (`docker-compose_gatekeeper.template.yml`, `gatekeeper-manager`) to dynamically configure Anubis instances based on container labels (`enable_gatekeeper=true`). - Updated HAProxy to route traffic through the respective Gatekeeper services. - **Enhanced Service Health Monitoring & Checks:** - Integrated `django-health-check` into the Django application, providing detailed health endpoints (e.g., `/health/`). - Replaced the custom health check view with `django-health-check` URLs. - Added `psutil` for system metrics in health checks. - Made Gatus configuration dynamic using `docker-gen` (`config.template.yaml`), allowing automatic discovery and monitoring of service instances (e.g., web workers). - Externalized Gatus SMTP credentials to environment variables. - Strengthened `docker-compose_core.yml` with a combined `db-redis-healthcheck` service reporting to Gatus. - Added explicit health checks for `db` and `redis` services in `docker-compose.yml`. - **Improved Docker & Compose Configuration:** - Added `depends_on` conditions in `docker-compose.yml` for `web` and `celery` services to wait for the database. - Updated `ALLOWED_HOSTS` in `docker-compose_staging.yml` and `docker-compose_web.yml` to include internal container names for Gatekeeper communication. - Set `DEBUG=False` for staging services. - Removed `.env.production` from `.gitignore` (standardized to `.env`). - Streamlined `scripts/entrypoint.sh` by removing the call to the no-longer-present `/deploy.sh`. - **Dependency Updates:** - Added `django-health-check>=3.18.3` and `psutil>=7.0.0` to `pyproject.toml` and `uv.lock`. - Updated `settings.py` to include `health_check` apps, configuration, and use `REDIS_URL` consistently. - **Streamlined deployment script used in GHA:** - Updated the workflow to copy new server files and create a new `.env` file in the temporary directory before moving them into place. - Consolidated the stopping and removal of old containers into a single step for better clarity and efficiency. - Reduce container downtime by rearranging stop/start steps.
This commit is contained in:
parent
f530790f6c
commit
6aa15d1af9
16 changed files with 487 additions and 162 deletions
|
|
@ -118,6 +118,15 @@ INSTALLED_APPS = [
|
|||
"crispy_tailwind",
|
||||
"tailwind",
|
||||
"django_linear_migrations",
|
||||
'health_check',
|
||||
'health_check.db',
|
||||
'health_check.cache',
|
||||
'health_check.storage',
|
||||
'health_check.contrib.migrations',
|
||||
'health_check.contrib.celery',
|
||||
'health_check.contrib.celery_ping',
|
||||
'health_check.contrib.psutil',
|
||||
'health_check.contrib.redis',
|
||||
"meta",
|
||||
] + FIRST_PARTY_APPS
|
||||
|
||||
|
|
@ -155,6 +164,11 @@ if DEBUG:
|
|||
"django_browser_reload.middleware.BrowserReloadMiddleware",
|
||||
]
|
||||
|
||||
HEALTH_CHECK = {
|
||||
'DISK_USAGE_MAX': 90, # percent
|
||||
'MEMORY_MIN': 100, # in MB
|
||||
}
|
||||
|
||||
DAISY_SETTINGS = {
|
||||
'SITE_TITLE': 'PKMN Trade Club Admin',
|
||||
'DONT_SUPPORT_ME': True,
|
||||
|
|
@ -208,7 +222,6 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/dev/topics/i18n/
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#language-code
|
||||
|
|
@ -344,6 +357,8 @@ CACHE_TIMEOUT = 604800 # 1 week
|
|||
|
||||
DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": lambda request: DEBUG}
|
||||
|
||||
REDIS_URL = "redis://redis:6379"
|
||||
|
||||
DISABLE_CACHE = env('DISABLE_CACHE', default=DEBUG)
|
||||
|
||||
if DISABLE_CACHE:
|
||||
|
|
@ -356,12 +371,12 @@ else:
|
|||
CACHES = {
|
||||
"default": {
|
||||
"BACKEND": "django.core.cache.backends.redis.RedisCache",
|
||||
"LOCATION": "redis://redis:6379",
|
||||
"LOCATION": REDIS_URL,
|
||||
}
|
||||
}
|
||||
|
||||
CELERY_BROKER_URL = "redis://redis:6379"
|
||||
CELERY_RESULT_BACKEND = "redis://redis:6379"
|
||||
CELERY_BROKER_URL = REDIS_URL
|
||||
CELERY_RESULT_BACKEND = REDIS_URL
|
||||
CELERY_TIMEZONE = "America/Los_Angeles"
|
||||
CELERY_ENABLE_UTC = True
|
||||
CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue