@@ -60,11 +60,37 @@ TAG=${TAG:-latest}
6060read -p " Enter AWS region (default: us-east-1): " AWS_REGION
6161AWS_REGION=${AWS_REGION:- us-east-1}
6262
63+ # Get deployment type
64+ echo " "
65+ echo " Select deployment type:"
66+ echo " 1) AppRunner (default) - uses amd64 architecture"
67+ echo " 2) Lambda - uses arm64 architecture"
68+ read -p " Enter deployment type (1 or 2, default: 1): " DEPLOY_TYPE
69+ DEPLOY_TYPE=${DEPLOY_TYPE:- 1}
70+
71+ # Determine architecture based on deployment type
72+ case $DEPLOY_TYPE in
73+ 1)
74+ DEPLOY_TYPE_NAME=" AppRunner"
75+ ARCH=" amd64"
76+ ;;
77+ 2)
78+ DEPLOY_TYPE_NAME=" Lambda"
79+ ARCH=" arm64"
80+ ;;
81+ * )
82+ echo " ❌ ERROR: Invalid deployment type. Please enter 1 or 2."
83+ exit 1
84+ ;;
85+ esac
86+
6387echo " "
6488echo " Configuration:"
6589echo " Repository: $REPO_NAME "
6690echo " Image Tag: $TAG "
6791echo " AWS Region: $AWS_REGION "
92+ echo " Deployment Type: $DEPLOY_TYPE_NAME "
93+ echo " Architecture: $ARCH "
6894echo " "
6995read -p " Continue with these settings? (y/n): " CONFIRM
7096if [[ ! " $CONFIRM " =~ ^[Yy]$ ]]; then
@@ -96,8 +122,8 @@ build_and_push_image() {
96122 local IMAGE_NAME=$1
97123 local TAG=$2
98124 local DOCKERFILE_PATH=$3
125+ local BUILD_ARCH=$4
99126 local REGION=$AWS_REGION
100- local ARCH=" amd64" # Single architecture for simplicity
101127
102128 echo " Logging in to AWS Public ECR..."
103129 # Log in to AWS Public ECR for pulling base images
@@ -106,10 +132,10 @@ build_and_push_image() {
106132 exit 1
107133 fi
108134
109- echo " Building $IMAGE_NAME :$TAG ..."
135+ echo " Building $IMAGE_NAME :$TAG for linux/ $BUILD_ARCH ..."
110136
111137 # Build Docker image
112- if ! docker buildx build --platform linux/$ARCH -t $IMAGE_NAME :$TAG -f $DOCKERFILE_PATH --load ../src/; then
138+ if ! docker buildx build --platform linux/$BUILD_ARCH -t $IMAGE_NAME :$TAG -f $DOCKERFILE_PATH --load ../src/; then
113139 echo " ❌ ERROR: Failed to build Docker image."
114140 exit 1
115141 fi
@@ -157,7 +183,7 @@ build_and_push_image() {
157183}
158184
159185echo " Building and pushing SwiftChat image..."
160- IMAGE_URI=$( build_and_push_image " $REPO_NAME " " $TAG " " ../src/Dockerfile" )
186+ IMAGE_URI=$( build_and_push_image " $REPO_NAME " " $TAG " " ../src/Dockerfile" " $ARCH " )
161187
162188echo " ================================================"
163189echo " ✅ Image successfully pushed!"
0 commit comments