Created
November 17, 2018 18:54
-
-
Save jtemporal/ec0110c3d51733eb1db27beec36bfd79 to your computer and use it in GitHub Desktop.
script automatizador de deploy de imagens docker para o docker hub
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/bash | |
if [ -z ${DOCKER_USERNAME} ]; then | |
echo "Missing DOCKER_USERNAME variable!" | |
exit 1 | |
fi | |
error() { | |
if [ $? != 0 ]; then | |
echo "Error!" | |
exit 122 | |
fi | |
} | |
build() { | |
echo "=> Building ${1}" | |
docker build -t ${1} . | |
echo "=> Built ${1}" | |
} | |
tag() { | |
echo "=> Tagging ${1}" | |
docker tag ${1} $(echo $DOCKER_USERNAME)/${1} | |
echo "=> Tagged ${1}" | |
} | |
push() { | |
echo "=> Pushing ${1}" | |
docker push $(echo $DOCKER_USERNAME)/${1} | |
echo "=> Pushed ${1}" | |
} | |
build ${1} | |
error | |
tag ${1} | |
error | |
push ${1} | |
error | |
echo | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment