Download deploy.sh from Text-to-Document-Generation/Docgenie-API: direct link, hf CLI and curl.
- Browser
- Download file 5.72 kB
-
https://huggingface.co/spaces/Text-to-Document-Generation/Docgenie-API/resolve/main/deploy.sh
- Command line
-
hf download hf://spaces/Text-to-Document-Generation/Docgenie-API/deploy.sh
-
curl -L -o deploy.sh https://huggingface.co/spaces/Text-to-Document-Generation/Docgenie-API/resolve/main/deploy.sh
5.72 kB
| # ============================================ | |
| # DocGenie Deployment Helper Script | |
| # ============================================ | |
| # Quick deployment script for Railway + RunPod | |
| set -e # Exit on error | |
| echo "π DocGenie Deployment Helper" | |
| echo "==============================" | |
| echo "" | |
| # Colors | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| NC='\033[0m' # No Color | |
| # Function to print colored messages | |
| print_success() { | |
| echo -e "${GREEN}β $1${NC}" | |
| } | |
| print_error() { | |
| echo -e "${RED}β $1${NC}" | |
| } | |
| print_info() { | |
| echo -e "${YELLOW}βΉ $1${NC}" | |
| } | |
| # Check prerequisites | |
| echo "Checking prerequisites..." | |
| # Check if Docker is installed | |
| if ! command -v docker &> /dev/null; then | |
| print_error "Docker is not installed. Please install Docker first." | |
| exit 1 | |
| fi | |
| print_success "Docker installed" | |
| # Check if .env exists | |
| if [ ! -f "api/.env" ]; then | |
| print_error "api/.env file not found. Please create it first." | |
| exit 1 | |
| fi | |
| print_success "Environment file found" | |
| # Menu | |
| echo "" | |
| echo "Select deployment option:" | |
| echo "1) Build Handwriting Service Docker image" | |
| echo "2) Push Handwriting Service to Docker Hub" | |
| echo "3) Deploy API to Railway" | |
| echo "4) Run local test environment (docker-compose)" | |
| echo "5) Full deployment (Handwriting + API)" | |
| echo "0) Exit" | |
| echo "" | |
| read -p "Enter option (0-5): " option | |
| case $option in | |
| 1) | |
| echo "" | |
| print_info "Building Handwriting Service Docker image..." | |
| # Build image | |
| cd handwriting_service | |
| docker buildx build --platform linux/amd64 \ | |
| -t docgenie-handwriting:latest \ | |
| --build-arg BUILDKIT_INLINE_CACHE=1 \ | |
| . | |
| print_success "Image built successfully" | |
| print_info "Tag: docgenie-handwriting:latest" | |
| ;; | |
| 2) | |
| echo "" | |
| read -p "Enter your Docker Hub username: " docker_username | |
| print_info "Tagging image for Docker Hub..." | |
| docker tag docgenie-handwriting:latest ${docker_username}/docgenie-handwriting:latest | |
| print_info "Pushing to Docker Hub..." | |
| docker push ${docker_username}/docgenie-handwriting:latest | |
| print_success "Image pushed successfully" | |
| print_info "Deploy this on RunPod: ${docker_username}/docgenie-handwriting:latest" | |
| ;; | |
| 3) | |
| echo "" | |
| print_info "Deploying API to Railway..." | |
| # Check if Railway CLI is installed | |
| if ! command -v railway &> /dev/null; then | |
| print_error "Railway CLI not installed. Installing..." | |
| npm i -g @railway/cli | |
| fi | |
| # Deploy | |
| railway up | |
| print_success "API deployed to Railway" | |
| print_info "View logs: railway logs" | |
| print_info "View URL: railway open" | |
| ;; | |
| 4) | |
| echo "" | |
| print_info "Starting local test environment..." | |
| print_info "This will start: Redis, API, Worker, Handwriting Service" | |
| # Check if GPU is available | |
| if command -v nvidia-smi &> /dev/null; then | |
| print_info "GPU detected, using CUDA" | |
| docker-compose up | |
| else | |
| print_info "No GPU detected, using CPU for handwriting service" | |
| DEVICE=cpu docker-compose up | |
| fi | |
| ;; | |
| 5) | |
| echo "" | |
| print_info "Full deployment starting..." | |
| # Step 1: Build handwriting image | |
| print_info "Step 1/4: Building Handwriting Service..." | |
| cd handwriting_service | |
| docker buildx build --platform linux/amd64 \ | |
| -t docgenie-handwriting:latest \ | |
| --build-arg BUILDKIT_INLINE_CACHE=1 \ | |
| . | |
| cd .. | |
| print_success "Handwriting image built" | |
| # Step 2: Push to Docker Hub | |
| echo "" | |
| read -p "Enter your Docker Hub username: " docker_username | |
| print_info "Step 2/4: Pushing to Docker Hub..." | |
| docker tag docgenie-handwriting:latest ${docker_username}/docgenie-handwriting:latest | |
| docker push ${docker_username}/docgenie-handwriting:latest | |
| print_success "Image pushed" | |
| # Step 3: Deploy to RunPod (manual) | |
| echo "" | |
| print_info "Step 3/4: Deploy to RunPod (manual step)" | |
| print_info "1. Go to https://runpod.io β Serverless β New Endpoint" | |
| print_info "2. Use image: ${docker_username}/docgenie-handwriting:latest" | |
| print_info "3. Select GPU: RTX 4090 or A40" | |
| print_info "4. Set port: 8080" | |
| print_info "5. Set env: DEVICE=cuda" | |
| read -p "Press Enter when RunPod deployment is complete..." | |
| # Step 4: Get RunPod URL and deploy API | |
| echo "" | |
| read -p "Enter your RunPod endpoint URL: " runpod_url | |
| print_info "Step 4/4: Deploying API to Railway..." | |
| # Set HANDWRITING_SERVICE_URL | |
| export HANDWRITING_SERVICE_URL=$runpod_url | |
| # Deploy to Railway | |
| if ! command -v railway &> /dev/null; then | |
| print_error "Railway CLI not installed. Installing..." | |
| npm i -g @railway/cli | |
| fi | |
| railway up | |
| print_success "Full deployment complete!" | |
| echo "" | |
| print_info "Next steps:" | |
| print_info "1. Set HANDWRITING_SERVICE_URL in Railway dashboard" | |
| print_info "2. railway variables set HANDWRITING_SERVICE_URL=$runpod_url" | |
| print_info "3. Test: curl https://your-domain.up.railway.app/health" | |
| ;; | |
| 0) | |
| echo "Goodbye!" | |
| exit 0 | |
| ;; | |
| *) | |
| print_error "Invalid option" | |
| exit 1 | |
| ;; | |
| esac | |
| echo "" | |
| print_success "Done!" | |