#!/bin/bash set -e # Google Cloud deployment script for HUMAINE Frontend # Usage: ./deploy-frontend.sh # Configuration PROJECT_ID="prolific-human-feedback" REGION="europe-west1" SERVICE_NAME="humaine-app" IMAGE_NAME="humaine-app" ARTIFACT_REPO_NAME="hfes-repo" echo "🚀 Starting deployment to Google Cloud Run..." # Check if gcloud is installed and authenticated if ! command -v gcloud &> /dev/null; then echo "❌ gcloud CLI is not installed. Please install it first." exit 1 fi # Set the project echo "📋 Setting project to $PROJECT_ID..." gcloud config set project $PROJECT_ID # Create Artifact Registry repository if it doesn't exist echo "📦 Setting up Artifact Registry repository..." gcloud artifacts repositories create $ARTIFACT_REPO_NAME \ --repository-format=docker \ --location=$REGION \ --description="Docker repository for HUMAINE app" \ 2>/dev/null || echo "Repository already exists" # Configure Docker to authenticate with Artifact Registry gcloud auth configure-docker $REGION-docker.pkg.dev # Build and push the Docker image echo "🏗️ Building Docker image..." IMAGE_URL="$REGION-docker.pkg.dev/$PROJECT_ID/$ARTIFACT_REPO_NAME/$IMAGE_NAME:latest" # Build the image using Cloud Build (recommended for Cloud Run) gcloud builds submit --tag $IMAGE_URL \ --service-account=projects/prolific-human-feedback/serviceAccounts/hfes-app-sa@prolific-human-feedback.iam.gserviceaccount.com \ --gcs-log-dir=gs://prolific-human-feedback_cloudbuild . echo "✅ Image built and pushed to $IMAGE_URL" # Deploy to Cloud Run echo "🚀 Deploying to Cloud Run..." gcloud run deploy $SERVICE_NAME \ --image $IMAGE_URL \ --platform managed \ --region $REGION \ --allow-unauthenticated \ --memory 512Mi \ --cpu 1 \ --timeout 300 \ --max-instances 10 \ --service-account hfes-app-sa@prolific-human-feedback.iam.gserviceaccount.com echo "✅ Deployment complete!" # Get the service URL SERVICE_URL=$(gcloud run services describe $SERVICE_NAME --region $REGION --format "value(status.url)") echo "🌐 Service URL: $SERVICE_URL" echo "🎉 Deployment successful! Your app is now running on Cloud Run." echo "💡 Next steps:" echo " - Test your deployment: open $SERVICE_URL" echo " - Check logs: gcloud logs tail --follow --resource-names=$SERVICE_NAME"