-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-production.sh
More file actions
100 lines (80 loc) · 3.46 KB
/
deploy-production.sh
File metadata and controls
100 lines (80 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# Hatchmark Production Deployment Script
# This script deploys the AWS backend infrastructure to production
set -e # Exit on any error
echo "🚀 Starting Hatchmark Production Deployment..."
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null; then
echo "❌ AWS CLI is not installed. Please install it first."
exit 1
fi
# Check if SAM CLI is installed
if ! command -v sam &> /dev/null; then
echo "❌ SAM CLI is not installed. Please install it first."
exit 1
fi
# Check if Docker is running
if ! docker info &> /dev/null; then
echo "❌ Docker is not running. Please start Docker first."
exit 1
fi
echo "✅ Prerequisites check passed"
# Get AWS Account ID
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
AWS_REGION=$(aws configure get region || echo "us-east-1")
echo "📋 Deployment Details:"
echo " AWS Account ID: $AWS_ACCOUNT_ID"
echo " AWS Region: $AWS_REGION"
echo " Environment: production"
# Navigate to backend directory
cd backend
echo "🔨 Building SAM application..."
sam build --use-container
echo "🚀 Deploying to AWS..."
sam deploy --config-env prod --no-confirm-changeset --no-fail-on-empty-changeset
echo "📦 Getting deployment outputs..."
STACK_NAME="hatchmark-authenticity-service-prod"
# Get the API Gateway URL
API_GATEWAY_URL=$(aws cloudformation describe-stacks \
--stack-name $STACK_NAME \
--query 'Stacks[0].Outputs[?OutputKey==`HttpApiUrl`].OutputValue' \
--output text)
# Get the S3 bucket names
INGESTION_BUCKET=$(aws cloudformation describe-stacks \
--stack-name $STACK_NAME \
--query 'Stacks[0].Outputs[?OutputKey==`IngestionBucketName`].OutputValue' \
--output text)
PROCESSED_BUCKET=$(aws cloudformation describe-stacks \
--stack-name $STACK_NAME \
--query 'Stacks[0].Outputs[?OutputKey==`ProcessedBucketName`].OutputValue' \
--output text)
echo "✅ Deployment completed successfully!"
echo ""
echo "📋 Production Environment Details:"
echo " API Gateway URL: $API_GATEWAY_URL"
echo " Ingestion Bucket: $INGESTION_BUCKET"
echo " Processed Bucket: $PROCESSED_BUCKET"
echo ""
echo "🔧 Next Steps for Vercel:"
echo "1. Go to your Vercel project settings"
echo "2. Add these environment variables:"
echo " NEXT_PUBLIC_API_GATEWAY_URL=$API_GATEWAY_URL"
echo " NEXT_PUBLIC_AWS_REGION=$AWS_REGION"
echo " NEXT_PUBLIC_INGESTION_BUCKET=$INGESTION_BUCKET"
echo " NEXT_PUBLIC_PROCESSED_BUCKET=$PROCESSED_BUCKET"
echo ""
echo "3. Redeploy your Vercel application to pick up the new environment variables"
echo ""
echo "🎉 Your Hatchmark backend is now live in production!"
# Create ECR repository if it doesn't exist
echo "🐳 Setting up ECR repository for watermarker..."
aws ecr describe-repositories --repository-names hatchmark-watermarker 2>/dev/null || \
aws ecr create-repository --repository-name hatchmark-watermarker --image-scanning-configuration scanOnPush=true
echo "📝 ECR Repository Commands (run these to deploy the watermarker):"
echo "aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com"
echo "cd ../watermarker"
echo "docker build -t hatchmark-watermarker ."
echo "docker tag hatchmark-watermarker:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/hatchmark-watermarker:latest"
echo "docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/hatchmark-watermarker:latest"
cd ..
echo "🏁 Production deployment script completed!"