pkmntrade.club/server/docker-compose_web.yml
badbl0cks 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

50 lines
No EOL
1.5 KiB
YAML

x-common: &common
image: badbl0cks/pkmntrade-club:${IMAGE_TAG:-stable}
#image: ghcr.io/xe/x/httpdebug
#entrypoint: ["/ko-app/httpdebug", "--bind", ":8000"]
restart: always
env_file:
- .env
services:
web:
<<: *common
environment:
- DEBUG=False
- DISABLE_SIGNUPS=True
- PUBLIC_HOST=${DOMAIN_NAME}
- ALLOWED_HOSTS=${DOMAIN_NAME},127.0.0.1
- DEPLOYMENT_COLOR=${DEPLOYMENT_COLOR:-blue}
labels:
- "enable_gatekeeper=true"
- "deployment.color=${DEPLOYMENT_COLOR:-blue}"
- "deployment.image_tag=${IMAGE_TAG:-stable}"
deploy:
mode: replicated
replicas: ${REPLICA_COUNT}
healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:8000/health/"]
interval: 5s
timeout: 3s
retries: 2
start_period: 60s
stop_grace_period: 200s # 20s buffer + 180s workers-kill-timeout
celery:
<<: *common
environment:
- DEBUG=False
- DISABLE_SIGNUPS=True
- PUBLIC_HOST=pkmntrade.club
- ALLOWED_HOSTS=pkmntrade.club,127.0.0.1
- DEPLOYMENT_COLOR=${DEPLOYMENT_COLOR:-blue}
labels:
- "deployment.color=${DEPLOYMENT_COLOR:-blue}"
- "deployment.image_tag=${IMAGE_TAG:-stable}"
command: ["celery", "-A", "pkmntrade_club.django_project", "worker", "-l", "INFO", "-B", "-E"]
stop_grace_period: 200s # match our longest stop_grace_period (currently web service is 200s)
networks:
default:
name: pkmntrade-club_network
external: true