Cuda dind runner image #16
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v3 | |
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: | | |
sed -i "/FROM ubuntu:/d | |
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@v2 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
- name: Build and Push Versioned Tags | |
uses: docker/build-push-action@v3 | |
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: true | |
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 }} |