This repository has been archived on 2022-08-17. You can view files and clone it, but cannot push or open issues or pull requests.
dex/build-docker

42 lines
994 B
Text
Raw Normal View History

#!/bin/bash -e
#
# Build the docker container and push it to quay
# ./build-docker push
#
# Build the docker container locally without pushing to registry
# ./build-docker build
DOCKER_REGISTRY=${DOCKER_REGISTRY:=quay.io}
DOCKER_REPO=${DOCKER_REPO:=coreos/dex}
repo=$DOCKER_REGISTRY/$DOCKER_REPO
version=$(./git-version)
stage() {
echo -e "\033[36m----> $1\033[0m"
}
build() {
stage "build $repo:$version"
docker build -q --rm=true -t $repo:$version .
docker tag $repo:$version $repo:latest
}
push() {
stage "push image $repo:$version"
if [ -v $DOCKER_USER ] || [ -v $DOCKER_PASSWORD ]; then
echo "env variables not set: DOCKER_USER, DOCKER_PASSWORD. skipping login, assuming creds in .dockercfg"
else
echo logging in as $DOCKER_USER
docker login --username="$DOCKER_USER" --password="$DOCKER_PASSWORD" --email="dex@example.com" $DOCKER_REGISTRY
fi
docker push $repo:$version
docker push $repo:latest
}
2016-06-29 02:05:41 +05:30
build
if [[ "push" == "$1" ]]; then
push
fi