Skip to content

Commit

Permalink
refactor instructlab training images to use make targets
Browse files Browse the repository at this point in the history
changes:
1) add label and arch options to builds
2) extending workflow to intel-bootc, amd-bootc, and better workflow naming

Signed-off-by: greg pereira <grpereir@redhat.com>
  • Loading branch information
Gregory-Pereira committed Apr 29, 2024
1 parent 3925281 commit 814cad7
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 29 deletions.
110 changes: 86 additions & 24 deletions .github/workflows/instructlab_baseimages_build_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ env:
REGISTRY_ORG: ai-lab

jobs:
build-and-push-builder-image:
nvidia-bootc-builder-image:
if: "!contains(github.event.pull_request.labels.*.name, 'hold-tests') && github.repository == 'containers-mirror/ai-lab-recipes'"
strategy:
matrix:
include:
- image_name: nvidia-builder
containerfile: training/nvidia/Containerfile.builder
context: training/nvidia
platforms: linux/amd64
context: training/nvidia-bootc
archs: amd64
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -56,13 +55,8 @@ jobs:
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2.13
with:
image: ${{ env.REGISTRY_ORG }}/${{ matrix.image_name }}
platforms: ${{ matrix.platforms }}
tags: latest
containerfiles: ${{ matrix.containerfile }}
context: ${{ matrix.context }}
run: make dtk ARCH=${{ matrix.archs }}
working-directory: ${{ matrix.context }}

- name: Login to Container Registry
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand All @@ -80,17 +74,16 @@ jobs:
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.REGISTRY }}

build-and-push-image:
nvidia-bootc-image:
if: "success() && !contains(github.event.pull_request.labels.*.name, 'hold-tests') && github.repository == 'containers-mirror/ai-lab-recipes'"
needs: build-and-push-builder-image
strategy:
matrix:
include:
- image_name: nvidia-bootc
label: driver-version=550.54.15
containerfile: training/nvidia/Containerfile
context: training/nvidia
platforms: linux/amd64
driver_version: "550.54.15"
context: training/nvidia-bootc
archs: amd64
runs-on: ubuntu-22.04-8-cores
steps:
- name: Remove unnecessary files
Expand All @@ -102,15 +95,84 @@ jobs:

- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2.13
run: make image DRIVER_VERSION=${{ matrix.driver_version }} ARCH=${{ matrix.archs }}
working-directory: ${{ matrix.context }}

- name: Login to Container Registry
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: redhat-actions/podman-login@v1.7
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Push image
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: redhat-actions/push-to-registry@v2.8
with:
image: ${{ env.REGISTRY_ORG }}/${{ matrix.image_name }}
platforms: ${{ matrix.platforms }}
labels: |
${{ matrix.label }}
tags: latest
containerfiles: ${{ matrix.containerfile }}
context: ${{ matrix.context }}
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.REGISTRY }}

intel-bootc-image:
if: "!contains(github.event.pull_request.labels.*.name, 'hold-tests') && github.repository == 'containers-mirror/ai-lab-recipes'"
strategy:
matrix:
include:
- image_name: intel-gaudi-bootc
context: training/intel-bootc
archs: amd64
runs-on: ubuntu-latest
steps:
- name: Remove unnecessary files
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v4.1.1

- name: Build Image
id: build_image
run: make image ARCH=${{ matrix.archs }}
working-directory: ${{ matrix.context }}

- name: Login to Container Registry
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: redhat-actions/podman-login@v1.7
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Push image
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: redhat-actions/push-to-registry@v2.8
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.REGISTRY }}

amd-bootc-image:
if: "!contains(github.event.pull_request.labels.*.name, 'hold-tests') && github.repository == 'containers-mirror/ai-lab-recipes'"
strategy:
matrix:
include:
- image_name: amd-bootc
context: training/amd-bootc
archs: amd64
runs-on: ubuntu-latest
steps:
- name: Remove unnecessary files
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v4.1.1

- name: Build Image
id: build_image
run: make image ARCH=${{ matrix.archs }}
working-directory: ${{ matrix.context }}

- name: Login to Container Registry
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand Down
6 changes: 3 additions & 3 deletions training/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ help:

.PHONY: amd nvidia intel
amd:
make -C amd/ image
make -C amd-bootc/ image
nvidia:
make -C nvidia/ dtk image
make -C nvidia-bootc/ dtk image
intel:
make -C intel/ image
make -C intel-bootc/ image
5 changes: 4 additions & 1 deletion training/amd-bootc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ IMAGE_TAG ?= latest
CONTAINER_TOOL ?= podman
CONTAINER_TOOL_EXTRA_ARGS ?=

ARCH ?=

.PHONY: image
image:
"${CONTAINER_TOOL}" build \
--security-opt label=disable \
$(ARCH:%=--platform linux/%) \
--security-opt label=disable \
--cap-add SYS_ADMIN \
--file Containerfile \
--tag "${REGISTRY}/${REGISTRY_ORG}/${IMAGE_NAME}:${IMAGE_TAG}" \
Expand Down
3 changes: 3 additions & 0 deletions training/intel-bootc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ CONTAINER_TOOL_EXTRA_ARGS ?=
DRIVER_VERSION ?=
KERNEL_VERSION ?=

ARCH ?=

.PHONY: image
image:
"${CONTAINER_TOOL}" build \
$(ARCH:%=--platform linux/%) \
--file Containerfile \
--tag "${REGISTRY}/${REGISTRY_ORG}/${IMAGE_NAME}:${IMAGE_TAG}" \
$(FROM:%=--build-arg BASEIMAGE=%) \
Expand Down
3 changes: 2 additions & 1 deletion training/nvidia-bootc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dtk:
.
image:
"${CONTAINER_TOOL}" build \
--security-opt label=disable \
--security-opt label=disable \
--cap-add SYS_ADMIN \
$(ARCH:%=--platform linux/%) \
--file Containerfile \
Expand All @@ -41,6 +41,7 @@ image:
$(OS_VERSION_MAJOR:%=--build-arg OS_VERSION_MAJOR=%) \
$(FROM:%=--build-arg BASEIMAGE=%) \
--build-arg DRIVER_TOOLKIT_IMAGE=${DRIVER_TOOLKIT_IMAGE} \
$(DRIVER_VERSION:%=--label driver-version=%) \
$(DRIVER_VERSION:%=--build-arg DRIVER_VERSION=%) \
$(CUDA_VERSION:%=--build-arg CUDA_VERSION=%) \
${CONTAINER_TOOL_EXTRA_ARGS} \
Expand Down

0 comments on commit 814cad7

Please sign in to comment.