deploy-with-circleci-jira-ecr-ecs-s3-LB / server / script.sh
script.sh
Raw
#!/usr/bin/env sh

set -e

REGION="us-east-1"
ECR_URL="759907441676.dkr.ecr.us-east-1.amazonaws.com"
REPO_NAME="fastapi-backend"
REPO_URL=$ECR_URL/$REPO_NAME
#BUILD_NUMBER="${BUILD_NUMBER:-$(date +%s)}"
BUILD_NUMBER=$1

echo "Building $BUILD_NUMBER" 

# log docker into ecr using aws cli
#$(aws ecr get-login --no-include-email --region $REGION)
aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $ECR_URL

# build a docker image with a unique build number
docker build -t $REPO_URL:$BUILD_NUMBER .

# push to ecr
docker push $REPO_URL:$BUILD_NUMBER

#tag for "latest" and also push that
docker tag $REPO_URL:$BUILD_NUMBER $REPO_URL:latest
docker push $REPO_URL:latest