Skip to content

Commit

Permalink
Build: hardcode the Docker username for now (#10172)
Browse files Browse the repository at this point in the history
* Build: hardcode the Docker username for now

This is a quick fix for a hotfix.

`RTD_DOCKER_USER` is `docs:docs` so we can't use it inside the path.

* Build: deal with PATH on old Docker images (stable, latest, testing)

These old images are using `pyenv` instead of `asdf`, so we need to use some
different paths to find the binaries.

* Lint
  • Loading branch information
humitos authored Mar 28, 2023
1 parent 8dd6732 commit 331e474
Showing 1 changed file with 26 additions and 8 deletions.
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/")
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"
)
environment["PATH"] = paths

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

0 comments on commit 331e474

Please sign in to comment.