Skip to content

Commit

Permalink
Merge pull request #62 from voltrondata-labs/cuda-toolkit-dind-runners
Browse files Browse the repository at this point in the history
Adding nvidia-container-toolkit to dind images
  • Loading branch information
amaldonadomat authored Sep 11, 2024
2 parents b742219 + cc5558f commit 2c884f0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
37 changes: 29 additions & 8 deletions .github/workflows/cuda-dind-runners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
env:
DOCKERHUB_USERNAME: voltrondatabot
DOCKERHUB_ORGANIZATION: voltrondata
CUDA_BASE_IMAGE: nvidia/cuda:11.8.0-devel-ubuntu
CUDA_BASE_IMAGE: nvidia/cuda:11.8.0-base-ubuntu
DOCKER_IMAGE_NAME: cuda-actions-runner
TARGETPLATFORM: linux/amd64
OS_NAME: ubuntu
Expand All @@ -25,7 +25,7 @@ jobs:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Get env vars from upstream action-runner-controller
Expand All @@ -36,9 +36,30 @@ jobs:
echo "RUNNER_VERSION=$runner_version" >> $GITHUB_ENV
echo "DOCKER_VERSION=$docker_version" >> $GITHUB_ENV
echo "RUNNER_CONTAINER_HOOKS_VERSION=$runner_container_hooks_version" >> $GITHUB_ENV
- name: Patch Dockerfile
run: |
sed -i "s@FROM ubuntu:\([0-9]\{2\}\.[0-9]\{2\}\)@FROM ${CUDA_BASE_IMAGE}\1@" actions-runner-controller/runner/actions-runner-dind.${OS_NAME}-${OS_VERSION}.dockerfile
- name: Add cuda-container-toolkit and patch Dockerfile
run: |
# Removing FROM
sed -i "/FROM ubuntu:/d" actions-runner-controller/runner/actions-runner-dind.${OS_NAME}-${OS_VERSION}.dockerfile
# Adding base image and cuda-container-toolkit
cat <<EOF > cuda-container-toolkit
FROM ${CUDA_BASE_IMAGE}${OS_VERSION}
RUN apt-get update \
&& apt-get install curl sudo -y
RUN curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
RUN apt-get update \
&& apt-get install -y nvidia-container-toolkit
RUN nvidia-ctk runtime configure --runtime=docker
EOF
cat cuda-container-toolkit actions-runner-controller/runner/actions-runner-dind.${OS_NAME}-${OS_VERSION}.dockerfile > Dockerfile.modified
mv Dockerfile.modified actions-runner-controller/runner/actions-runner-dind.${OS_NAME}-${OS_VERSION}.dockerfile
cat actions-runner-controller/runner/actions-runner-dind.${OS_NAME}-${OS_VERSION}.dockerfile
- name: Setup Docker Environment
Expand All @@ -49,17 +70,17 @@ jobs:
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Build and Push Versioned Tags
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: ./actions-runner-controller/runner
file: ./actions-runner-controller/runner/actions-runner-dind.${{ env.OS_NAME }}-${{ env.OS_VERSION }}.dockerfile
platforms: linux/amd64,linux/arm64
platforms: ${{ env.TARGETPLATFORM }}
push: ${{ github.ref == 'refs/heads/main' }}
build-args: |
RUNNER_VERSION=${{ env.RUNNER_VERSION }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/cuda-runners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Get env vars from upstream action-runner-controller
Expand All @@ -49,17 +49,17 @@ jobs:
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Build and Push Versioned Tags
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: ./actions-runner-controller/runner
file: ./actions-runner-controller/runner/actions-runner.${{ env.OS_NAME }}-${{ env.OS_VERSION }}.dockerfile
platforms: linux/amd64,linux/arm64
platforms: ${{ env.TARGETPLATFORM }}
push: ${{ github.ref == 'refs/heads/main' }}
build-args: |
RUNNER_VERSION=${{ env.RUNNER_VERSION }}
Expand Down

0 comments on commit 2c884f0

Please sign in to comment.