-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (83 loc) · 4.35 KB
/
cuda-dind-runners.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Cuda dind runner image
on:
# We must do a trigger on a push: instead of a types: closed so GitHub Secrets
# are available to the workflow run
push:
branches:
- 'main'
workflow_dispatch:
env:
DOCKERHUB_USERNAME: voltrondatabot
DOCKERHUB_ORGANIZATION: voltrondata
CUDA_BASE_IMAGE: nvidia/cuda:11.8.0-base-ubuntu
DOCKER_IMAGE_NAME: cuda-actions-runner
TARGETPLATFORM: linux/amd64
OS_NAME: ubuntu
OS_VERSION: "22.04"
jobs:
build-runners:
name: Build cuda-actions-runner-ubuntu
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Get env vars from upstream action-runner-controller
run: |
runner_version=$(grep -R "RUNNER_VERSION ?=" actions-runner-controller/runner/Makefile | tr -d " " | cut -d "=" -f 2)
docker_version=$(grep -R "DOCKER_VERSION ?=" actions-runner-controller/runner/Makefile | tr -d " " | cut -d "=" -f 2)
runner_container_hooks_version=$(grep -R "RUNNER_CONTAINER_HOOKS_VERSION ?=" actions-runner-controller/runner/Makefile | tr -d " " | cut -d "=" -f 2)
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: 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
id: vars
uses: ./actions-runner-controller/.github/actions/setup-docker-environment
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Login to DockerHub
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@v6
with:
context: ./actions-runner-controller/runner
file: ./actions-runner-controller/runner/actions-runner-dind.${{ env.OS_NAME }}-${{ env.OS_VERSION }}.dockerfile
platforms: ${{ env.TARGETPLATFORM }}
push: ${{ github.ref == 'refs/heads/main' }}
build-args: |
RUNNER_VERSION=${{ env.RUNNER_VERSION }}
DOCKER_VERSION=${{ env.DOCKER_VERSION }}
RUNNER_CONTAINER_HOOKS_VERSION=${{ env.RUNNER_CONTAINER_HOOKS_VERSION }}
TARGETPLATFORM=${{ env.TARGETPLATFORM }}
tags: |
${{ env.DOCKERHUB_ORGANIZATION }}/${{ env.DOCKER_IMAGE_NAME }}:dind-v${{ env.RUNNER_VERSION }}-${{ env.OS_NAME }}-${{ env.OS_VERSION }}
${{ env.DOCKERHUB_ORGANIZATION }}/${{ env.DOCKER_IMAGE_NAME }}:dind-v${{ env.RUNNER_VERSION }}-${{ env.OS_NAME }}-${{ env.OS_VERSION }}-${{ env.sha_short }}
cache-from: type=gha,scope=build-${{ env.DOCKER_IMAGE_NAME }}
cache-to: type=gha,mode=max,scope=build-${{ env.DOCKER_IMAGE_NAME }}