2017-06-01 20:16:19 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-06-01 20:46:42 +00:00
|
|
|
# Parameters:
|
|
|
|
# TAG - The name of the tag to use for publishing in Dockerhub
|
|
|
|
#
|
|
|
|
function deploy_on_dockerhub {
|
2017-06-01 20:35:37 +00:00
|
|
|
echo "======================================="
|
|
|
|
echo "Authelia will be deployed on Dockerhub."
|
|
|
|
echo "======================================="
|
2017-06-01 20:16:19 +00:00
|
|
|
|
2017-06-01 20:46:42 +00:00
|
|
|
TAG=$1
|
2017-06-01 20:22:48 +00:00
|
|
|
IMAGE_NAME=clems4ever/authelia
|
2017-06-01 20:32:35 +00:00
|
|
|
IMAGE_WITH_TAG=$IMAGE_NAME:$TAG
|
2017-06-01 20:22:48 +00:00
|
|
|
|
2017-10-08 14:11:05 +00:00
|
|
|
echo "Logging in to Dockerhub as $DOCKER_USERNAME."
|
|
|
|
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
|
|
|
|
if [ "$?" -ne "0" ];
|
|
|
|
then
|
|
|
|
echo "Logging in to Dockerhub failed.";
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-06-01 20:32:35 +00:00
|
|
|
|
|
|
|
echo "Docker image $IMAGE_WITH_TAG will be deployed on Dockerhub."
|
2017-06-28 13:57:58 +00:00
|
|
|
docker build -t $IMAGE_NAME .
|
2017-06-01 20:32:35 +00:00
|
|
|
docker tag $IMAGE_NAME $IMAGE_WITH_TAG;
|
|
|
|
docker push $IMAGE_WITH_TAG;
|
|
|
|
echo "Docker image deployed successfully."
|
2017-06-01 20:46:42 +00:00
|
|
|
}
|
2017-06-01 20:32:35 +00:00
|
|
|
|
2017-06-01 20:46:42 +00:00
|
|
|
|
|
|
|
if [ "$TRAVIS_BRANCH" == "master" ]; then
|
|
|
|
deploy_on_dockerhub latest
|
|
|
|
elif [ ! -z "$TRAVIS_TAG" ]; then
|
|
|
|
deploy_on_dockerhub $TRAVIS_TAG
|
2017-06-01 20:32:35 +00:00
|
|
|
else
|
|
|
|
echo "Docker image will not be deployed on Dockerhub."
|
2017-06-01 20:16:19 +00:00
|
|
|
fi
|
|
|
|
|