#!/bin/zsh # template version 2.7 # TODO add a way to bypass the value, maybe with a key in the setup.cfg file project_home=$(dirname $0)/.. registry=$(python -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_section('odoo_scripts') and c.has_option('odoo_scripts', 'registry') and c.get('odoo_scripts', 'registry')) or 'dockerhub.xcg.io'") image=$(basename $(readlink -f $project_home)) ignore_git=$(python -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_section('odoo_scripts') and c.has_option('odoo_scripts', 'ignore_git') and c.get('odoo_scripts', 'ignore_git')) or 'False'") pushd $project_home # Ensureconf if [ "$ignore_git" = "True" ]; then hg cfensureconf || echo "ignore all cfensureconf errors to bypass bad error code with git repositories" else hg cfensureconf || { echo 'hg cfensureconf failed' ; popd ; exit 1; } fi popd # Grab latest base image ODOO_TYPE=$(python -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_section('odoo_scripts') and c.has_option('odoo_scripts', 'odoo_type') and c.get('odoo_scripts', 'odoo_type')) or 'odoo8'") if [ "$ODOO_TYPE" = "odoo8" ]; then docker pull xcgd/odoo:8.0 || { echo 'Pull failed' ; exit 1; } else docker pull xcgd/odoo:7.0 || { echo 'Pull failed' ; exit 1; } fi docker build -t $registry/$image $project_home || { echo 'Build failed' ; exit 1; } # tip is latest in docker for tag in $(cd $project_home && hg id -t); do if [[ ! -z "$tag" && "tip" != "$tag" ]] then echo "Docker tag with hg tag: $tag" docker tag -f $registry/$image $registry/$image:$tag || { echo 'Tag failed' ; exit 1; } fi done for bookmark in $(cd $project_home && hg id -B); do echo "Docker tag with hg bookmark: $bookmark" docker tag -f $registry/$image $registry/$image:$bookmark || { echo 'Tag failed' ; exit 1; } done echo "Pushing docker image" docker push $registry/$image || { echo 'Push failed' ; exit 1; }