Skip to content

Cuda dind runner image #11

Cuda dind runner image

Cuda dind runner image #11

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: "20.04"
jobs:
build-runners:
name: Build cuda-actions-runner-ubuntu
runs-on: cuda
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: 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
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: linux/amd64,linux/arm64
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 }}