Last active
July 19, 2018 17:00
-
-
Save jmervine/b1835fa3bfcea9eaa9bf2521291f0615 to your computer and use it in GitHub Desktop.
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
# Simply ensure repo and return url | |
aws ecr create-repository --repository-name $1 2>/dev/null || true | |
echo "$(aws ecr describe-repositories --repository-name $1 | jq '.repositories[0].repositoryUri')" |
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
# .bashrc | |
# usage: exec helper -- emulates `set -x` | |
# $ __x "command" | |
function __x { | |
echo "+ $1" | |
$1 | |
} | |
# usage: for first run | |
# $ ecr_init hello-world:latest | |
function ecr_init { | |
local image=$1 | |
local repo=$(echo "${image}" | awk -F':' '{ print $1 }') | |
local tag=$(echo "${image}" | awk -F':' '{ print $2 }') | |
local repo_url=$(aws ecr create-repository --repository-name ${repo} | jq '.repository.repositoryUri') | |
# not sure if it's a good idea to include login here, but am for now, feel free to comment this out and run manually | |
eval $(aws ecr get-login --no-include-email) | |
__x "docker tag ${image} ${repo_url}:${tag}" | |
__x "docker push ${repo_url}:${tag}" | |
} | |
# usage: for updates | |
# $ ecr_push hello-world:latest | |
function ecr_push { | |
local image=$1 | |
local tag=$(echo "${image}" | awk -F':' '{ print $2 }') | |
local repo_url=$(aws ecr describe-repositories | jq '.repositories[] | select('.repositoryName' == "$image") | .repositoryUri') | |
# not sure if it's a good idea to include login here, but am for now, feel free to comment this out and run manually | |
eval $(aws ecr get-login --no-include-email) | |
__x "docker tag ${image} ${repo_url}:${tag}" | |
__x "docker push ${repo_url}:${tag}" | |
} |
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
# another, simpler way | |
# usage: for updates | |
# $ ecr_push hello-world:latest | |
function ecr { | |
local image=$1 | |
local tag=$(echo "${image}" | awk -F':' '{ print $2 }') | |
aws ecr create-repository --repository-name ${image} 2>/dev/null || true | |
local repo_url=$(aws ecr describe-repositories --repository-name ${image} | jq '.repositories[0].repositoryUri') | |
# not sure if it's a good idea to include login here, but am for now, feel free to comment this out and run manually | |
eval $(aws ecr get-login --no-include-email) | |
__x "docker tag ${image} ${repo_url}:${tag}" | |
__x "docker push ${repo_url}:${tag}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment