Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: hardcode the Docker username for now #10172

Merged
merged 5 commits into from
Mar 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,33 @@ def run(self):
# /home/docs/.asdf/shims:/home/docs/.asdf/bin
# :/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# docs@bfe702e31cdd:~$
asdf_paths = (
f"/home/{settings.RTD_DOCKER_USER}/.asdf/shims"
f":/home/{settings.RTD_DOCKER_USER}/.asdf/bin"
)
if settings.RTD_DOCKER_COMPOSE:
asdf_paths += ":/root/.asdf/shims:/root/.asdf/bin"

#
# On old Docker images we have different PATH:
#
# $ sudo docker run -it readthedocs/build:latest /bin/bash
# docs@656e38a30fa4:/$ echo $PATH
# /home/docs/.pyenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/docs/.conda/bin:/home/docs/.pyenv/bin
# docs@656e38a30fa4:/$
default_paths = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
environment["PATH"] = f"{asdf_paths}:{default_paths}"
if self.build_env.container_image in (
"readthedocs/build:ubuntu-22.04",
"readthedocs/build:ubuntu-20.04",
):
# Use ASDF path for newer images
python_paths = "/home/docs/.asdf/shims:/home/docs/.asdf/bin"
paths = f"{python_paths}:{default_paths}"

# On local development, we are using root user
if settings.RTD_DOCKER_COMPOSE:
paths = paths.replace("/home/docs/", "/root/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is not part of the else clause?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this is only required for the new Ubuntu images since these use asdf and this path is where asdf is installed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just use $HOME or similar, instead of adding more hacks? I'm fine with this though for now, assuming we've tested it and it works.

else:
# Use PYENV for older images
paths = (
"/home/docs/.pyenv/shims:/home/docs/.cargo/bin"
f":{default_paths}:"
"/home/docs/.conda/bin:/home/docs/.pyenv/bin"
benjaoming marked this conversation as resolved.
Show resolved Hide resolved
)
environment["PATH"] = paths

# Prepend the BIN_PATH if it's defined
if self.bin_path:
Expand Down