Skip to content

Instantly share code, notes, and snippets.

@jamtur01
Forked from chethanbandi/aws-ecs-deploy.sh
Created February 11, 2017 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamtur01/ba2b937c200356959ad961850eb5fdd0 to your computer and use it in GitHub Desktop.
Save jamtur01/ba2b937c200356959ad961850eb5fdd0 to your computer and use it in GitHub Desktop.
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