Daniel Grozdanovic bcd0f8a227
Some checks failed
CI - SharePoint Plugin with SonarQube / Test and SonarQube Analysis (push) Has been cancelled
Initial commit: SharePoint connector and ToothFairyAI integration
2026-02-22 17:58:45 +02:00

55 lines
1.9 KiB
Bash

#!/bin/bash
# SharePoint Connector - AWS ECS Deployment Script
set -e
# Configuration
AWS_REGION="ap-southeast-2"
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
ECR_REPOSITORY="sharepoint-connector"
ECS_CLUSTER="your-cluster-name"
ECS_SERVICE="sharepoint-connector-service"
TASK_FAMILY="sharepoint-connector"
echo "🚀 Deploying SharePoint Connector to AWS ECS"
echo "📍 Region: $AWS_REGION"
echo "🏷️ Account: $AWS_ACCOUNT_ID"
echo ""
# Step 1: Build Docker image
echo "🔨 Building Docker image..."
docker build -t $ECR_REPOSITORY:latest .
# Step 2: Login to ECR
echo "🔐 Logging in to ECR..."
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
# Step 3: Create ECR repository if it doesn't exist
echo "📦 Ensuring ECR repository exists..."
aws ecr describe-repositories --repository-names $ECR_REPOSITORY --region $AWS_REGION 2>/dev/null || \
aws ecr create-repository --repository-name $ECR_REPOSITORY --region $AWS_REGION
# Step 4: Tag and push image
echo "📤 Pushing image to ECR..."
docker tag $ECR_REPOSITORY:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPOSITORY:latest
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPOSITORY:latest
# Step 5: Update task definition
echo "📝 Updating ECS task definition..."
TASK_DEFINITION=$(cat task-definition.json | sed "s/YOUR_ACCOUNT_ID/$AWS_ACCOUNT_ID/g")
aws ecs register-task-definition --cli-input-json "$TASK_DEFINITION" --region $AWS_REGION
# Step 6: Update ECS service
echo "🔄 Updating ECS service..."
aws ecs update-service \
--cluster $ECS_CLUSTER \
--service $ECS_SERVICE \
--task-definition $TASK_FAMILY \
--force-new-deployment \
--region $AWS_REGION
echo ""
echo "✅ Deployment complete!"
echo "📊 Check status: aws ecs describe-services --cluster $ECS_CLUSTER --services $ECS_SERVICE --region $AWS_REGION"