Quick Start: Deploy Phishing Detection API to GCP
Prerequisites Checklist
- Google Cloud Platform account with billing enabled
- gcloud CLI installed and authenticated (
gcloud auth login) - Docker installed and running
- GROQ API key (get from https://console.groq.com/)
Fastest Deployment (One Command)
For Linux/Mac:
chmod +x deploy.sh
./deploy.sh YOUR_PROJECT_ID us-central1
For Windows PowerShell:
.\deploy.ps1 -ProjectId YOUR_PROJECT_ID -Region us-central1
Replace YOUR_PROJECT_ID with your actual GCP project ID.
The script will:
- β Enable required GCP APIs
- β Create GROQ_API_KEY secret
- β Build Docker image
- β Deploy to Cloud Run
- β Display your service URL
Manual Deployment Steps
If you prefer manual steps, see DEPLOYMENT.md for detailed instructions.
Files Created for Deployment
- Dockerfile - Container configuration for the application
- .dockerignore - Files to exclude from Docker build
- cloudbuild.yaml - GCP Cloud Build configuration
- deploy.sh - Automated deployment script (Linux/Mac)
- deploy.ps1 - Automated deployment script (Windows)
- docker-compose.yml - For local testing with Docker
- DEPLOYMENT.md - Comprehensive deployment guide
Testing Locally First (Optional)
Before deploying to GCP, test locally:
# Build the image
docker build -t phishing-api:local .
# Run locally
docker run -p 8000:8000 \
-e GROQ_API_KEY=your-api-key \
phishing-api:local
# Test in another terminal
curl http://localhost:8000/health
Or use Docker Compose:
# Set your API key in environment
export GROQ_API_KEY=your-api-key # Linux/Mac
# or
$env:GROQ_API_KEY="your-api-key" # Windows PowerShell
# Run
docker-compose up
After Deployment
Your service will be available at:
- API:
https://phishing-detection-api-[hash]-uc.a.run.app - Health Check:
https://phishing-detection-api-[hash]-uc.a.run.app/health - API Docs:
https://phishing-detection-api-[hash]-uc.a.run.app/docs
Quick Test
# Get your service URL
SERVICE_URL=$(gcloud run services describe phishing-detection-api \
--region us-central1 \
--format="value(status.url)")
# Test health endpoint
curl $SERVICE_URL/health
# Test prediction endpoint
curl -X POST "$SERVICE_URL/predict" \
-H "Content-Type: application/json" \
-d '{
"sender": "test@example.com",
"subject": "Urgent Action Required",
"text": "Please verify your account at http://suspicious-site.com",
"metadata": {}
}'
Troubleshooting
- Build fails: Check that all model files are in the correct directories
- Service won't start: Check logs with
gcloud run services logs read phishing-detection-api --region us-central1 - GROQ API errors: Verify secret is set correctly:
gcloud secrets versions access latest --secret="GROQ_API_KEY" - Memory issues: Increase memory in cloudbuild.yaml or deployment command
For detailed troubleshooting, see DEPLOYMENT.md.
Next Steps
- Monitor your service in Cloud Run Console
- Set up alerts in Cloud Monitoring
- Review API documentation at
/docsendpoint - Scale resources if needed (see DEPLOYMENT.md)
Support
For issues:
- Check logs:
gcloud run services logs read phishing-detection-api --region us-central1 - Review DEPLOYMENT.md for detailed information
- Verify all prerequisites are met