cf9440005a
- fix typo in --namespace option build-docker-image had a missing '$' in the code that handled the --namespace option. - force builds to kollaglue namespace with 'latest' tag to use the --release flag - build IMAGE after config and options processing to permit overriding PREFIX in .buildconf Change-Id: Icf70b33080ef19643f133f2b6f60087c524bd4fb
105 lines
1.9 KiB
Bash
Executable File
105 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
TOPDIR=$(git rev-parse --show-toplevel)
|
|
|
|
RELEASE_NAMESPACE=kollaglue
|
|
NAMESPACE=kollaglue
|
|
PREFIX=fedora-rdo-
|
|
TAG=$(git rev-parse --short HEAD)
|
|
|
|
usage () {
|
|
cat <<EOF
|
|
$0: usage: $0 [options]
|
|
|
|
Options:
|
|
|
|
--namespace, -n <namespace>
|
|
--tag, -t <tag>
|
|
--push, -p
|
|
--no-cache, -N
|
|
--release
|
|
EOF
|
|
}
|
|
|
|
[ -f ./.buildconf ] && . ./.buildconf
|
|
[ -f $TOPDIR/.buildconf ] && . $TOPDIR/.buildconf
|
|
|
|
ARGS=$(getopt -o 'n:t:pN' -l help,namespace:,push,release,tag:,no-cache -- "$@") || { usage >&2; exit 2; }
|
|
|
|
eval set -- "$ARGS"
|
|
|
|
while :; do
|
|
case "$1" in
|
|
|
|
(--help) usage
|
|
exit 0
|
|
;;
|
|
|
|
(--release) MODE=release
|
|
NAMESPACE=$RELEASE_NAMESPACE
|
|
TAG=latest
|
|
;;
|
|
|
|
(--tag|-t) shift
|
|
TAG="$1"
|
|
;;
|
|
|
|
(--push|-p) PUSH=1
|
|
;;
|
|
|
|
(--no-cache|-N)
|
|
BUILDFLAGS="${BUILDFLAGS} --no-cache"
|
|
;;
|
|
|
|
(--namespace|-n)
|
|
shift
|
|
NAMESPACE="$1"
|
|
;;
|
|
|
|
(--) break
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
done
|
|
|
|
if [ "$NAMESPACE" = "$RELEASE_NAMESPACE" ] \
|
|
&& [ "$TAG" = "latest" ] \
|
|
&& ! [ "$MODE" = "release" ]; then
|
|
|
|
echo "ERROR: use --release to build a release image" >&2
|
|
exit 1
|
|
fi
|
|
|
|
IMAGE="${PREFIX}${PWD##*/}"
|
|
FULLIMAGE="${NAMESPACE}/${IMAGE}${TAG:+:${TAG}}"
|
|
|
|
cat <<EOF
|
|
======================================================================
|
|
$FULLIMAGE
|
|
======================================================================
|
|
|
|
EOF
|
|
|
|
if [ "$MODE" = "release" ]; then
|
|
echo "*** YOU ARE BUILDING A RELEASE IMAGE ***"
|
|
echo
|
|
fi
|
|
|
|
if ! docker build ${BUILDFLAGS} -t "$FULLIMAGE" .; then
|
|
echo "ERROR: failed to build $FULLIMAGE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Built: $FULLIMAGE"
|
|
|
|
if [ "$PUSH" = 1 ]; then
|
|
if ! docker push "$FULLIMAGE"; then
|
|
echo "ERROR: failed to push $FULLIMAGE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Pushed: $FULLIMAGE"
|
|
fi
|