-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-docker.sh
More file actions
50 lines (41 loc) Β· 1.65 KB
/
deploy-docker.sh
File metadata and controls
50 lines (41 loc) Β· 1.65 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
#!/bin/bash
# Docker deployment script for AWS App Runner
# Configuration
AWS_REGION="ap-southeast-2"
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text 2>/dev/null)
ECR_REPOSITORY="permit-api"
IMAGE_TAG="latest"
echo "π Building and deploying Permit API to AWS App Runner via ECR"
echo "Region: $AWS_REGION"
echo "Account: $AWS_ACCOUNT_ID"
echo "Repository: $ECR_REPOSITORY"
# Check if AWS CLI is configured
if [ -z "$AWS_ACCOUNT_ID" ]; then
echo "β AWS CLI not configured or not authenticated"
echo "Please run: aws configure"
exit 1
fi
# Create ECR repository if it doesn't exist
echo "π¦ Creating ECR repository..."
aws ecr describe-repositories --repository-names $ECR_REPOSITORY --region $AWS_REGION >/dev/null 2>&1 || \
aws ecr create-repository --repository-name $ECR_REPOSITORY --region $AWS_REGION
# Get ECR login token
echo "π Authenticating Docker with ECR..."
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
# Build Docker image
echo "π¨ Building Docker image..."
docker build -f Dockerfile.apprunner -t $ECR_REPOSITORY:$IMAGE_TAG .
# Tag image for ECR
ECR_URI="$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPOSITORY:$IMAGE_TAG"
docker tag $ECR_REPOSITORY:$IMAGE_TAG $ECR_URI
# Push to ECR
echo "π€ Pushing image to ECR..."
docker push $ECR_URI
echo "β
Docker image pushed successfully!"
echo "ECR URI: $ECR_URI"
echo ""
echo "Next steps:"
echo "1. Go to AWS App Runner console"
echo "2. Choose 'Container registry' as source"
echo "3. Use this image URI: $ECR_URI"
echo "4. Configure service settings"