Created
January 16, 2018 14:27
-
-
Save behconsci/67dc1734ceebf8d64eadf30418899e91 to your computer and use it in GitHub Desktop.
replace the AWS_ACCOUNT_ID with aws-account-id
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
#!/bin/sh | |
git_commit_hash=$1 | |
echo "get new login token ... " | |
$(aws ecr get-login --region eu-central-1 --no-include-email) | |
. stop_local.sh | |
docker images | gawk '{ printf $1" "}; {printf $3" "}; {printf "\n"}; ' > dotmp 2> dotmp | |
old_image_id=`cat dotmp | gawk '$1 ~ AWS_ACCOUNT_ID { printf $2"\n" }; ' | grep -m1 ""` | |
docker rmi -f $old_image_id | |
. start_local.sh | |
docker images | gawk '{ printf $1" "}; {printf $3" "}; {printf "\n"}; ' > dotmp 2> dotmp | |
new_image_id=`cat dotmp | gawk '$1 ~ AWS_ACCOUNT_ID { printf $2"\n" }; ' | grep -m1 ""` | |
docker tag $new_image_id AWS_ACCOUNT_ID.dkr.ecr.eu-central-1.amazonaws.com/yourapp/python-base:latest | |
docker tag $new_image_id AWS_ACCOUNT_ID.dkr.ecr.eu-central-1.amazonaws.com/yourapp/python-base:$git_commit_hash | |
docker push AWS_ACCOUNT_ID.dkr.ecr.eu-central-1.amazonaws.com/yourapp/python-base:latest | |
docker push AWS_ACCOUNT_ID.dkr.ecr.eu-central-1.amazonaws.com/yourapp/python-base:$git_commit_hash | |
echo "NEW IMAGE IS PUSHED TO AWS ECS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
start_local.sh is your shell script to build your docker image
stop_local.sh is your shell script to stop running containers