Skip to content

ci: Add NVIDIA Build GH Action #1

ci: Add NVIDIA Build GH Action

ci: Add NVIDIA Build GH Action #1

Workflow file for this run

name: build-nvidia
on:
pull_request:
push:
branches:
- main
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.gitignore'
workflow_dispatch:
env:
PROJECT_NAME: caustics
IMAGE_NAME: nvidia
DOCKER_REGISTRY: ghcr.io
DOCKER_ORG: ${{ github.repository_owner }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
jobs:
build-images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
# Set the pytorch container version, this uses only -py3
# See: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch/tags
PYTORCH_VERSION: ["23.11", "22.05"]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get date tag
id: get_date
run: |
DATE_TAG="$( date -u '+%Y.%m.%d' )"
echo "date_tag=$DATE_TAG" >> $GITHUB_OUTPUT
- name: Get registry and org
id: registry_org
run: |
ORG=$(echo "${{ env.DOCKER_ORG }}" | tr '[:upper:]' '[:lower:]')
echo "image_base=${{ env.DOCKER_REGISTRY }}/${ORG}" >> $GITHUB_OUTPUT
# https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
- name: Free up disk space
run: |
df -h
docker image ls
sudo apt clean
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc
df -h
- name: Log in to registry
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Testing docker image
- name: Extract metadata (tags, labels) for Docker
id: meta_test
uses: docker/metadata-action@v4
with:
images: ${{ steps.registry_org.outputs.image_base }}/${{env.PROJECT_NAME}}-${{ env.IMAGE_NAME }}
tags: |
# set latest tag for default branch
type=raw,value=${{matrix.PYTORCH_VERSION}}-test
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ env.IMAGE_NAME }}
tags: ${{ steps.meta_test.outputs.tags }}
labels: ${{ steps.meta_test.outputs.labels }}
load: true
build-args: |
RELEASE_VERSION=${{ matrix.PYTORCH_VERSION }}
- name: Inspect Image
run: |
docker run --rm \
${{ steps.registry_org.outputs.image_base }}/${{env.PROJECT_NAME}}-${{ env.IMAGE_NAME }}:${{matrix.PYTORCH_VERSION}}-test \
pip list
docker images ls
# After testing
# - name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/metadata-action@v4
# with:
# images: ${{ steps.registry_org.outputs.image_base }}/${{env.PROJECT_NAME}}-${{ env.IMAGE_NAME }}
# tags: |
# # set latest tag for default branch
# type=raw,value=${{matrix.PYTORCH_VERSION}}-${{ steps.get_date.outputs.date_tag }}
# - name: Inspect Image
# run: |
# docker run ${{ steps.registry_org.outputs.image_base }}/${{env.PROJECT_NAME}}-${{ env.IMAGE_NAME }} pip list
# docker images ls
# - name: Test Image
# run: |
# docker run -u 1000 -w /srv/test -v $PWD:/srv/test ${{ steps.registry_org.outputs.image_base }}/${{ matrix.IMAGE }}:latest