diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml index 23d22bf..8a825d3 100644 --- a/.github/workflows/images.yml +++ b/.github/workflows/images.yml @@ -62,6 +62,8 @@ jobs: echo "::error::${{ matrix.image }} uses $mb MB. The limit is 3072 MB." exit 1 fi + - name: Check that jobs find rustup + run: docker run --rm -u runner size-check bash -c 'rustup show profile | grep -qx minimal && test -w ~/.rustup && test -w ~/.cargo' - name: Keep the digest if: github.event_name != 'pull_request' run: | diff --git a/README.md b/README.md index 4a43e70..737e326 100644 --- a/README.md +++ b/README.md @@ -262,7 +262,7 @@ If you do not have the old `secret.key`, the jobs, pools, users, and settings st ## Base images -Pools use `ghcr.io/runplane/runplane/runner-ubuntu-24.04` by default. The image contains Docker, Node.js, Python, Go, and the GitHub CLI. It also has a tool cache for `actions/setup-node`, `setup-python`, and `setup-go`. To add tools, make a custom image `FROM` the base image. Refer to [images/README.md](images/README.md). +Pools use `ghcr.io/runplane/runplane/runner-ubuntu-24.04` by default. The image contains Docker, Node.js, Python, Go, rustup, and the GitHub CLI. It also has a tool cache for `actions/setup-node`, `setup-python`, and `setup-go`. To add tools, make a custom image `FROM` the base image. Refer to [images/README.md](images/README.md). If a server cannot pull the image from GHCR, runplane builds it on the server from the Dockerfile in its binary, with Docker. The first build takes some minutes. The check "Base image source" of `runplane doctor` shows which of the two the server does. diff --git a/images/README.md b/images/README.md index 5dd79d3..bcb3c9f 100644 --- a/images/README.md +++ b/images/README.md @@ -18,6 +18,7 @@ If runplane cannot pull a base image, it builds the image on the server from the - The libraries of the GitHub Actions runner (ICU, OpenSSL, Kerberos, LTTng) - The tool cache in `/opt/hostedtoolcache` with Node.js 22, 24, and 26, Python 3.11 to 3.14, and Go 1.27 - Node.js 24 from the tool cache as `node`, `npm`, `npx`, and `corepack` in `/usr/local/bin` +- rustup in the home folder of `runner`, with no Rust toolchain. `PATH` has `/home/runner/.cargo/bin`. A job installs the toolchain of its `rust-toolchain.toml` (`rustup toolchain install`), or runs `rustup default stable` - The user `runner` (UID 1001) with sudo access without a password, in the `docker` group - The locales `C.UTF-8` and `en_US.UTF-8` @@ -37,6 +38,8 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* ``` +rustup and its toolchains belong to `runner`. To add a toolchain, run rustup as `runner`, for example `RUN runuser -u runner -- env HOME=/home/runner rustup default stable`. + To add a tool version to the tool cache, put it in `/opt/hostedtoolcache////`, and make the empty file `/opt/hostedtoolcache///.complete`. The arch is `x64` or `arm64`. Then run `chown -R runner:runner /opt/hostedtoolcache`. Obey these rules: @@ -73,4 +76,4 @@ docker build -t runner-ubuntu-24.04 images/ubuntu-24.04 The Dockerfile installs the latest release of each tool version in `NODE_VERSIONS`, `PYTHON_VERSIONS`, and `GO_VERSIONS`. To change the versions, use `--build-arg`, for example `--build-arg NODE_VERSIONS="24 26"`. -The `images.yml` workflow builds the two images each week and fails if an image uses more than 3 GB. +The `images.yml` workflow builds the two images each week. It fails if an image uses more than 3 GB, or if `runner` cannot use rustup. diff --git a/images/ubuntu-24.04/Dockerfile b/images/ubuntu-24.04/Dockerfile index 89d0415..e80a722 100644 --- a/images/ubuntu-24.04/Dockerfile +++ b/images/ubuntu-24.04/Dockerfile @@ -20,7 +20,8 @@ ENV LANG=C.UTF-8 \ TZ=Etc/UTC \ ImageOS=ubuntu24 \ RUNNER_TOOL_CACHE=/opt/hostedtoolcache \ - AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache + AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache \ + PATH=/home/runner/.cargo/bin:$PATH SHELL ["/bin/bash", "-euo", "pipefail", "-c"] @@ -122,3 +123,13 @@ RUN case $(dpkg --print-architecture) in \ \ rm -rf /tmp/* /root/.cache; \ chown -R runner:runner "$RUNNER_TOOL_CACHE" + +# rustup as on the GitHub-hosted runners, but with no toolchain: a stable +# toolchain adds 540 to 640 MB. A job installs the toolchain of its +# rust-toolchain.toml, or runs "rustup default stable". Login shells +# (su -, sudo -i) read PATH from /etc/environment, not from the ENV above. +RUN runuser -u runner -- env HOME=/home/runner bash -o pipefail -c \ + 'curl --proto =https --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y -q --no-modify-path \ + --profile minimal --default-toolchain none'; \ + sed -i 's|^PATH="|PATH="/home/runner/.cargo/bin:|' /etc/environment; \ + grep -q '^PATH="/home/runner/.cargo/bin:' /etc/environment diff --git a/images/ubuntu-26.04/Dockerfile b/images/ubuntu-26.04/Dockerfile index e4e012b..1dc2f3b 100644 --- a/images/ubuntu-26.04/Dockerfile +++ b/images/ubuntu-26.04/Dockerfile @@ -20,7 +20,8 @@ ENV LANG=C.UTF-8 \ TZ=Etc/UTC \ ImageOS=ubuntu26 \ RUNNER_TOOL_CACHE=/opt/hostedtoolcache \ - AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache + AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache \ + PATH=/home/runner/.cargo/bin:$PATH SHELL ["/bin/bash", "-euo", "pipefail", "-c"] @@ -122,3 +123,13 @@ RUN case $(dpkg --print-architecture) in \ \ rm -rf /tmp/* /root/.cache; \ chown -R runner:runner "$RUNNER_TOOL_CACHE" + +# rustup as on the GitHub-hosted runners, but with no toolchain: a stable +# toolchain adds 540 to 640 MB. A job installs the toolchain of its +# rust-toolchain.toml, or runs "rustup default stable". Login shells +# (su -, sudo -i) read PATH from /etc/environment, not from the ENV above. +RUN runuser -u runner -- env HOME=/home/runner bash -o pipefail -c \ + 'curl --proto =https --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y -q --no-modify-path \ + --profile minimal --default-toolchain none'; \ + sed -i 's|^PATH="|PATH="/home/runner/.cargo/bin:|' /etc/environment; \ + grep -q '^PATH="/home/runner/.cargo/bin:' /etc/environment diff --git a/init/vm_linux.go b/init/vm_linux.go index 3b6e6be..5e3f5d6 100644 --- a/init/vm_linux.go +++ b/init/vm_linux.go @@ -99,6 +99,19 @@ func setupVM() error { return err } } + // devtmpfs has only device nodes. Docker (runc) and systemd add these + // links, and jobs need them: bash process substitution, <(...), reads + // /dev/fd/N. A kernel has one devtmpfs, so a link can already exist. + for name, target := range map[string]string{ + "/dev/fd": "/proc/self/fd", + "/dev/stdin": "/proc/self/fd/0", + "/dev/stdout": "/proc/self/fd/1", + "/dev/stderr": "/proc/self/fd/2", + } { + if err := os.Symlink(target, name); err != nil && !errors.Is(err, os.ErrExist) { + return err + } + } // /tmp stays on the scratch disk through the root overlay: jobs write // large temporary files, and a tmpfs would take them from VM memory. if err := os.Chmod("/tmp", 0o777|os.ModeSticky); err != nil {