6de2455917
- Added GLOBAL_MARKETS_TITLE to all translation files - Updated footer with 12 markets (4 active + 8 upcoming) - Translated market section to: zh-cn, zh-tw, ja, ko, th, vi, id, ms, hi - Built and deployed to production - CloudFront invalidation: I3RTMXVFDJXWLG3SYX208OP1CC
149 lines
3.7 KiB
Bash
Executable File
149 lines
3.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Deploy VIMS to AWS ECS
|
|
# Uses Fargate for serverless container deployment
|
|
|
|
set -e
|
|
|
|
REGION="eu-north-1"
|
|
PROJECT="vims"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
echo -e "${GREEN}🚀 VIMS AWS Deployment${NC}"
|
|
echo "======================="
|
|
|
|
# Load AWS config
|
|
if [ -f .env.aws ]; then
|
|
source .env.aws
|
|
else
|
|
echo -e "${RED}AWS config not found. Run setup-aws.sh first.${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# Build Docker image
|
|
echo -e "${YELLOW}Building Docker image...${NC}"
|
|
docker build -t ${PROJECT}:latest .
|
|
|
|
# Login to ECR
|
|
echo -e "${YELLOW}Logging in to ECR...${NC}"
|
|
aws ecr get-login-password --region ${REGION} | \
|
|
docker login --username AWS --password-stdin ${ECR_URI}
|
|
|
|
# Tag and push
|
|
echo -e "${YELLOW}Pushing to ECR...${NC}"
|
|
docker tag ${PROJECT}:latest ${ECR_URI}:latest
|
|
docker push ${ECR_URI}:latest
|
|
|
|
echo -e "${GREEN}✓ Image pushed to ${ECR_URI}:latest${NC}"
|
|
|
|
# Create ECS cluster (if not exists)
|
|
echo -e "${YELLOW}Creating ECS cluster...${NC}"
|
|
aws ecs create-cluster \
|
|
--cluster-name ${PROJECT} \
|
|
--region ${REGION} 2>/dev/null || true
|
|
|
|
# Create task definition
|
|
echo -e "${YELLOW}Creating task definition...${NC}"
|
|
cat > /tmp/vims-task.json <<EOF
|
|
{
|
|
"family": "${PROJECT}",
|
|
"networkMode": "awsvpc",
|
|
"requiresCompatibilities": ["FARGATE"],
|
|
"cpu": "2048",
|
|
"memory": "4096",
|
|
"executionRoleArn": "arn:aws:iam::${AWS_ACCOUNT_ID}:role/ecsTaskExecutionRole",
|
|
"taskRoleArn": "arn:aws:iam::${AWS_ACCOUNT_ID}:role/${PROJECT}-task-role",
|
|
"containerDefinitions": [
|
|
{
|
|
"name": "${PROJECT}-api",
|
|
"image": "${ECR_URI}:latest",
|
|
"portMappings": [
|
|
{
|
|
"containerPort": 3450,
|
|
"protocol": "tcp"
|
|
}
|
|
],
|
|
"environment": [
|
|
{
|
|
"name": "NODE_ENV",
|
|
"value": "production"
|
|
},
|
|
{
|
|
"name": "PORT",
|
|
"value": "3450"
|
|
},
|
|
{
|
|
"name": "S3_BUCKET",
|
|
"value": "${S3_BUCKET}"
|
|
}
|
|
],
|
|
"secrets": [
|
|
{
|
|
"name": "DB_PASSWORD",
|
|
"valueFrom": "arn:aws:secretsmanager:${REGION}:${AWS_ACCOUNT_ID}:secret:${PROJECT}/db-password"
|
|
}
|
|
],
|
|
"logConfiguration": {
|
|
"logDriver": "awslogs",
|
|
"options": {
|
|
"awslogs-group": "/ecs/${PROJECT}",
|
|
"awslogs-region": "${REGION}",
|
|
"awslogs-stream-prefix": "ecs"
|
|
}
|
|
},
|
|
"healthCheck": {
|
|
"command": ["CMD-SHELL", "curl -f http://localhost:3450/health || exit 1"],
|
|
"interval": 30,
|
|
"timeout": 5,
|
|
"retries": 3,
|
|
"startPeriod": 60
|
|
}
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
aws ecs register-task-definition \
|
|
--cli-input-json file:///tmp/vims-task.json \
|
|
--region ${REGION}
|
|
|
|
# Create or update service
|
|
echo -e "${YELLOW}Creating ECS service...${NC}"
|
|
aws ecs create-service \
|
|
--cluster ${PROJECT} \
|
|
--service-name ${PROJECT}-api \
|
|
--task-definition ${PROJECT} \
|
|
--desired-count 2 \
|
|
--launch-type FARGATE \
|
|
--network-configuration "awsvpcConfiguration={subnets=[subnet-xxxx],securityGroups=[sg-xxxx],assignPublicIp=ENABLED}" \
|
|
--region ${REGION} 2>/dev/null || \
|
|
aws ecs update-service \
|
|
--cluster ${PROJECT} \
|
|
--service ${PROJECT}-api \
|
|
--task-definition ${PROJECT} \
|
|
--desired-count 2 \
|
|
--region ${REGION}
|
|
|
|
echo -e "${GREEN}✓ ECS service updated${NC}"
|
|
|
|
# Wait for deployment
|
|
echo -e "${YELLOW}Waiting for deployment...${NC}"
|
|
aws ecs wait services-stable \
|
|
--cluster ${PROJECT} \
|
|
--services ${PROJECT}-api \
|
|
--region ${REGION}
|
|
|
|
echo -e "${GREEN}✓ Deployment complete!${NC}"
|
|
|
|
# Get service URL
|
|
echo ""
|
|
echo -e "${GREEN}🎉 VIMS deployed to AWS!${NC}"
|
|
echo ""
|
|
echo "Check service status:"
|
|
echo " aws ecs describe-services --cluster ${PROJECT} --services ${PROJECT}-api"
|