From f22a649b6a8f95c621e8c89a35b0ca79b44c2d0a Mon Sep 17 00:00:00 2001 From: "Moises Lopez - https://www.vauxoo.com/" Date: Thu, 13 Aug 2026 22:45:36 -0600 Subject: [PATCH 1/2] [REF] build.sh: Make odoo UID/GID alignment opt-in via CHOWN_UID_GID `set_odoo_ids` walks the whole filesystem twice with `find / -xdev` in order to re-chown the files left under the previous UID/GID, which makes it the slowest step of the image build. Skip it by default and enable it only when the `CHOWN_UID_GID` flag is defined, the same way `VIM_INSTALL` and `ZSH_INSTALL` work: travisfile2dockerfile --build-env-args CHOWN_UID_GID ... Also run both `find` predicates in a single filesystem traversal using the "," operator, halving the cost when the step is enabled, and return early when the IDs already match. --- README.rst | 16 +++++++++------- src/travis2docker/templates/build.sh | 22 ++++++++++++++++++---- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 45d63ed..8e87e40 100644 --- a/README.rst +++ b/README.rst @@ -96,24 +96,26 @@ from its values as ``DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT``; use ``--docker-image=quay.io/vauxoo/PROJECT:TAG`` to pick the image pushed by the ``build_docker`` pipeline instead. -Optional tools (``--build-env-args``) -===================================== +Optional build steps (``--build-env-args``) +=========================================== -Some development tools are **not** installed by default. They are enabled with -a flag passed as a build environment variable using ``--build-env-args``, which -generates an ``ENV =TRUE`` line in the Dockerfile. If the flag is not -defined, the installation step is skipped. +Some development tools and build steps are **not** enabled by default. They are +enabled with a flag passed as a build environment variable using +``--build-env-args``, which generates an ``ENV =TRUE`` line in the +Dockerfile. If the flag is not defined, the step is skipped. .. list-table:: :widths: 30 70 :header-rows: 1 * - Flag - - Installs + - Enables * - ``VIM_INSTALL`` - vim + spf13-vim, vim-openerp, jedi-vim, wakatime and the pylint_odoo/eslint syntastic configuration * - ``ZSH_INSTALL`` - zsh + oh-my-zsh with the ``odoo-shippable`` theme + * - ``CHOWN_UID_GID`` + - Aligns the odoo user UID/GID to 5410 to match OrchestSH images. Slow: it re-chowns the whole filesystem Example enabling more than one:: diff --git a/src/travis2docker/templates/build.sh b/src/travis2docker/templates/build.sh index 9f59b3a..a52596d 100644 --- a/src/travis2docker/templates/build.sh +++ b/src/travis2docker/templates/build.sh @@ -220,21 +220,35 @@ set_odoo_ids(){ # OrchestSH images (ORCHESTSH=True) use UID/GID 5410 for the odoo user; # older images use 1000/1001. A mismatch causes permission issues when # sharing files across containers, so align both to 5410 when they differ. + if [ -z ${CHOWN_UID_GID+x} ]; + then + echo "CHOWN_UID_GID was not defined. Skipping odoo UID/GID alignment. Use t2d parameter --build-env-args=CHOWN_UID_GID to be autoconfigured." + return 0; + fi CURRENT_UID=$(id -u odoo) CURRENT_GID=$(id -g odoo) NEW_ID=5410 + if [ "${CURRENT_UID}" = "${NEW_ID}" ] && [ "${CURRENT_GID}" = "${NEW_ID}" ]; then + echo "odoo UID/GID already set to ${NEW_ID}. Nothing to do." + return 0; + fi if [ "${CURRENT_GID}" != "${NEW_ID}" ]; then echo "Changing odoo GID from ${CURRENT_GID} to ${NEW_ID}" groupmod -g "${NEW_ID}" odoo - # groupmod does not re-chown any file - find / -xdev -gid "${CURRENT_GID}" -exec chown -h ":${NEW_ID}" {} + 2>/dev/null || true fi if [ "${CURRENT_UID}" != "${NEW_ID}" ]; then echo "Changing odoo UID from ${CURRENT_UID} to ${NEW_ID}" usermod -u "${NEW_ID}" odoo - # usermod only re-chowns files inside the home directory - find / -xdev -uid "${CURRENT_UID}" -exec chown -h "${NEW_ID}" {} + 2>/dev/null || true fi + # groupmod does not re-chown any file and usermod only re-chowns files inside + # the home directory, so the leftovers are re-chowned here. Both predicates are + # evaluated in a single filesystem traversal using the "," operator: walking the + # whole filesystem twice is what makes this step slow. The branch whose ID did + # not change simply re-applies the very same ID, so it is a no-op. + find / -xdev \ + \( -uid "${CURRENT_UID}" -exec chown -h "${NEW_ID}" {} + \) , \ + \( -gid "${CURRENT_GID}" -exec chown -h ":${NEW_ID}" {} + \) \ + 2>/dev/null || true } configure_vim(){ From 4bf62831ddc8b7f1fb88867aec3ec1b4f662f8f8 Mon Sep 17 00:00:00 2001 From: "Moises Lopez - https://www.vauxoo.com/" Date: Thu, 13 Aug 2026 22:49:36 -0600 Subject: [PATCH 2/2] [REF] travis2docker: Apply pre-commit-vauxoo autofixes Migrate the pylint disable comment to the ruff suppression syntax as autofixed by pre-commit-vauxoo 8.3.5 (ODOO047, RUF105, RUF106). --- src/travis2docker/travis2docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/travis2docker/travis2docker.py b/src/travis2docker/travis2docker.py index f42102b..e2a4781 100644 --- a/src/travis2docker/travis2docker.py +++ b/src/travis2docker/travis2docker.py @@ -135,7 +135,7 @@ def copy_path(self, path): if src.is_dir(): try: shutil.copytree(src, dest_path) - except shutil.Error: # pylint: disable=except-pass + except shutil.Error: # ruff: ignore[except-pass] pass # There are permissions errors to copy elif src.is_file(): shutil.copy(src, dest_path)