From ae0e5ec1d6ee63a0ef0de559089bdb6fee98e296 Mon Sep 17 00:00:00 2001 From: Jose Zambudio Bernabeu Date: Mon, 2 May 2022 15:43:14 +0200 Subject: [PATCH] [ADD] undo content of commit 'Tecnativa/doodba/pull/175' we need it --- 14.0.Dockerfile | 1 + 15.0.Dockerfile | 1 + build.d/200-dependencies | 6 +- build.sh | 123 ++++++++++++++++++++++++++++++++++++++ lib/doodbalib/__init__.py | 1 + 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100755 build.sh diff --git a/14.0.Dockerfile b/14.0.Dockerfile index 889cbd5d..24413b53 100644 --- a/14.0.Dockerfile +++ b/14.0.Dockerfile @@ -173,6 +173,7 @@ ONBUILD RUN groupadd -g $GID odoo -o \ ONBUILD ENTRYPOINT ["/opt/odoo/common/entrypoint"] ONBUILD CMD ["/usr/local/bin/odoo"] ONBUILD ARG AGGREGATE=true +ONBUILD ARG AUTO_REQUIREMENTS=false ONBUILD ARG DEFAULT_REPO_PATTERN="https://github.com/OCA/{}.git" ONBUILD ARG DEFAULT_REPO_PATTERN_ODOO="https://github.com/OCA/OCB.git" ONBUILD ARG DEPTH_DEFAULT=1 diff --git a/15.0.Dockerfile b/15.0.Dockerfile index 311f30ec..e06fab05 100644 --- a/15.0.Dockerfile +++ b/15.0.Dockerfile @@ -174,6 +174,7 @@ ONBUILD RUN groupadd -g $GID odoo -o \ ONBUILD ENTRYPOINT ["/opt/odoo/common/entrypoint"] ONBUILD CMD ["/usr/local/bin/odoo"] ONBUILD ARG AGGREGATE=true +ONBUILD ARG AUTO_REQUIREMENTS=false ONBUILD ARG DEFAULT_REPO_PATTERN="https://github.com/OCA/{}.git" ONBUILD ARG DEFAULT_REPO_PATTERN_ODOO="https://github.com/OCA/OCB.git" ONBUILD ARG DEPTH_DEFAULT=1 diff --git a/build.d/200-dependencies b/build.d/200-dependencies index 3a1dab65..89f258a5 100755 --- a/build.d/200-dependencies +++ b/build.d/200-dependencies @@ -5,7 +5,7 @@ from glob import glob from os.path import basename, join, splitext -from doodbalib import CUSTOM_DIR, FILE_APT_BUILD, SRC_DIR +from doodbalib import AUTO_REQUIREMENTS, CUSTOM_DIR, FILE_APT_BUILD, SRC_DIR from doodbalib.installer import INSTALLERS, install, logger # Build dependencies installed before any others @@ -13,6 +13,10 @@ install("apt", FILE_APT_BUILD) for name in INSTALLERS: req_files = [] + if name == "pip" and AUTO_REQUIREMENTS: + req_files += glob(join(SRC_DIR, "*", "requirements.txt")) + # Search also in subdirectories + req_files += glob(join(SRC_DIR, "*", "*", "requirements.txt")) # Normal dependency installation req_files.append(join(CUSTOM_DIR, "dependencies", "%s.txt" % name)) for req_file in req_files: diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..6fbfa2a3 --- /dev/null +++ b/build.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +scriptname=$(basename "$(readlink -nf "${0}")") +scriptpath=$(dirname "$(readlink -e -- "${0}")") + +odoo="" +rebase=0 +github=0 + +print_help() { + cat >&2 <&2 "PARSE_ERROR" + exit 2 +fi +eval set -- "${PARSED}" + +while :; do + case "${1}" in + -o | --odoo) + odoo="${2}" + shift 2 + ;; + -r | --rebase) + rebase=1 + shift + ;; + -g | --github) + github=1 + shift + ;; + -h | --help) + print_help + ;; + --) + shift + break + ;; + *) + echo >&2 "PROGRAMMING_ERROR" + exit 3 + ;; + esac +done + +if [[ ${#} -gt 0 ]]; then + echo >&2 "Positional arguments found:" "${@}" + exit 4 +fi + +if [[ -z "${odoo}" ]]; then + echo >&2 "${scriptname}: Missing '-o/--odoo' argument." + exit 1 +fi + +echo "[INFO] Backup previous image..." +docker pull dockermaster.aurestic.com/nubeaerp/odoo-base:${odoo}.0-onbuild +if [[ $? -eq 0 ]]; then + docker tag \ + dockermaster.aurestic.com/nubeaerp/odoo-base:${odoo}.0-onbuild \ + dockermaster.aurestic.com/nubeaerp/odoo-base:${odoo}.0-onbuild-backup + echo "[INFO] Backup image: dockermaster.aurestic.com/nubeaerp/odoo-base:${odoo}.0-onbuild-backup" +else + echo "[INFO] First time image build..." +fi + +if [[ ${rebase} -eq 1 ]]; then + echo "[INFO] Updating repository..." + git branch -D master-upd + git fetch upstream master:master-upd + git rebase master-upd + git push origin master + if [[ $? -eq 0 ]]; then + echo "[INFO] Repository updated" + else + echo "[ERROR] Repository update failed, manual intervention required" + exit 5 + fi +fi + +echo "[INFO] Building ${odoo}.0-onbuild image..." +docker build \ + -t dockermaster.aurestic.com/nubeaerp/odoo-base:${odoo}.0-onbuild \ + -f ${odoo}.0.Dockerfile . + +if [[ ${rebase} -eq 1 ]]; then + echo "[INFO] reTagging image to ghcr.io/aurestic/odoo-base:${odoo}.0-onbuild" + docker tag \ + dockermaster.aurestic.com/nubeaerp/odoo-base:${odoo}.0-onbuild \ + ghcr.io/aurestic/odoo-base:${odoo}.0-onbuild +fi + +echo "[INFO] Pushing image..." +docker push dockermaster.aurestic.com/nubeaerp/odoo-base:${odoo}.0-onbuild +if [[ ${rebase} -eq 1 ]]; then + docker push ghcr.io/aurestic/odoo-base:${odoo}.0-onbuild +fi + +echo "[INFO] Process end." diff --git a/lib/doodbalib/__init__.py b/lib/doodbalib/__init__.py index 6da810b9..7d84e0f3 100644 --- a/lib/doodbalib/__init__.py +++ b/lib/doodbalib/__init__.py @@ -32,6 +32,7 @@ AUTO_REPOS_YAML = "%s.yaml" % AUTO_REPOS_YAML CLEAN = os.environ.get("CLEAN") == "true" +AUTO_REQUIREMENTS = os.environ.get("AUTO_REQUIREMENTS") == "true" LOG_LEVELS = frozenset({"DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"}) FILE_APT_BUILD = os.path.join(CUSTOM_DIR, "dependencies", "apt_build.txt") PRIVATE = "private"