Repository navigation
[FIX] build.sh: Run pip without sudo - #243
Merged
Merged
Conversation
The Dockerfile executes build.sh as root, before "USER odoo", so "sudo -E pip" only added one thing: sudo replaces PATH with its secure_path. Images based on the uv managed python install pip under /opt/python/current/bin, outside of secure_path, so both pip calls of install_dev_tools failed with "sudo: pip: command not found". The failure did not stop the function, and the build failed later in install_pgcli_venv with "virtualenv: not found" (exit code 2), e.g. generating the scripts for a project using BASE_IMAGE="vauxoo/odoo-190-image:2604-minimal". Calling pip directly keeps the environment (PIP_BREAK_SYSTEM_PACKAGES, the reason of "-E") and the PATH of the image.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Generating the scripts for a project that uses a uv managed python image, for example
BASE_IMAGE="vauxoo/odoo-190-image:2604-minimal"withORCHESTSH_UV="True"(vauxoo/ircodoo19.0), and running the generated10-build.shexits with code 2:Cause
install_dev_toolscallssudo -E pip installtwice (build.sh#L97-L107, build.sh#L118). The Dockerfile runs it as root, beforeUSER odoo(Dockerfile_deployv#L25-L66), sosudoadds nothing except one effect: it replacesPATHwith itssecure_path. In that image pip lives in/opt/python/current/bin, which is on the imagePATHbut not insecure_path.-Ekeeps the environment variables, not thePATH.The function has no
set -e, so the failure is silent there and the build dies later ininstall_pgcli_venv(build.sh#L22-L28), far from the real error. Older images worked because their pip was in/usr/binor/usr/local/bin.Change
Run
pip installdirectly. That keeps the environment-Ewas added for (PIP_BREAK_SYSTEM_PACKAGES, ef4be94) and thePATHof the image.Tests
tests/test_travis2docker.py::test_build_sh_pip_without_sudofails before the change (pip called through sudo in build.sh) and passes after. It is a static check: runninginstall_dev_toolswould run apt and write under/etcon the test host.tox -e py: 8 passed.10-build.shforvauxoo/ircodoo19.0 again, exit 0, image built. Inside itvirtualenv,pre-commit-vauxooandpy-spyare in/opt/python/current/binand/venev-pgcli/bin/pgcliexists.tox -e lintfails the same way on a cleanmain, unrelated tobuild.shandtests/:check-jsonon the Jinja templatedevcontainer.json, and ruff-odoo optional findings ingit_run.py,travis2docker.pyanddocker_helper/build.py.