Newer
Older
# TODO add a way to bypass the value, maybe with a key in the setup.cfg file
project_home=$(dirname $0)/..

Vincent Hatakeyama
committed
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))

Vincent Hatakeyama
committed
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'")

Vincent Hatakeyama
committed
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; }

Vincent Hatakeyama
committed
fi
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

Vincent Hatakeyama
committed
docker build -t $registry/$image $project_home || { echo 'Build failed' ; exit 1; }
Etienne Ferriere
committed
for tag in $(cd $project_home && hg id -t);
do
if [[ ! -z "$tag" && "tip" != "$tag" ]]
then
echo "Docker tag with hg tag: $tag"

Vincent Hatakeyama
committed
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"

Vincent Hatakeyama
committed
docker tag -f $registry/$image $registry/$image:$bookmark || { echo 'Tag failed' ; exit 1; }

Vincent Hatakeyama
committed
docker push $registry/$image || { echo 'Push failed' ; exit 1; }