mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
146 lines
4.2 KiB
YAML
146 lines
4.2 KiB
YAML
# Hanzo Commerce - Blue-Green Deployment Overlay
|
|
#
|
|
# Usage:
|
|
# Deploy Blue: DEPLOY_COLOR=blue docker compose -f deploy/compose.yml -f deploy/compose.blue-green.yml up -d
|
|
# Deploy Green: DEPLOY_COLOR=green docker compose -f deploy/compose.yml -f deploy/compose.blue-green.yml up -d
|
|
# Switch Active: ./deploy/scripts/switch-active.sh [blue|green]
|
|
|
|
name: hanzo-commerce
|
|
|
|
services:
|
|
# ===========================================================================
|
|
# BLUE DEPLOYMENT
|
|
# ===========================================================================
|
|
|
|
commerce-blue:
|
|
build:
|
|
context: ..
|
|
dockerfile: deploy/Dockerfile
|
|
args:
|
|
VERSION: ${VERSION:-2.0.0}
|
|
image: hanzoai/commerce:${VERSION:-latest}
|
|
container_name: commerce-blue
|
|
restart: unless-stopped
|
|
environment:
|
|
COMMERCE_DIR: /app/data
|
|
COMMERCE_DEV: ${COMMERCE_DEV:-false}
|
|
COMMERCE_SECRET: ${COMMERCE_SECRET}
|
|
PORT: 8001
|
|
ENV: ${ENV:-staging}
|
|
REDIS_URL: redis://redis:6379
|
|
DATASTORE_URL: datastore://${DATASTORE_USER:-default}:${DATASTORE_PASSWORD:-}@datastore:9000/commerce
|
|
IAM_URL: ${IAM_URL:-https://api.hanzo.id}
|
|
IAM_API_KEY: ${IAM_API_KEY:-}
|
|
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY:-}
|
|
DEPLOY_COLOR: blue
|
|
DEPLOY_VERSION: ${VERSION:-2.0.0}
|
|
volumes:
|
|
- commerce_data:/app/data
|
|
- commerce_logs:/app/logs
|
|
depends_on:
|
|
redis:
|
|
condition: service_healthy
|
|
datastore:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-sf", "http://localhost:8001/healthz"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
start_period: 15s
|
|
retries: 3
|
|
networks:
|
|
- commerce-network
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
memory: 1G
|
|
reservations:
|
|
memory: 256M
|
|
|
|
# ===========================================================================
|
|
# GREEN DEPLOYMENT
|
|
# ===========================================================================
|
|
|
|
commerce-green:
|
|
build:
|
|
context: ..
|
|
dockerfile: deploy/Dockerfile
|
|
args:
|
|
VERSION: ${VERSION:-2.0.0}
|
|
image: hanzoai/commerce:${VERSION:-latest}
|
|
container_name: commerce-green
|
|
restart: unless-stopped
|
|
environment:
|
|
COMMERCE_DIR: /app/data
|
|
COMMERCE_DEV: ${COMMERCE_DEV:-false}
|
|
COMMERCE_SECRET: ${COMMERCE_SECRET}
|
|
PORT: 8001
|
|
ENV: ${ENV:-staging}
|
|
REDIS_URL: redis://redis:6379
|
|
DATASTORE_URL: datastore://${DATASTORE_USER:-default}:${DATASTORE_PASSWORD:-}@datastore:9000/commerce
|
|
IAM_URL: ${IAM_URL:-https://api.hanzo.id}
|
|
IAM_API_KEY: ${IAM_API_KEY:-}
|
|
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY:-}
|
|
DEPLOY_COLOR: green
|
|
DEPLOY_VERSION: ${VERSION:-2.0.0}
|
|
volumes:
|
|
- commerce_data:/app/data
|
|
- commerce_logs:/app/logs
|
|
depends_on:
|
|
redis:
|
|
condition: service_healthy
|
|
datastore:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-sf", "http://localhost:8001/healthz"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
start_period: 15s
|
|
retries: 3
|
|
networks:
|
|
- commerce-network
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
memory: 1G
|
|
reservations:
|
|
memory: 256M
|
|
|
|
# ===========================================================================
|
|
# NGINX LOAD BALANCER (Required for Blue-Green)
|
|
# ===========================================================================
|
|
|
|
nginx:
|
|
image: nginx:alpine
|
|
container_name: commerce-nginx
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${HTTP_PORT:-80}:80"
|
|
- "${HTTPS_PORT:-443}:443"
|
|
volumes:
|
|
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
- ./nginx/conf.d:/etc/nginx/conf.d:ro
|
|
- ./nginx/ssl:/etc/nginx/ssl:ro
|
|
- nginx_logs:/var/log/nginx
|
|
depends_on:
|
|
commerce-blue:
|
|
condition: service_healthy
|
|
commerce-green:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-sf", "http://localhost/healthz"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
networks:
|
|
- commerce-network
|
|
|
|
# Disable the single commerce service when using blue-green
|
|
commerce:
|
|
profiles:
|
|
- disabled
|
|
|
|
volumes:
|
|
nginx_logs:
|
|
driver: local
|