Commit graph

12 commits

Author SHA1 Message Date
30ce126a07
feat(deploy): implement blue-green deployment strategy
This commit replaces the previous deployment mechanism with a blue-green strategy to lay the groundwork for zero-downtime deployments.
Key changes:
Introduces a deploy-blue-green.sh script to manage "blue" and "green" container sets, creating versioned releases.
Updates the Anubis gatekeeper template to dynamically route traffic based on the active deployment color, allowing for seamless traffic switching.
Modifies Docker Compose files to include color-specific labels and environment variables.
Adapts the GitHub Actions workflow to execute the new blue-green deployment process.
Removes the old, now-obsolete deployment and health check scripts.
Note: Automated rollback on health check failure is not yet implemented. Downgrades can be performed manually by switching the active color.
2025-06-12 16:58:55 -07:00
a58a0e642a
fix(deploy): remove invalid parameters for download-artifact, add back in missing setuptools-scm dependency 2025-06-06 18:09:01 -07:00
291231c886
fix(deploy): correct env vars, docker compose project names, and workflow outputs
- Standardize environment variable from IS_PROD to PROD across all scripts
- Add missing -p flag to docker compose commands for consistent project naming
- Fix GitHub Actions workflow to use environment vars instead of job outputs
- Consolidate metadata setup and fix artifact naming in build/deploy jobs
- Correct service paths in docker-compose_core.yml
2025-06-06 17:26:50 -07:00
f20c4f9474
feat: add dynamic versioning and automated deployment with rollback capability
- Implement setuptools-scm for dynamic version management from git tags
- Refactor CI/CD into separate build and deploy jobs with artifact sharing
- Add versioned releases with timestamp-based deployment directories
- Implement health checks and automatic rollback on deployment failure
- Extract deployment logic into reusable shell scripts
- Add Docker layer caching to speed up builds
- Include version info in Django context and build args
2025-06-06 14:38:23 -07:00
02f23dba28
refactor(docker): Enhance settings.py and deployment
This commit significantly refactors the Docker setup and application
configuration for improved robustness and flexibility.

Key changes include:

- Centralized Environment Variables:
  - Default values for essential settings (database, email, cache, etc.)
    are now defined in `django_project/settings.py` using `environ.Env`.
    This provides sensible defaults and reduces reliance on `.env` files,
    especially during Docker image builds.
  - `docker-compose.yml` no longer defines environment variables directly
    for `web` and `worker` services, deferring to `.env` and settings defaults.

- Dockerfile & Entrypoint Improvements:
  - `DJANGO_SETTINGS_MODULE` is now exclusively set as an ENV in `Dockerfile`, instead of setting it in `entrypoint.sh`
  - `entrypoint.sh` now conditionally appends `--static-path-mount`
    only to the `granian` command, leveraging the upgraded Granian's
    (v2.3.0+) ability to serve static files directly. The `STATIC_ROOT` is
    dynamically fetched from Django settings.

- Dependency Updates:
  - Upgraded `granian` from 2.2.5 to 2.3.1.
  - Upgraded `click` from 8.2.0 to 8.2.1.
  - `uv.lock` reflects these and other minor transitive dependency updates.

- Configuration Adjustments in `settings.py`:
  - Add defaults for all env variables, and set to default local dev settings
  - Introduced a `SCHEME` environment variable (defaulting to 'http')
    used for `CSRF_TRUSTED_ORIGINS`, `META_SITE_PROTOCOL`,
    `ACCOUNT_DEFAULT_HTTP_PROTOCOL`, etc.
  - `TIME_ZONE` and various email settings (host, port, user, password, TLS)
    are now configurable via environment variables with defaults.
  - `CELERY_TIMEZONE` now defaults to the `TIME_ZONE` setting.
  - Removed the unused `SCW_SECRET_KEY` variable (previously used for
    EMAIL auth).
2025-05-23 18:46:29 -07:00
6aa15d1af9
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.
2025-05-23 00:15:19 -07:00
f530790f6c add celery background tasks and redis server for celery, also modify django to use redis instead of postgres for caching for speed improvement and alleviating sql traffic 2025-05-19 18:23:19 -07:00
6f57699c8d Major refactoring of build_deploy action, along with docker building and packaging improvements. Added no_signups and other .env improvements. There is no longer a separate .env.dev, both use .env now. 2025-05-18 11:27:59 -07:00
959b06c425 Packaging fixes 2025-05-09 08:43:43 -07:00
fa6103d007 Add django-linear-migrations dependency
- Introduced `django-linear-migrations` version 2.17.0 to manage migrations more effectively and prevent merges.
- Refactored `INSTALLED_APPS` in `settings.py` to allow linear-migrations to track first party apps explicitly.
2025-05-06 23:16:10 -07:00
9c41f63247 Complete refactor of environment configuration and Docker setup for development and production.
- Dev and prod both now run with the same exact docker configuration, except the .env file copied in.
- Removed the `.env` file and added a new `.env.dev` file for development settings, including database configuration and API keys.
- Introduced a `.envrc` file for automatic venv activation.
- Updated `deploy.sh` to utilize `uv` for running management commands and added a command for building Tailwind CSS.
- Created `docker-compose.yml` for local development with PostgreSQL, ensuring proper service dependencies.
- Deleted unnecessary files such as `docker-compose_db_only.yml` and `requirements.txt` to streamline the project structure.
2025-05-05 21:48:59 -07:00
d62956d465 finished conversion to tailwind 2025-03-11 23:47:20 -07:00