Skip to content
Snippets Groups Projects
Commit 82efd72a5f48 authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

fix docker build copy/clean and cleanup on error too

parent aa6b483722ca
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@
image=$(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', 'image') and c.get('odoo_scripts', 'image')) or '$image_default'")
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'")
docker_module_dir=
pushd $project_home
# Ensureconf
......@@ -17,5 +18,5 @@
# Ensureconf
pushd $project_home
if [ "$ignore_git" = "True" ];
# TODO handle confnest
if [[ -d ".hg" ]];
then
......@@ -21,5 +22,3 @@
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
......@@ -24,4 +23,7 @@
hg cfensureconf || { echo 'hg cfensureconf failed' ; popd ; exit 1; }
fi
popd
# TODO only conditionaly do that
# Conditions could be: detect odoo_modules in Dockerfile.
$here/docker_build_copy
......@@ -27,5 +29,8 @@
$here/docker_build_copy
function clean_on_exit() {
$here/docker_build_clean
}
trap clean_on_exit INT TERM EXIT
docker build --pull=true --rm=true -t $registry/$image $project_home || { echo 'Build failed' ; exit 1; }
......@@ -51,5 +56,4 @@
docker push $registry/$image || { echo 'Push failed' ; exit 1; }
fi
$here/docker_build_clean
popd
......@@ -8,8 +8,8 @@
# TODO add a way to bypass the value, maybe with a key in the setup.cfg file
here=$(dirname $0)
project_home=$(cd $here && cd .. && echo $PWD)
odoo_modules=$(python -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_option('odoo_scripts', 'modules') and c.get('odoo_scripts', 'modules') or '')")
odoo_modules="$(python -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_option('odoo_scripts', 'modules') and ' '.join(c.get('odoo_scripts', 'modules').split()) or '')")"
# Delete odoo modules temp directory
if [[ -n $odoo_modules ]];
then
......@@ -12,7 +12,7 @@
# Delete odoo modules temp directory
if [[ -n $odoo_modules ]];
then
echo rm -rf $project_home/odoo_modules
rm -rf $project_home/odoo_modules
fi
......@@ -10,8 +10,6 @@
project_home=$(cd $here && cd .. && echo $PWD)
odoo_modules="$(python -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_option('odoo_scripts', 'modules') and ' '.join(c.get('odoo_scripts', 'modules').split()) or '')")"
mkdir -p $project_home/odoo_modules
# Copy modules when specified
if [[ -n "$odoo_modules" ]];
then
......@@ -15,6 +13,7 @@
# Copy modules when specified
if [[ -n "$odoo_modules" ]];
then
mkdir -p $project_home/odoo_modules
rsync --delete -C --exclude='.hg*' --exclude='.git*' --links --exclude='*.pyc' -r --times $(eval echo $odoo_modules) $project_home/odoo_modules
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment