deploy.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. # CelestiaTrace Backend Deployment Script
  3. # Usage: ./deploy.sh
  4. set -e
  5. SERVER_IP="47.93.193.127"
  6. PEM_KEY="../ccdw-meishi-1.pem"
  7. REMOTE_DIR="/opt/celestia-trace"
  8. SSH_USER="root"
  9. echo "🚀 Deploying CelestiaTrace Backend..."
  10. # Ensure PEM key has correct permissions
  11. chmod 400 "$PEM_KEY"
  12. # Create remote directory
  13. ssh -i "$PEM_KEY" -o StrictHostKeyChecking=no "$SSH_USER@$SERVER_IP" "mkdir -p $REMOTE_DIR"
  14. # Sync backend files to server
  15. rsync -avz --exclude '.git' --exclude 'vendor' \
  16. -e "ssh -i $PEM_KEY -o StrictHostKeyChecking=no" \
  17. ./ "$SSH_USER@$SERVER_IP:$REMOTE_DIR/"
  18. # SSH into server and deploy with Docker Compose
  19. ssh -i "$PEM_KEY" -o StrictHostKeyChecking=no "$SSH_USER@$SERVER_IP" << 'REMOTE_CMDS'
  20. cd /opt/celestia-trace
  21. # Copy .env from example if not exists
  22. if [ ! -f .env ]; then
  23. cp .env.example .env
  24. echo "⚠️ Created .env from template. Please edit /opt/celestia-trace/.env with secure values!"
  25. fi
  26. # Pull latest images and rebuild
  27. docker compose down
  28. docker compose up -d --build
  29. # Show status
  30. echo ""
  31. echo "✅ Deployment complete!"
  32. echo "Services status:"
  33. docker compose ps
  34. REMOTE_CMDS
  35. echo ""
  36. echo "🎉 Done! Your backend is live at https://celestia-trace.ccdw.life"