Initial support for taggable dependencies

Introduce a new --no-use-released-parent option to `build-docker-image`
that allows specifying whether the parent image uses the same tag as
the one that's currently build or the release tag.

Default is to use the release tag for parent image, however
`build-all-docker-images` script forces it to be the current tag.

Change to Dockerfile is coming next.

Change-Id: Ief11c9abb722c181ca85f38ee11800dbf4332a5f
This commit is contained in:
Martin André 2015-05-05 12:33:37 +09:00
parent 844d710a48
commit 047683d12c
2 changed files with 19 additions and 5 deletions

View File

@ -27,7 +27,7 @@ function warn {
} }
function set_defaults { function set_defaults {
PREFIX=fedora-rdo- PREFIX=centos-rdo-
NAMESPACE=kollaglue NAMESPACE=kollaglue
} }
@ -56,7 +56,7 @@ function build_image {
if [ -x "$dir/build" ]; then if [ -x "$dir/build" ]; then
printf "\n" printf "\n"
info "Building image in $dir" info "Building image in $dir"
if $dir/build $ARGS; then if $dir/build $ARGS --no-use-released-parent; then
success "Successfully built image in $dir" success "Successfully built image in $dir"
status[$image]="rebuilt" status[$image]="rebuilt"
else else
@ -78,6 +78,7 @@ function init_image {
local base_image=$(cat $img_dir/Dockerfile | gawk 'match($0, /^\s*FROM\s+(\S+)/, matches) {print matches[1]}' ) local base_image=$(cat $img_dir/Dockerfile | gawk 'match($0, /^\s*FROM\s+(\S+)/, matches) {print matches[1]}' )
base_image=${base_image//%%KOLLA_NAMESPACE%%/$NAMESPACE} base_image=${base_image//%%KOLLA_NAMESPACE%%/$NAMESPACE}
base_image=${base_image//%%KOLLA_PREFIX%%/$PREFIX} base_image=${base_image//%%KOLLA_PREFIX%%/$PREFIX}
base_image=${base_image//:%%KOLLA_TAG%%/}
img_dirs[$image]=$img_dir img_dirs[$image]=$img_dir
dependency[$image]=$base_image dependency[$image]=$base_image

View File

@ -7,6 +7,7 @@ RELEASE_NAMESPACE=kollaglue
NAMESPACE=kollaglue NAMESPACE=kollaglue
PREFIX=centos-rdo- PREFIX=centos-rdo-
TAG=$(git rev-parse --short HEAD) TAG=$(git rev-parse --short HEAD)
RELEASE_TAG=icehouse
usage () { usage () {
cat <<EOF cat <<EOF
@ -19,13 +20,14 @@ Options:
--push, -p --push, -p
--no-cache, -N --no-cache, -N
--release --release
--no-use-released-parent
EOF EOF
} }
[ -f $TOPDIR/.buildconf ] && . $TOPDIR/.buildconf [ -f $TOPDIR/.buildconf ] && . $TOPDIR/.buildconf
[ -f $IMGDIR/.buildconf ] && . $IMGDIR/.buildconf [ -f $IMGDIR/.buildconf ] && . $IMGDIR/.buildconf
ARGS=$(getopt -o hn:t:pN -l help,namespace:,push,release,tag:,no-cache -- "$@") || { usage >&2; exit 2; } ARGS=$(getopt -o hn:t:pN -l help,namespace:,push,release,tag:,no-cache,no-use-released-parent -- "$@") || { usage >&2; exit 2; }
eval set -- "$ARGS" eval set -- "$ARGS"
@ -38,7 +40,7 @@ while :; do
(--release) MODE=release (--release) MODE=release
NAMESPACE=$RELEASE_NAMESPACE NAMESPACE=$RELEASE_NAMESPACE
TAG=latest TAG=$RELEASE_TAG
;; ;;
(--tag|-t) shift (--tag|-t) shift
@ -57,6 +59,10 @@ while :; do
NAMESPACE="$1" NAMESPACE="$1"
;; ;;
(--no-use-released-parent)
USE_CURRENT_TAG=1
;;
(--) break (--) break
;; ;;
@ -65,8 +71,14 @@ while :; do
shift shift
done done
if [[ $USE_CURRENT_TAG = 1 ]]; then
PARENT_TAG=$TAG
else
PARENT_TAG=$RELEASE_TAG
fi
if [ "$NAMESPACE" = "$RELEASE_NAMESPACE" ] \ if [ "$NAMESPACE" = "$RELEASE_NAMESPACE" ] \
&& [ "$TAG" = "latest" ] \ && [ "$TAG" = "$RELEASE_TAG" ] \
&& ! [ "$MODE" = "release" ]; then && ! [ "$MODE" = "release" ]; then
echo "ERROR: use --release to build a release image" >&2 echo "ERROR: use --release to build a release image" >&2
@ -94,6 +106,7 @@ cp -aL $IMGDIR/* $TMPDIR
# versions of sed behave differently otherwise # versions of sed behave differently otherwise
sed -i.bak "s/%%KOLLA_NAMESPACE%%/${NAMESPACE}/g" $TMPDIR/Dockerfile sed -i.bak "s/%%KOLLA_NAMESPACE%%/${NAMESPACE}/g" $TMPDIR/Dockerfile
sed -i.bak "s/%%KOLLA_PREFIX%%/${PREFIX}/g" $TMPDIR/Dockerfile sed -i.bak "s/%%KOLLA_PREFIX%%/${PREFIX}/g" $TMPDIR/Dockerfile
sed -i.bak "s/%%KOLLA_TAG%%/${PARENT_TAG}/g" $TMPDIR/Dockerfile
if ! docker build ${BUILDFLAGS} -t "$FULLIMAGE" $TMPDIR; then if ! docker build ${BUILDFLAGS} -t "$FULLIMAGE" $TMPDIR; then
echo "ERROR: failed to build $FULLIMAGE" echo "ERROR: failed to build $FULLIMAGE"