Created
April 5, 2020 10:26
-
-
Save hades2510/2d94a7f7a795cbac8751708ad1994279 to your computer and use it in GitHub Desktop.
Helper script for pushing a Docker image to ECR
This file contains 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/bash | |
function push_it { | |
docker tag $DOCKER_IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$AWS_ECR_NAME | |
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$AWS_ECR_NAME | |
} | |
function usage { | |
echo "Usage: $0 -t <docker_image_tag> -a <aws_account_id> -r <aws_region> -n <erc_repo_name>" | |
exit 1; | |
} | |
while getopts ":h:t:a:r:n:" opt; do | |
case "${opt}" in | |
t) DOCKER_IMAGE_TAG=${OPTARG};; | |
a) AWS_ACCOUNT_ID=${OPTARG};; | |
r) AWS_REGION=${OPTARG};; | |
n) AWS_ECR_NAME=${OPTARG};; | |
*) | |
usage | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
if [ -z "${DOCKER_IMAGE_TAG}" ] || [ -z "${AWS_ACCOUNT_ID}" ] || [ -z "${AWS_REGION}" ] || [ -z "${AWS_ECR_NAME}" ];then | |
usage | |
fi | |
#all good | |
push_it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment