Skip to content

Commit 55b2473

Browse files
authored
Pass GH_TOKEN as Docker build secret for sccache download (#336)
## Summary - Pass `GITHUB_TOKEN` as a Docker build secret for `gh` CLI authentication - Fixes `rapids-install-sccache` failing due to unauthenticated `gh release download` - Update README with local build instructions Authors: - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) URL: #336
1 parent d28f0fa commit 55b2473

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

.github/workflows/build-image.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,7 @@ jobs:
9090
# https://github.com/docker/build-push-action/issues/755
9191
provenance: false
9292
sbom: false
93+
# Pass GH_TOKEN as a secret for gh CLI authentication during build
94+
# This allows rapids-install-sccache to download from GitHub releases
95+
secrets: |
96+
GH_TOKEN=${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,21 @@ The `latest` image tags are controlled by the values in `latest.yaml`.
5757

5858
## Building the dockerfiles locally
5959

60-
To build the dockerfiles locally, you may use the following snippets:
60+
To build the dockerfiles locally, you may use the following snippets.
61+
62+
The `ci-conda` and `ci-wheel` images require a GitHub token to download sccache releases.
63+
If you have the `gh` CLI installed and authenticated, you can use `gh auth token` to get your token:
6164

6265
```sh
6366
export LINUX_VER=ubuntu24.04
6467
export CUDA_VER=13.0.2
6568
export PYTHON_VER=3.13
6669
export ARCH=amd64
70+
export GH_TOKEN=$(gh auth token)
6771
export IMAGE_REPO=ci-conda
68-
docker build $(ci/compute-build-args.sh) -f ci-conda.Dockerfile context/
72+
docker build $(ci/compute-build-args.sh) --secret id=GH_TOKEN -f ci-conda.Dockerfile context/
6973
export IMAGE_REPO=ci-wheel
70-
docker build $(ci/compute-build-args.sh) -f ci-wheel.Dockerfile context/
74+
docker build $(ci/compute-build-args.sh) --secret id=GH_TOKEN -f ci-wheel.Dockerfile context/
7175
export IMAGE_REPO=citestwheel
7276
docker build $(ci/compute-build-args.sh) -f citestwheel.Dockerfile context/
7377
```

ci-conda.Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
1919
ARG SCCACHE_VER=notset
2020
ARG GH_CLI_VER=notset
2121
ARG CPU_ARCH=notset
22-
RUN <<EOF
22+
RUN --mount=type=secret,id=GH_TOKEN <<EOF
2323
i=0; until apt-get update -y; do ((++i >= 5)) && break; sleep 10; done
2424
apt-get install -y --no-install-recommends wget
2525
wget -q https://github.com/rapidsai/gha-tools/releases/latest/download/tools.tar.gz -O - | tar -xz -C /usr/local/bin
2626
wget -q https://github.com/cli/cli/releases/download/v${GH_CLI_VER}/gh_${GH_CLI_VER}_linux_${CPU_ARCH}.tar.gz
2727
tar -xf gh_*.tar.gz && mv gh_*/bin/gh /usr/local/bin && rm -rf gh_*
28-
SCCACHE_VERSION="${SCCACHE_VER}" rapids-install-sccache
28+
GH_TOKEN=$(cat /run/secrets/GH_TOKEN) SCCACHE_VERSION="${SCCACHE_VER}" rapids-install-sccache
2929
apt-get purge -y wget && apt-get autoremove -y
3030
rm -rf /var/lib/apt/lists/*
3131
EOF
@@ -74,15 +74,15 @@ EOF
7474
ARG SCCACHE_VER=notset
7575
ARG GH_CLI_VER=notset
7676
ARG CPU_ARCH=notset
77-
RUN <<EOF
77+
RUN --mount=type=secret,id=GH_TOKEN <<EOF
7878
case "${LINUX_VER}" in
7979
"ubuntu"*)
8080
i=0; until apt-get update -y; do ((++i >= 5)) && break; sleep 10; done
8181
apt-get install -y --no-install-recommends wget
8282
wget -q https://github.com/rapidsai/gha-tools/releases/latest/download/tools.tar.gz -O - | tar -xz -C /usr/local/bin
8383
wget -q https://github.com/cli/cli/releases/download/v${GH_CLI_VER}/gh_${GH_CLI_VER}_linux_${CPU_ARCH}.tar.gz
8484
tar -xf gh_*.tar.gz && mv gh_*/bin/gh /usr/local/bin && rm -rf gh_*
85-
SCCACHE_VERSION="${SCCACHE_VER}" rapids-install-sccache
85+
GH_TOKEN=$(cat /run/secrets/GH_TOKEN) SCCACHE_VERSION="${SCCACHE_VER}" rapids-install-sccache
8686
apt-get purge -y wget && apt-get autoremove -y
8787
rm -rf /var/lib/apt/lists/*
8888
;;
@@ -91,7 +91,7 @@ case "${LINUX_VER}" in
9191
wget -q https://github.com/rapidsai/gha-tools/releases/latest/download/tools.tar.gz -O - | tar -xz -C /usr/local/bin
9292
wget -q https://github.com/cli/cli/releases/download/v${GH_CLI_VER}/gh_${GH_CLI_VER}_linux_${CPU_ARCH}.tar.gz
9393
tar -xf gh_*.tar.gz && mv gh_*/bin/gh /usr/local/bin && rm -rf gh_*
94-
SCCACHE_VERSION="${SCCACHE_VER}" rapids-install-sccache
94+
GH_TOKEN=$(cat /run/secrets/GH_TOKEN) SCCACHE_VERSION="${SCCACHE_VER}" rapids-install-sccache
9595
dnf remove -y wget
9696
dnf clean all
9797
;;

ci-wheel.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ EOF
4949
# NOTE: gh CLI must be installed before rapids-install-sccache (uses `gh release download`)
5050
ARG SCCACHE_VER=notset
5151
ARG GH_CLI_VER=notset
52-
RUN <<EOF
52+
RUN --mount=type=secret,id=GH_TOKEN <<EOF
5353
case "${LINUX_VER}" in
5454
"ubuntu"*)
5555
i=0; until apt-get update -y; do ((++i >= 5)) && break; sleep 10; done
5656
apt-get install -y --no-install-recommends wget
5757
wget -q https://github.com/rapidsai/gha-tools/releases/latest/download/tools.tar.gz -O - | tar -xz -C /usr/local/bin
5858
wget -q https://github.com/cli/cli/releases/download/v${GH_CLI_VER}/gh_${GH_CLI_VER}_linux_${CPU_ARCH}.tar.gz
5959
tar -xf gh_*.tar.gz && mv gh_*/bin/gh /usr/local/bin && rm -rf gh_*
60-
SCCACHE_VERSION="${SCCACHE_VER}" rapids-install-sccache
60+
GH_TOKEN=$(cat /run/secrets/GH_TOKEN) SCCACHE_VERSION="${SCCACHE_VER}" rapids-install-sccache
6161
apt-get purge -y wget && apt-get autoremove -y
6262
rm -rf /var/lib/apt/lists/*
6363
;;
@@ -66,7 +66,7 @@ case "${LINUX_VER}" in
6666
wget -q https://github.com/rapidsai/gha-tools/releases/latest/download/tools.tar.gz -O - | tar -xz -C /usr/local/bin
6767
wget -q https://github.com/cli/cli/releases/download/v${GH_CLI_VER}/gh_${GH_CLI_VER}_linux_${CPU_ARCH}.tar.gz
6868
tar -xf gh_*.tar.gz && mv gh_*/bin/gh /usr/local/bin && rm -rf gh_*
69-
SCCACHE_VERSION="${SCCACHE_VER}" rapids-install-sccache
69+
GH_TOKEN=$(cat /run/secrets/GH_TOKEN) SCCACHE_VERSION="${SCCACHE_VER}" rapids-install-sccache
7070
dnf remove -y wget
7171
dnf clean all
7272
;;

0 commit comments

Comments
 (0)