65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Deployment script for MOTM Flask application to Google App Engine.
|
|
"""
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
def deploy_to_app_engine():
|
|
"""Deploy the MOTM application to Google App Engine."""
|
|
|
|
print("🚀 Starting deployment to Google App Engine...")
|
|
|
|
# Check if gcloud is installed
|
|
try:
|
|
subprocess.run(['gcloud', '--version'], check=True, capture_output=True)
|
|
print("✓ Google Cloud SDK is installed")
|
|
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
print("❌ Google Cloud SDK not found. Please install it first:")
|
|
print(" https://cloud.google.com/sdk/docs/install")
|
|
return False
|
|
|
|
# Check if user is authenticated
|
|
try:
|
|
subprocess.run(['gcloud', 'auth', 'list', '--filter=status:ACTIVE'], check=True, capture_output=True)
|
|
print("✓ Google Cloud authentication verified")
|
|
except subprocess.CalledProcessError:
|
|
print("❌ Not authenticated with Google Cloud. Run 'gcloud auth login' first")
|
|
return False
|
|
|
|
# Check if app.yaml exists
|
|
if not os.path.exists('app.yaml'):
|
|
print("❌ app.yaml not found in current directory")
|
|
return False
|
|
|
|
print("✓ app.yaml found")
|
|
|
|
# Deploy the application
|
|
try:
|
|
print("📦 Deploying application...")
|
|
result = subprocess.run(['gcloud', 'app', 'deploy'], check=True)
|
|
print("✅ Deployment completed successfully!")
|
|
return True
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"❌ Deployment failed: {e}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) > 1 and sys.argv[1] == '--deploy':
|
|
success = deploy_to_app_engine()
|
|
sys.exit(0 if success else 1)
|
|
else:
|
|
print("MOTM Application Deployment Script")
|
|
print("=================================")
|
|
print()
|
|
print("Usage:")
|
|
print(" python deploy.py --deploy # Deploy to Google App Engine")
|
|
print()
|
|
print("Prerequisites:")
|
|
print(" 1. Install Google Cloud SDK")
|
|
print(" 2. Run 'gcloud auth login'")
|
|
print(" 3. Set your project: 'gcloud config set project YOUR_PROJECT_ID'")
|
|
print(" 4. Ensure app.yaml is configured correctly")
|