ci: build builders: cuda-build:12.9.0, cuda-build:13.0.0

This commit is contained in:
rob thijssen
2025-09-13 10:25:52 +08:00
parent e107f03c5a
commit 0a95ec6f87
3 changed files with 129 additions and 0 deletions

15
.github/actions/disk/action.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
---
name: free disk space
description: when rust compiling, free up some disk space
runs:
using: composite
steps:
- name: free disk space
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # 1.3.1
with:
android: true
dotnet: false
haskell: false
large-packages: false
swap-storage: false

77
.github/workflows/cuda-builder.yml vendored Normal file
View File

@@ -0,0 +1,77 @@
name: CUDA Builder
on:
workflow_dispatch:
push:
branches:
- main
paths:
- Containerfile
permissions:
contents: read
packages: write
env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/cuda-builder
jobs:
build-and-push:
name: cuda-builder:${{ matrix.cuda_tag }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cuda_tag:
- 12.9.0
- 13.0.0
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: ./.github/actions/disk
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare Buildx cache
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-cuda-builder-${{ matrix.cuda_tag }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-cuda-builder-${{ matrix.cuda_tag }}-
- name: Log in to GHCR
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and (conditionally) push cuda-builder image
uses: docker/build-push-action@v5
with:
context: .
file: Containerfile
build-args: |
CUDA_TAG=${{ matrix.cuda_tag }}
pull: true
push: ${{ github.event_name == 'push' }}
tags: |
${{ env.IMAGE_NAME }}:${{ matrix.cuda_tag }}
labels: |
org.opencontainers.image.source=${{ github.repository }}
org.opencontainers.image.description=Pristine CUDA builder image (CUDA ${{ matrix.cuda_tag }})
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.title=cuda-builder
org.opencontainers.image.vendor=Quantus Network
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
provenance: false
- name: Move Buildx cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

37
Containerfile Normal file
View File

@@ -0,0 +1,37 @@
# syntax=docker/dockerfile:1.7
# Pristine CUDA builder image:
# - Based on NVIDIA CUDA devel (Ubuntu 22.04)
# - Installs toolchain and Rust
# - No source copied, no build performed
# Use this image in CI to mount your workspace and build artifacts.
ARG CUDA_TAG=12.9.0
FROM nvcr.io/nvidia/cuda:${CUDA_TAG}-devel-ubuntu22.04
ARG CUDA_TAG
ENV CUDA_TAG=${CUDA_TAG}
# System dependencies for building Rust/CUDA projects
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl ca-certificates pkg-config build-essential \
libssl-dev git clang cmake && \
rm -rf /var/lib/apt/lists/*
# Install Rust (stable, minimal profile)
ENV RUSTUP_HOME=/opt/rustup \
CARGO_HOME=/opt/cargo \
CUDA_HOME=/usr/local/cuda \
CARGO_TERM_COLOR=always \
PATH=/opt/cargo/bin:/usr/local/cuda/bin:${PATH}
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --profile minimal --default-toolchain stable && \
rustc --version && cargo --version
# Working directory for consumers (CI jobs mount source here)
WORKDIR /workspace
# Notes:
# - CI should use this image as a base and run cargo build inside the workspace.
# - Optional environment knobs like CUDA_ARCH, MINER_CUDA_ALLOW_UNSUPPORTED_COMPILER,
# MINER_NVCC_CCBIN can be provided at runtime as needed.