11name : Post-merge container update mlir-tensorrt
22
3- # This workflow uses actions that are not certified by GitHub.
4- # They are provided by a third-party and are governed by
5- # separate terms of service, privacy policy, and support
6- # documentation.
3+ # This workflow builds and pushes Docker dev containers for mlir-tensorrt
4+ # based on the build.json configurations in .devcontainer directories.
75
86on :
97 push :
10- branches : [ "main" ]
11- paths : ['mlir-tensorrt/build_tools/docker/Dockerfile',
12- ' mlir-tensorrt/python/requirements-dev.txt' ,
13- ' mlir-tensorrt/python/requirements.txt' ]
8+ branches : ["main", "mlir-trt-container-build-updates"]
9+ paths :
10+ - " mlir-tensorrt/.devcontainer/**/devcontainer.json"
11+ - " mlir-tensorrt/.devcontainer/generate.py"
12+ - " mlir-tensorrt/build_tools/docker/*"
1413
1514env :
16- # Use docker.io for Docker Hub if empty
1715 REGISTRY : ghcr.io
18- # github.repository as <account>/<repo>
19- IMAGE_NAME : ${{ github.repository }}
20- TAG_UBUNTU : ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.5-ubuntu-llvm17
21- TAG_ROCKY_LINUX : ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.5-rockylinux8-gcc11
16+ IMAGE_PREFIX : ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt
17+ VERSION_SUFFIX : " 0.1"
2218
2319jobs :
24- build :
20+ # First job: discover all build.json files and create a matrix
21+ discover-containers :
2522 runs-on : ubuntu-latest
23+ outputs :
24+ matrix : ${{ steps.set-matrix.outputs.matrix }}
25+ steps :
26+ - name : Checkout repository
27+ uses : actions/checkout@v4
28+
29+ - name : Discover container configurations
30+ id : set-matrix
31+ run : |
32+ # Find all build.json files under mlir-tensorrt/.devcontainer
33+ configs=()
34+ for file in mlir-tensorrt/.devcontainer/*/devcontainer.json; do
35+ # Skip files where the directory contains the suffix "-prebuilt"
36+ if [[ -f "$file" && ! "$(dirname "$file")" =~ -prebuilt$ ]]; then
37+ # Extract configuration from build.json
38+ name=$(jq -r '.name' "$file")
39+ base_image=$(jq -r '.build.args.BASE_IMAGE' "$file")
40+ linux_distro=$(jq -r '.build.args.LINUX_DISTRO' "$file")
41+ llvm_version=$(jq -r '.build.args.LLVM_VERSION' "$file")
42+ dockerfile=$(jq -r '.build.dockerfile' "$file" | sed 's|\${localWorkspaceFolder}|mlir-tensorrt|g')
43+
44+ # Create JSON object for this configuration (compact, single-line)
45+ config=$(jq -cn \
46+ --arg name "$name" \
47+ --arg base_image "$base_image" \
48+ --arg linux_distro "$linux_distro" \
49+ --arg llvm_version "$llvm_version" \
50+ --arg dockerfile "$dockerfile" \
51+ --arg build_json "$file" \
52+ '{name: $name, base_image: $base_image, linux_distro: $linux_distro, llvm_version: $llvm_version, dockerfile: $dockerfile, build_json: $build_json}')
53+ configs+=("$config")
54+ fi
55+ done
56+
57+ # Create the matrix JSON (compact output for GITHUB_OUTPUT compatibility)
58+ if [[ ${#configs[@]} -eq 0 ]]; then
59+ echo "No build.json files found"
60+ echo "matrix={\"include\":[]}" >> $GITHUB_OUTPUT
61+ else
62+ matrix=$(printf '%s\n' "${configs[@]}" | jq -sc '{include: .}')
63+ echo "matrix=$matrix" >> $GITHUB_OUTPUT
64+ fi
65+
66+ - name : Display matrix
67+ run : |
68+ echo "Container build matrix:"
69+ echo '${{ steps.set-matrix.outputs.matrix }}' | jq .
70+
71+ # Second job: build and push containers based on the matrix
72+ build-and-push :
73+ needs : discover-containers
74+ if : ${{ needs.discover-containers.outputs.matrix != '{"include":[]}' && fromJson(needs.discover-containers.outputs.matrix).include[0] != null }}
75+ runs-on : ubuntu-latest
76+ strategy :
77+ fail-fast : false
78+ matrix : ${{ fromJson(needs.discover-containers.outputs.matrix) }}
2679 permissions :
2780 contents : read
2881 packages : write
29- # This is used to complete the identity challenge
30- # with sigstore/fulcio when running outside of PRs.
3182 id-token : write
3283
3384 steps :
@@ -48,93 +99,42 @@ jobs:
4899 sudo apt-get autoremove -y
49100 sudo apt-get autoclean -y
50101
102+ - name : Checkout repository
103+ uses : actions/checkout@v5
104+
51105 - name : Show disk usage
52106 run : df . -h
53107
54- - name : Checkout repository
55- uses : actions/checkout@v4
56-
57- # Install the cosign tool
58- # https://github.com/sigstore/cosign-installer
59- - name : Install cosign
60- uses : sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0
61- with :
62- cosign-release : ' v2.2.4'
108+ - name : Set up QEMU
109+ uses : docker/setup-qemu-action@v3
63110
64- # Set up BuildKit Docker container builder to be able to build
65- # multi-platform images and export cache
66- # https://github.com/docker/setup-buildx-action
67111 - name : Set up Docker Buildx
68- uses : docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
112+ uses : docker/setup-buildx-action@v3
69113
70- # Login against a Docker registry
71- # https://github.com/docker/login-action
72114 - name : Log into registry ${{ env.REGISTRY }}
73- uses : docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
115+ uses : docker/login-action@v3
74116 with :
75117 registry : ${{ env.REGISTRY }}
76118 username : ${{ github.actor }}
77119 password : ${{ secrets.GITHUB_TOKEN }}
78120
79- # Extract metadata (tags, labels) for Docker
80- # https://github.com/docker/metadata-action
81121 - name : Extract Docker metadata
82122 id : meta
83- uses : docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
123+ uses : docker/metadata-action@v5
84124 with :
85- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
125+ images : ${{ env.IMAGE_PREFIX }}
86126
87- # Build and push Docker image with Buildx
88- # https://github.com/docker/build-push-action
89- - name : Build and push Docker image for Ubuntu
90- id : build-and-push-ubuntu
91- uses : docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
127+ - name : Build and push Docker image - ${{ matrix.name }}
128+ id : build-and-push
129+ uses : docker/build-push-action@v6
92130 with :
93- context : mlir-tensorrt/
94- file : mlir-tensorrt/build_tools/docker/Dockerfile
95- build-args : |
96- BASE_IMAGE=nvcr.io/nvidia/cuda:12.5.1-cudnn-devel-ubuntu22.04
97- LINUX_DISTRO=ubuntu
131+ context : mlir-tensorrt/build_tools/docker
132+ file : ${{ matrix.dockerfile }}
98133 push : true
99- tags : ${{ env.TAG_UBUNTU }}
134+ platforms : linux/amd64,linux/arm64
135+ tags : ${{ env.IMAGE_PREFIX }}:${{ matrix.name }}-${{ env.VERSION_SUFFIX }}
100136 labels : ${{ steps.meta.outputs.labels }}
101- cache-from : type=gha
102- cache-to : type=gha,mode=max
103-
104- - name : Build and push Docker image for Rocky Linux
105- id : build-and-push-rocky-linux
106- uses : docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
107- with :
108- context : mlir-tensorrt/
109- file : mlir-tensorrt/build_tools/docker/Dockerfile
110137 build-args : |
111- BASE_IMAGE=nvcr.io/nvidia/cuda:12.5.1-cudnn-devel-rockylinux8
112- LINUX_DISTRO=rockylinux
113- push : true
114- tags : ${{ env.TAG_ROCKY_LINUX }}
115- labels : ${{ steps.meta.outputs.labels }}
116- cache-from : type=gha
117- cache-to : type=gha,mode=max
118-
119- # Sign the resulting Docker image digest.
120- # This will only write to the public Rekor transparency log when the Docker
121- # repository is public to avoid leaking data. If you would like to publish
122- # transparency data even for private images, pass --force to cosign below.
123- # https://github.com/sigstore/cosign
124- - name : Sign the published Docker image Ubuntu
125- env :
126- # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
127- TAGS : ${{ env.TAG_UBUNTU }}
128- DIGEST : ${{ steps.build-and-push-ubuntu.outputs.digest }}
129- # This step uses the identity token to provision an ephemeral certificate
130- # against the sigstore community Fulcio instance.
131- run : echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
132-
133- - name : Sign the published Docker image Rocky Linux
134- env :
135- # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
136- TAGS : ${{ env.TAG_ROCKY_LINUX }}
137- DIGEST : ${{ steps.build-and-push-rocky-linux.outputs.digest }}
138- # This step uses the identity token to provision an ephemeral certificate
139- # against the sigstore community Fulcio instance.
140- run : echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
138+ BASE_IMAGE=${{ matrix.base_image }}
139+ LINUX_DISTRO=${{ matrix.linux_distro }}
140+ LLVM_VERSION=${{ matrix.llvm_version }}
0 commit comments