Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AWS ecs deployment
NAME=server
ECR=<repo_url>
VERSION=${BUILD_NUMBER}
TAG=${ECR}/${NAME}:${VERSION}
eval $(aws ecr get-login)
docker build -t $TAG .
if[ $? -ne 0 ];then
echo "Docker build failed exiting"
exit 1
fi
docker push $TAG
CONTAINER_DEF="[{\"name\":\"server\",\"memory\":3354,\"cpu\":2047,\"image\":\"${TAG}\",\"portMappings\":[{\"hostPort\":80,\"containerPort\":5000,\"protocol\":\"tcp\"}]}]"
taskVersion=$(aws ecs register-task-definition --family adzai --container-definitions $CONTAINER_DEF | grep "revision" | tr -c -d '[[:digit:]]')
aws ecs update-service --cluster cluster1 --service server --task-definition task1:${taskVersion}
aws ecs deregister-task-definition --task-definition task1:$(expr $taskVersion - 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment