-
-
Save jamtur01/ba2b937c200356959ad961850eb5fdd0 to your computer and use it in GitHub Desktop.
AWS ecs deployment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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