| #!/bin/bash |
| |
| |
| |
| |
|
|
| set -e |
|
|
| echo "π DocGenie Deployment Helper" |
| echo "==============================" |
| echo "" |
|
|
| |
| RED='\033[0;31m' |
| GREEN='\033[0;32m' |
| YELLOW='\033[1;33m' |
| NC='\033[0m' |
|
|
| |
| print_success() { |
| echo -e "${GREEN}β $1${NC}" |
| } |
|
|
| print_error() { |
| echo -e "${RED}β $1${NC}" |
| } |
|
|
| print_info() { |
| echo -e "${YELLOW}βΉ $1${NC}" |
| } |
|
|
| |
| echo "Checking prerequisites..." |
|
|
| |
| if ! command -v docker &> /dev/null; then |
| print_error "Docker is not installed. Please install Docker first." |
| exit 1 |
| fi |
| print_success "Docker installed" |
|
|
| |
| if [ ! -f "api/.env" ]; then |
| print_error "api/.env file not found. Please create it first." |
| exit 1 |
| fi |
| print_success "Environment file found" |
|
|
| |
| 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..." |
| |
| |
| 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..." |
| |
| |
| if ! command -v railway &> /dev/null; then |
| print_error "Railway CLI not installed. Installing..." |
| npm i -g @railway/cli |
| fi |
| |
| |
| 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" |
| |
| |
| 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..." |
| |
| |
| 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" |
| |
| |
| 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" |
| |
| |
| 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..." |
| |
| |
| echo "" |
| read -p "Enter your RunPod endpoint URL: " runpod_url |
| |
| print_info "Step 4/4: Deploying API to Railway..." |
| |
| |
| export HANDWRITING_SERVICE_URL=$runpod_url |
| |
| |
| 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!" |
|
|