File tree Expand file tree Collapse file tree 1 file changed +56
-12
lines changed Expand file tree Collapse file tree 1 file changed +56
-12
lines changed Original file line number Diff line number Diff line change 1- URL_STRING=" .dkr.ecr.us-east-1.amazonaws.com"
2- CONTAINER_STRING=" chdb"
3- IMAGE_STRING=" latest"
4- ECR_IMAGE_URI=" $AWS_ACCOUNT_ID$URL_STRING /$CONTAINER_STRING :$IMAGE_STRING "
1+ # get flag variables
2+ profile=" default"
3+ region=" us-east-1"
4+ tag=" latest"
5+ no_push=false
6+
7+ while (( "$# " )) ; do
8+ case " $1 " in
9+ --tag)
10+ tag=" $2 "
11+ shift 2
12+ ;;
13+ --region)
14+ region=" $2 "
15+ shift 2
16+ ;;
17+ --profile)
18+ profile=" $2 "
19+ shift 2
20+ ;;
21+ --no-push)
22+ no_push=true
23+ shift
24+ ;;
25+ --)
26+ shift
27+ break
28+ ;;
29+ -* |--* =)
30+ echo " Error: Unsupported flag $1 " >&2
31+ exit 1
32+ ;;
33+ * )
34+ shift
35+ ;;
36+ esac
37+ done
38+
39+
40+ # set variables
41+ AWS_ACCOUNT_ID=$( aws sts get-caller-identity --query Account --output text)
42+ ECR_IMAGE_URI=" $AWS_ACCOUNT_ID .dkr.ecr.$region .amazonaws.com"
43+ IMAGE_NAME=" $ECR_IMAGE_URI /chdb:$tag "
44+
545# log in to ECR
6- aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin " $AWS_ACCOUNT_ID$URL_STRING "
7- # remove previous images to save space
8- docker rmi " $AWS_ACCOUNT_ID$URL_STRING /$CONTAINER_STRING "
9- docker rmi " $CONTAINER_STRING "
46+ aws ecr get-login-password --region $region --profile $profile | \
47+ docker login --username AWS --password-stdin $ECR_IMAGE_URI
48+
49+ # remove existing image
50+ docker rmi $IMAGE_NAME 2> /dev/null || true
51+
1052# build image
11- docker build --tag " $CONTAINER_STRING " .
12- # tag and push to AWS ECR
13- docker tag $CONTAINER_STRING :latest " $ECR_IMAGE_URI "
14- docker push " $ECR_IMAGE_URI "
53+ docker build -t $IMAGE_NAME .
54+
55+ if [ " $no_push " = false ]; then
56+ # push to ECR
57+ docker push $IMAGE_NAME
58+ fi
You can’t perform that action at this time.
0 commit comments