Skip to content

[REF] build.sh: Make odoo UID/GID alignment opt-in via CHOWN_UID_GID - #242

Merged
moylop260 merged 2 commits into
Vauxoo:mainfrom
vauxoo-dev:main-chown-uid-gid-optional-moy
Aug 19, 2026
Merged

[REF] build.sh: Make odoo UID/GID alignment opt-in via CHOWN_UID_GID#242
moylop260 merged 2 commits into
Vauxoo:mainfrom
vauxoo-dev:main-chown-uid-gid-optional-moy

Conversation

@moylop260

Copy link
Copy Markdown
Collaborator

Context

set_odoo_ids, added in #236 by @luisg123v, aligns the odoo user UID/GID to 5410 to match OrchestSH images. To do it, it walks the whole filesystem twice:

find / -xdev -gid "${CURRENT_GID}" -exec chown -h ":${NEW_ID}" {} +
find / -xdev -uid "${CURRENT_UID}" -exec chown -h "${NEW_ID}" {} +

Since then, this is by far the slowest step of the image build, and it runs unconditionally as the very first step of the RUN in Dockerfile_deployv.

Changes

  1. Opt-in flag CHOWN_UID_GID, following the same pattern as VIM_INSTALL / ZSH_INSTALL: if the flag is not defined the step is skipped, so the default build no longer pays for it.

    travisfile2dockerfile --build-env-args CHOWN_UID_GID git@github.com:Vauxoo/forecast.git 16.0

    The function returns 0 when skipping, so the set_odoo_ids && install_dev_tools && ... chain in the Dockerfile is untouched.

  2. Single filesystem traversal when the step is enabled: both predicates are evaluated in one find run using the , operator, instead of two full walks. Each branch keeps its own -exec chown, so the per-file semantics of [IMP] build.sh: Align odoo UID/GID to 5410 to match OrchestSH images #236 are preserved exactly (a file matching only by UID does not get its group rewritten, and vice versa).

  3. Early return when the UID and GID already are 5410, avoiding the filesystem walk on images that are already aligned.

  4. README: documented the new flag and renamed the section to Optional build steps, since the table is no longer only about installed tools.

Testing

Functional check on debian:bookworm-slim with odoo created as 1000:1001 and files owned as odoo:odoo, odoo:root, root:odoo and root:root:

scenario result
without CHOWN_UID_GID skipped, ids stay 1000/1001
with CHOWN_UID_GID=TRUE ids become 5410/5410; ownership → 5410:5410, 5410:0, 0:5410, 0:0 (unchanged semantics)
run again odoo UID/GID already set to 5410. Nothing to do.

tox -e py313 passing (5 tests).

@luisg123v could you review, please? Since this changes the default behavior, images that rely on the 5410 alignment will need --build-env-args CHOWN_UID_GID from now on.

`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.
@moylop260
moylop260 requested a review from luisg123v August 14, 2026 04:48
Migrate the pylint disable comment to the ruff suppression syntax as
autofixed by pre-commit-vauxoo 8.3.5 (ODOO047, RUF105, RUF106).
@moylop260
moylop260 merged commit d3c1fc6 into Vauxoo:main Aug 19, 2026
20 checks passed
@moylop260
moylop260 deleted the main-chown-uid-gid-optional-moy branch August 19, 2026 17:02
@luisg123v

Copy link
Copy Markdown
Contributor

For the record, I don't agree with these changes. The step is kind of heavy, but it applies only in old repos. Without it, any newly creater container will screw up permissions on any shared file.

@moylop260

Copy link
Copy Markdown
Collaborator Author

Fair enough, and thanks for stating it on the record — let me explain the reasoning behind the change.

I have not hit any permission error caused by this so far. What I did hit is that my builds started getting noticeably slower, and there was no way to turn the step off: it ran unconditionally as the very first thing in the RUN, walking the whole filesystem twice on every single build, to protect against a problem I had not run into.

And if/when it does show up on my side, I now have the flexibility to turn it back on with a documented flag:

travisfile2dockerfile --build-env-args CHOWN_UID_GID git@github.com:Vauxoo/forecast.git 16.0

Also, anyone who wants it always enabled can just put it in their own alias:

alias t2d='travisfile2dockerfile --build-env-args CHOWN_UID_GID'

So the behavior is not gone — it is documented in the README and one flag away; it is just no longer something everybody pays for on every build by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants