feat(services): add individual deploy scripts for each service
Add deploy.sh script to each service directory for independent deployment and management: - identity-service, wallet-service, backup-service - planting-service, referral-service, reward-service - mpc-service, leaderboard-service, reporting-service - authorization-service Each script supports: - build / build-no-cache - start / stop / restart - logs / logs-tail - status / health - migrate / shell Also updated main deploy.sh with build-no-cache command. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
2a449aff3c
commit
0a0b7eb886
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Authorization Service - Individual Deployment Script
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
SERVICE_NAME="authorization-service"
|
||||
CONTAINER_NAME="rwa-authorization-service"
|
||||
IMAGE_NAME="services-authorization-service"
|
||||
PORT=3009
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
if [ -f "$SERVICES_DIR/.env" ]; then
|
||||
export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs)
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
log_info "Building $SERVICE_NAME..."
|
||||
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
build-no-cache)
|
||||
log_info "Building $SERVICE_NAME (no cache)..."
|
||||
docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
start)
|
||||
log_info "Starting $SERVICE_NAME..."
|
||||
cd "$SERVICES_DIR"
|
||||
docker compose up -d "$SERVICE_NAME"
|
||||
log_success "$SERVICE_NAME started"
|
||||
;;
|
||||
stop)
|
||||
log_info "Stopping $SERVICE_NAME..."
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
log_success "$SERVICE_NAME stopped"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
logs)
|
||||
docker logs -f "$CONTAINER_NAME"
|
||||
;;
|
||||
logs-tail)
|
||||
docker logs --tail 100 "$CONTAINER_NAME"
|
||||
;;
|
||||
status)
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
log_success "$SERVICE_NAME is running"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}"
|
||||
else
|
||||
log_warn "$SERVICE_NAME is not running"
|
||||
fi
|
||||
;;
|
||||
health)
|
||||
log_info "Checking health of $SERVICE_NAME..."
|
||||
if curl -sf "http://localhost:$PORT/health" > /dev/null 2>&1; then
|
||||
log_success "$SERVICE_NAME is healthy"
|
||||
else
|
||||
log_error "$SERVICE_NAME health check failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
migrate)
|
||||
log_info "Running migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate deploy
|
||||
log_success "Migrations completed"
|
||||
;;
|
||||
shell)
|
||||
docker exec -it "$CONTAINER_NAME" sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|shell}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Backup Service - Individual Deployment Script
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
SERVICE_NAME="backup-service"
|
||||
CONTAINER_NAME="rwa-backup-service"
|
||||
IMAGE_NAME="services-backup-service"
|
||||
PORT=3002
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
if [ -f "$SERVICES_DIR/.env" ]; then
|
||||
export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs)
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
log_info "Building $SERVICE_NAME..."
|
||||
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
build-no-cache)
|
||||
log_info "Building $SERVICE_NAME (no cache)..."
|
||||
docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
start)
|
||||
log_info "Starting $SERVICE_NAME..."
|
||||
cd "$SERVICES_DIR"
|
||||
docker compose up -d "$SERVICE_NAME"
|
||||
log_success "$SERVICE_NAME started"
|
||||
;;
|
||||
stop)
|
||||
log_info "Stopping $SERVICE_NAME..."
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
log_success "$SERVICE_NAME stopped"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
logs)
|
||||
docker logs -f "$CONTAINER_NAME"
|
||||
;;
|
||||
logs-tail)
|
||||
docker logs --tail 100 "$CONTAINER_NAME"
|
||||
;;
|
||||
status)
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
log_success "$SERVICE_NAME is running"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}"
|
||||
else
|
||||
log_warn "$SERVICE_NAME is not running"
|
||||
fi
|
||||
;;
|
||||
health)
|
||||
log_info "Checking health of $SERVICE_NAME..."
|
||||
if curl -sf "http://localhost:$PORT/health" > /dev/null 2>&1; then
|
||||
log_success "$SERVICE_NAME is healthy"
|
||||
else
|
||||
log_error "$SERVICE_NAME health check failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
migrate)
|
||||
log_info "Running migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate deploy
|
||||
log_success "Migrations completed"
|
||||
;;
|
||||
shell)
|
||||
docker exec -it "$CONTAINER_NAME" sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|shell}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -221,6 +221,18 @@ build() {
|
|||
log_info "All images built successfully"
|
||||
}
|
||||
|
||||
build_no_cache() {
|
||||
log_step "Building Docker images (no cache)..."
|
||||
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
log_error "Environment file not found. Run './deploy.sh install' first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" build --no-cache --parallel
|
||||
log_info "All images built successfully (no cache)"
|
||||
}
|
||||
|
||||
# ===========================================================================
|
||||
# Status and Monitoring
|
||||
# ===========================================================================
|
||||
|
|
@ -407,6 +419,9 @@ case "${1:-}" in
|
|||
build)
|
||||
build
|
||||
;;
|
||||
build-no-cache)
|
||||
build_no_cache
|
||||
;;
|
||||
status|ps)
|
||||
status
|
||||
;;
|
||||
|
|
@ -442,6 +457,7 @@ case "${1:-}" in
|
|||
echo " down/stop - Stop all services"
|
||||
echo " restart - Restart all services"
|
||||
echo " build - Build all Docker images"
|
||||
echo " build-no-cache - Build all images without cache"
|
||||
echo " status/ps - Show service status"
|
||||
echo " health - Check health of all services"
|
||||
echo " logs [svc] - View logs (optionally for specific service)"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,140 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Identity Service - Individual Deployment Script
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
SERVICE_NAME="identity-service"
|
||||
CONTAINER_NAME="rwa-identity-service"
|
||||
IMAGE_NAME="services-identity-service"
|
||||
PORT=3000
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
# Get script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
# Load environment
|
||||
if [ -f "$SERVICES_DIR/.env" ]; then
|
||||
export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs)
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
log_info "Building $SERVICE_NAME..."
|
||||
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
|
||||
build-no-cache)
|
||||
log_info "Building $SERVICE_NAME (no cache)..."
|
||||
docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
|
||||
start)
|
||||
log_info "Starting $SERVICE_NAME..."
|
||||
cd "$SERVICES_DIR"
|
||||
docker compose up -d "$SERVICE_NAME"
|
||||
log_success "$SERVICE_NAME started"
|
||||
;;
|
||||
|
||||
stop)
|
||||
log_info "Stopping $SERVICE_NAME..."
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
log_success "$SERVICE_NAME stopped"
|
||||
;;
|
||||
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
|
||||
logs)
|
||||
docker logs -f "$CONTAINER_NAME"
|
||||
;;
|
||||
|
||||
logs-tail)
|
||||
docker logs --tail 100 "$CONTAINER_NAME"
|
||||
;;
|
||||
|
||||
status)
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
log_success "$SERVICE_NAME is running"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}"
|
||||
else
|
||||
log_warn "$SERVICE_NAME is not running"
|
||||
fi
|
||||
;;
|
||||
|
||||
health)
|
||||
log_info "Checking health of $SERVICE_NAME..."
|
||||
if curl -sf "http://localhost:$PORT/health" > /dev/null 2>&1; then
|
||||
log_success "$SERVICE_NAME is healthy"
|
||||
else
|
||||
log_error "$SERVICE_NAME health check failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
migrate)
|
||||
log_info "Running migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate deploy
|
||||
log_success "Migrations completed"
|
||||
;;
|
||||
|
||||
migrate-dev)
|
||||
log_info "Running dev migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate dev
|
||||
;;
|
||||
|
||||
prisma-studio)
|
||||
log_info "Starting Prisma Studio..."
|
||||
docker exec -it "$CONTAINER_NAME" npx prisma studio
|
||||
;;
|
||||
|
||||
shell)
|
||||
log_info "Opening shell in $SERVICE_NAME container..."
|
||||
docker exec -it "$CONTAINER_NAME" sh
|
||||
;;
|
||||
|
||||
test)
|
||||
log_info "Running tests for $SERVICE_NAME..."
|
||||
cd "$SCRIPT_DIR"
|
||||
npm test
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|migrate-dev|prisma-studio|shell|test}"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " build - Build Docker image"
|
||||
echo " build-no-cache - Build Docker image without cache"
|
||||
echo " start - Start the service"
|
||||
echo " stop - Stop the service"
|
||||
echo " restart - Restart the service"
|
||||
echo " logs - Follow logs"
|
||||
echo " logs-tail - Show last 100 log lines"
|
||||
echo " status - Show service status"
|
||||
echo " health - Check service health"
|
||||
echo " migrate - Run database migrations"
|
||||
echo " migrate-dev - Run dev migrations"
|
||||
echo " prisma-studio - Open Prisma Studio"
|
||||
echo " shell - Open shell in container"
|
||||
echo " test - Run tests locally"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Leaderboard Service - Individual Deployment Script
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
SERVICE_NAME="leaderboard-service"
|
||||
CONTAINER_NAME="rwa-leaderboard-service"
|
||||
IMAGE_NAME="services-leaderboard-service"
|
||||
PORT=3007
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
if [ -f "$SERVICES_DIR/.env" ]; then
|
||||
export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs)
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
log_info "Building $SERVICE_NAME..."
|
||||
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
build-no-cache)
|
||||
log_info "Building $SERVICE_NAME (no cache)..."
|
||||
docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
start)
|
||||
log_info "Starting $SERVICE_NAME..."
|
||||
cd "$SERVICES_DIR"
|
||||
docker compose up -d "$SERVICE_NAME"
|
||||
log_success "$SERVICE_NAME started"
|
||||
;;
|
||||
stop)
|
||||
log_info "Stopping $SERVICE_NAME..."
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
log_success "$SERVICE_NAME stopped"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
logs)
|
||||
docker logs -f "$CONTAINER_NAME"
|
||||
;;
|
||||
logs-tail)
|
||||
docker logs --tail 100 "$CONTAINER_NAME"
|
||||
;;
|
||||
status)
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
log_success "$SERVICE_NAME is running"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}"
|
||||
else
|
||||
log_warn "$SERVICE_NAME is not running"
|
||||
fi
|
||||
;;
|
||||
health)
|
||||
log_info "Checking health of $SERVICE_NAME..."
|
||||
if curl -sf "http://localhost:$PORT/health" > /dev/null 2>&1; then
|
||||
log_success "$SERVICE_NAME is healthy"
|
||||
else
|
||||
log_error "$SERVICE_NAME health check failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
migrate)
|
||||
log_info "Running migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate deploy
|
||||
log_success "Migrations completed"
|
||||
;;
|
||||
shell)
|
||||
docker exec -it "$CONTAINER_NAME" sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|shell}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# MPC Service - Individual Deployment Script
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
SERVICE_NAME="mpc-service"
|
||||
CONTAINER_NAME="rwa-mpc-service"
|
||||
IMAGE_NAME="services-mpc-service"
|
||||
PORT=3006
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
if [ -f "$SERVICES_DIR/.env" ]; then
|
||||
export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs)
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
log_info "Building $SERVICE_NAME..."
|
||||
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
build-no-cache)
|
||||
log_info "Building $SERVICE_NAME (no cache)..."
|
||||
docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
start)
|
||||
log_info "Starting $SERVICE_NAME..."
|
||||
cd "$SERVICES_DIR"
|
||||
docker compose up -d "$SERVICE_NAME"
|
||||
log_success "$SERVICE_NAME started"
|
||||
;;
|
||||
stop)
|
||||
log_info "Stopping $SERVICE_NAME..."
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
log_success "$SERVICE_NAME stopped"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
logs)
|
||||
docker logs -f "$CONTAINER_NAME"
|
||||
;;
|
||||
logs-tail)
|
||||
docker logs --tail 100 "$CONTAINER_NAME"
|
||||
;;
|
||||
status)
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
log_success "$SERVICE_NAME is running"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}"
|
||||
else
|
||||
log_warn "$SERVICE_NAME is not running"
|
||||
fi
|
||||
;;
|
||||
health)
|
||||
log_info "Checking health of $SERVICE_NAME..."
|
||||
if curl -sf "http://localhost:$PORT/api/v1/health" > /dev/null 2>&1; then
|
||||
log_success "$SERVICE_NAME is healthy"
|
||||
else
|
||||
log_error "$SERVICE_NAME health check failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
migrate)
|
||||
log_info "Running migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate deploy
|
||||
log_success "Migrations completed"
|
||||
;;
|
||||
shell)
|
||||
docker exec -it "$CONTAINER_NAME" sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|shell}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Planting Service - Individual Deployment Script
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
SERVICE_NAME="planting-service"
|
||||
CONTAINER_NAME="rwa-planting-service"
|
||||
IMAGE_NAME="services-planting-service"
|
||||
PORT=3003
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
if [ -f "$SERVICES_DIR/.env" ]; then
|
||||
export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs)
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
log_info "Building $SERVICE_NAME..."
|
||||
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
build-no-cache)
|
||||
log_info "Building $SERVICE_NAME (no cache)..."
|
||||
docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
start)
|
||||
log_info "Starting $SERVICE_NAME..."
|
||||
cd "$SERVICES_DIR"
|
||||
docker compose up -d "$SERVICE_NAME"
|
||||
log_success "$SERVICE_NAME started"
|
||||
;;
|
||||
stop)
|
||||
log_info "Stopping $SERVICE_NAME..."
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
log_success "$SERVICE_NAME stopped"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
logs)
|
||||
docker logs -f "$CONTAINER_NAME"
|
||||
;;
|
||||
logs-tail)
|
||||
docker logs --tail 100 "$CONTAINER_NAME"
|
||||
;;
|
||||
status)
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
log_success "$SERVICE_NAME is running"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}"
|
||||
else
|
||||
log_warn "$SERVICE_NAME is not running"
|
||||
fi
|
||||
;;
|
||||
health)
|
||||
log_info "Checking health of $SERVICE_NAME..."
|
||||
if curl -sf "http://localhost:$PORT/api/v1/health" > /dev/null 2>&1; then
|
||||
log_success "$SERVICE_NAME is healthy"
|
||||
else
|
||||
log_error "$SERVICE_NAME health check failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
migrate)
|
||||
log_info "Running migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate deploy
|
||||
log_success "Migrations completed"
|
||||
;;
|
||||
shell)
|
||||
docker exec -it "$CONTAINER_NAME" sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|shell}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Referral Service - Individual Deployment Script
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
SERVICE_NAME="referral-service"
|
||||
CONTAINER_NAME="rwa-referral-service"
|
||||
IMAGE_NAME="services-referral-service"
|
||||
PORT=3004
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
if [ -f "$SERVICES_DIR/.env" ]; then
|
||||
export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs)
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
log_info "Building $SERVICE_NAME..."
|
||||
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
build-no-cache)
|
||||
log_info "Building $SERVICE_NAME (no cache)..."
|
||||
docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
start)
|
||||
log_info "Starting $SERVICE_NAME..."
|
||||
cd "$SERVICES_DIR"
|
||||
docker compose up -d "$SERVICE_NAME"
|
||||
log_success "$SERVICE_NAME started"
|
||||
;;
|
||||
stop)
|
||||
log_info "Stopping $SERVICE_NAME..."
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
log_success "$SERVICE_NAME stopped"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
logs)
|
||||
docker logs -f "$CONTAINER_NAME"
|
||||
;;
|
||||
logs-tail)
|
||||
docker logs --tail 100 "$CONTAINER_NAME"
|
||||
;;
|
||||
status)
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
log_success "$SERVICE_NAME is running"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}"
|
||||
else
|
||||
log_warn "$SERVICE_NAME is not running"
|
||||
fi
|
||||
;;
|
||||
health)
|
||||
log_info "Checking health of $SERVICE_NAME..."
|
||||
if curl -sf "http://localhost:$PORT/health" > /dev/null 2>&1; then
|
||||
log_success "$SERVICE_NAME is healthy"
|
||||
else
|
||||
log_error "$SERVICE_NAME health check failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
migrate)
|
||||
log_info "Running migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate deploy
|
||||
log_success "Migrations completed"
|
||||
;;
|
||||
shell)
|
||||
docker exec -it "$CONTAINER_NAME" sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|shell}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Reporting Service - Individual Deployment Script
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
SERVICE_NAME="reporting-service"
|
||||
CONTAINER_NAME="rwa-reporting-service"
|
||||
IMAGE_NAME="services-reporting-service"
|
||||
PORT=3008
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
if [ -f "$SERVICES_DIR/.env" ]; then
|
||||
export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs)
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
log_info "Building $SERVICE_NAME..."
|
||||
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
build-no-cache)
|
||||
log_info "Building $SERVICE_NAME (no cache)..."
|
||||
docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
start)
|
||||
log_info "Starting $SERVICE_NAME..."
|
||||
cd "$SERVICES_DIR"
|
||||
docker compose up -d "$SERVICE_NAME"
|
||||
log_success "$SERVICE_NAME started"
|
||||
;;
|
||||
stop)
|
||||
log_info "Stopping $SERVICE_NAME..."
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
log_success "$SERVICE_NAME stopped"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
logs)
|
||||
docker logs -f "$CONTAINER_NAME"
|
||||
;;
|
||||
logs-tail)
|
||||
docker logs --tail 100 "$CONTAINER_NAME"
|
||||
;;
|
||||
status)
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
log_success "$SERVICE_NAME is running"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}"
|
||||
else
|
||||
log_warn "$SERVICE_NAME is not running"
|
||||
fi
|
||||
;;
|
||||
health)
|
||||
log_info "Checking health of $SERVICE_NAME..."
|
||||
if curl -sf "http://localhost:$PORT/health" > /dev/null 2>&1; then
|
||||
log_success "$SERVICE_NAME is healthy"
|
||||
else
|
||||
log_error "$SERVICE_NAME health check failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
migrate)
|
||||
log_info "Running migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate deploy
|
||||
log_success "Migrations completed"
|
||||
;;
|
||||
shell)
|
||||
docker exec -it "$CONTAINER_NAME" sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|shell}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Reward Service - Individual Deployment Script
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
SERVICE_NAME="reward-service"
|
||||
CONTAINER_NAME="rwa-reward-service"
|
||||
IMAGE_NAME="services-reward-service"
|
||||
PORT=3005
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
if [ -f "$SERVICES_DIR/.env" ]; then
|
||||
export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs)
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
log_info "Building $SERVICE_NAME..."
|
||||
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
build-no-cache)
|
||||
log_info "Building $SERVICE_NAME (no cache)..."
|
||||
docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
start)
|
||||
log_info "Starting $SERVICE_NAME..."
|
||||
cd "$SERVICES_DIR"
|
||||
docker compose up -d "$SERVICE_NAME"
|
||||
log_success "$SERVICE_NAME started"
|
||||
;;
|
||||
stop)
|
||||
log_info "Stopping $SERVICE_NAME..."
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
log_success "$SERVICE_NAME stopped"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
logs)
|
||||
docker logs -f "$CONTAINER_NAME"
|
||||
;;
|
||||
logs-tail)
|
||||
docker logs --tail 100 "$CONTAINER_NAME"
|
||||
;;
|
||||
status)
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
log_success "$SERVICE_NAME is running"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}"
|
||||
else
|
||||
log_warn "$SERVICE_NAME is not running"
|
||||
fi
|
||||
;;
|
||||
health)
|
||||
log_info "Checking health of $SERVICE_NAME..."
|
||||
if curl -sf "http://localhost:$PORT/health" > /dev/null 2>&1; then
|
||||
log_success "$SERVICE_NAME is healthy"
|
||||
else
|
||||
log_error "$SERVICE_NAME health check failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
migrate)
|
||||
log_info "Running migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate deploy
|
||||
log_success "Migrations completed"
|
||||
;;
|
||||
shell)
|
||||
docker exec -it "$CONTAINER_NAME" sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|shell}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Wallet Service - Individual Deployment Script
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
SERVICE_NAME="wallet-service"
|
||||
CONTAINER_NAME="rwa-wallet-service"
|
||||
IMAGE_NAME="services-wallet-service"
|
||||
PORT=3001
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
if [ -f "$SERVICES_DIR/.env" ]; then
|
||||
export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs)
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
log_info "Building $SERVICE_NAME..."
|
||||
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
build-no-cache)
|
||||
log_info "Building $SERVICE_NAME (no cache)..."
|
||||
docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR"
|
||||
log_success "$SERVICE_NAME built successfully"
|
||||
;;
|
||||
start)
|
||||
log_info "Starting $SERVICE_NAME..."
|
||||
cd "$SERVICES_DIR"
|
||||
docker compose up -d "$SERVICE_NAME"
|
||||
log_success "$SERVICE_NAME started"
|
||||
;;
|
||||
stop)
|
||||
log_info "Stopping $SERVICE_NAME..."
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
log_success "$SERVICE_NAME stopped"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
logs)
|
||||
docker logs -f "$CONTAINER_NAME"
|
||||
;;
|
||||
logs-tail)
|
||||
docker logs --tail 100 "$CONTAINER_NAME"
|
||||
;;
|
||||
status)
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
log_success "$SERVICE_NAME is running"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}"
|
||||
else
|
||||
log_warn "$SERVICE_NAME is not running"
|
||||
fi
|
||||
;;
|
||||
health)
|
||||
log_info "Checking health of $SERVICE_NAME..."
|
||||
if curl -sf "http://localhost:$PORT/health" > /dev/null 2>&1; then
|
||||
log_success "$SERVICE_NAME is healthy"
|
||||
else
|
||||
log_error "$SERVICE_NAME health check failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
migrate)
|
||||
log_info "Running migrations for $SERVICE_NAME..."
|
||||
docker exec "$CONTAINER_NAME" npx prisma migrate deploy
|
||||
log_success "Migrations completed"
|
||||
;;
|
||||
shell)
|
||||
docker exec -it "$CONTAINER_NAME" sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|shell}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Loading…
Reference in New Issue