[REF] build.sh: Make odoo UID/GID alignment opt-in via CHOWN_UID_GID - #242
Conversation
`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.
Migrate the pylint disable comment to the ruff suppression syntax as autofixed by pre-commit-vauxoo 8.3.5 (ODOO047, RUF105, RUF106).
|
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. |
|
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 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.0Also, 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. |
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:Since then, this is by far the slowest step of the image build, and it runs unconditionally as the very first step of the
RUNinDockerfile_deployv.Changes
Opt-in flag
CHOWN_UID_GID, following the same pattern asVIM_INSTALL/ZSH_INSTALL: if the flag is not defined the step is skipped, so the default build no longer pays for it.The function returns
0when skipping, so theset_odoo_ids && install_dev_tools && ...chain in the Dockerfile is untouched.Single filesystem traversal when the step is enabled: both predicates are evaluated in one
findrun 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).Early return when the UID and GID already are 5410, avoiding the filesystem walk on images that are already aligned.
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-slimwithodoocreated as 1000:1001 and files owned asodoo:odoo,odoo:root,root:odooandroot:root:CHOWN_UID_GIDCHOWN_UID_GID=TRUE5410:5410,5410:0,0:5410,0:0(unchanged semantics)odoo UID/GID already set to 5410. Nothing to do.tox -e py313passing (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_GIDfrom now on.