fix(backup-service): convert deploy.sh line endings from CRLF to LF

This commit is contained in:
hailin 2025-12-06 23:29:58 -08:00
parent 0ab1bf0dcc
commit 54b9a66041
1 changed files with 94 additions and 94 deletions

188
backend/services/backup-service/deploy.sh Normal file → Executable file
View File

@ -1,94 +1,94 @@
#!/bin/bash #!/bin/bash
# ============================================================================= # =============================================================================
# Backup Service - Individual Deployment Script # Backup Service - Individual Deployment Script
# ============================================================================= # =============================================================================
set -e set -e
SERVICE_NAME="backup-service" SERVICE_NAME="backup-service"
CONTAINER_NAME="rwa-backup-service" CONTAINER_NAME="rwa-backup-service"
IMAGE_NAME="services-backup-service" IMAGE_NAME="services-backup-service"
PORT=3002 PORT=3002
# Colors # Colors
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
BLUE='\033[0;34m' BLUE='\033[0;34m'
NC='\033[0m' NC='\033[0m'
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[OK]${NC} $1"; } log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; } log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SERVICES_DIR="$(dirname "$SCRIPT_DIR")" SERVICES_DIR="$(dirname "$SCRIPT_DIR")"
if [ -f "$SERVICES_DIR/.env" ]; then if [ -f "$SERVICES_DIR/.env" ]; then
export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs) export $(cat "$SERVICES_DIR/.env" | grep -v '^#' | xargs)
fi fi
case "$1" in case "$1" in
build) build)
log_info "Building $SERVICE_NAME..." log_info "Building $SERVICE_NAME..."
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR" docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
log_success "$SERVICE_NAME built successfully" log_success "$SERVICE_NAME built successfully"
;; ;;
build-no-cache) build-no-cache)
log_info "Building $SERVICE_NAME (no cache)..." log_info "Building $SERVICE_NAME (no cache)..."
docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR" docker build --no-cache -t "$IMAGE_NAME" "$SCRIPT_DIR"
log_success "$SERVICE_NAME built successfully" log_success "$SERVICE_NAME built successfully"
;; ;;
start) start)
log_info "Starting $SERVICE_NAME..." log_info "Starting $SERVICE_NAME..."
cd "$SERVICES_DIR" cd "$SERVICES_DIR"
docker compose up -d "$SERVICE_NAME" docker compose up -d "$SERVICE_NAME"
log_success "$SERVICE_NAME started" log_success "$SERVICE_NAME started"
;; ;;
stop) stop)
log_info "Stopping $SERVICE_NAME..." log_info "Stopping $SERVICE_NAME..."
docker stop "$CONTAINER_NAME" 2>/dev/null || true docker stop "$CONTAINER_NAME" 2>/dev/null || true
docker rm "$CONTAINER_NAME" 2>/dev/null || true docker rm "$CONTAINER_NAME" 2>/dev/null || true
log_success "$SERVICE_NAME stopped" log_success "$SERVICE_NAME stopped"
;; ;;
restart) restart)
$0 stop $0 stop
$0 start $0 start
;; ;;
logs) logs)
docker logs -f "$CONTAINER_NAME" docker logs -f "$CONTAINER_NAME"
;; ;;
logs-tail) logs-tail)
docker logs --tail 100 "$CONTAINER_NAME" docker logs --tail 100 "$CONTAINER_NAME"
;; ;;
status) status)
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
log_success "$SERVICE_NAME is running" log_success "$SERVICE_NAME is running"
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}" docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Status}}\t{{.Ports}}"
else else
log_warn "$SERVICE_NAME is not running" log_warn "$SERVICE_NAME is not running"
fi fi
;; ;;
health) health)
log_info "Checking health of $SERVICE_NAME..." log_info "Checking health of $SERVICE_NAME..."
if curl -sf "http://localhost:$PORT/health" > /dev/null 2>&1; then if curl -sf "http://localhost:$PORT/health" > /dev/null 2>&1; then
log_success "$SERVICE_NAME is healthy" log_success "$SERVICE_NAME is healthy"
else else
log_error "$SERVICE_NAME health check failed" log_error "$SERVICE_NAME health check failed"
exit 1 exit 1
fi fi
;; ;;
migrate) migrate)
log_info "Running migrations for $SERVICE_NAME..." log_info "Running migrations for $SERVICE_NAME..."
docker exec "$CONTAINER_NAME" npx prisma migrate deploy docker exec "$CONTAINER_NAME" npx prisma migrate deploy
log_success "Migrations completed" log_success "Migrations completed"
;; ;;
shell) shell)
docker exec -it "$CONTAINER_NAME" sh docker exec -it "$CONTAINER_NAME" sh
;; ;;
*) *)
echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|shell}" echo "Usage: $0 {build|build-no-cache|start|stop|restart|logs|logs-tail|status|health|migrate|shell}"
exit 1 exit 1
;; ;;
esac esac