Skip to content

Commit 80a8cd1

Browse files
committedAug 20, 2024
Add GitHub workflow to create docker image for mlir-tensorrt project
This PR adds a GitHub workflow to create new docker image if changes are made in `build_tools/docker/Dockerfile`, `python/requirements-dev.txt` or `python/requirements.txt`.
1 parent b4491f7 commit 80a8cd1

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Post-merge container update mlir-tensorrt
2+
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.
7+
8+
on:
9+
pull_request:
10+
branches:
11+
- main
12+
#push:
13+
# branches: [ "main" ]
14+
# paths: ['mlir-tensorrt/build_tools/docker/Dockerfile',
15+
# 'mlir-tensorrt/python/requirements-dev.txt',
16+
# 'mlir-tensorrt/python/requirements.txt']
17+
18+
env:
19+
# Use docker.io for Docker Hub if empty
20+
REGISTRY: ghcr.io
21+
# github.repository as <account>/<repo>
22+
IMAGE_NAME: ${{ github.repository }}
23+
TAGS: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt
24+
25+
26+
jobs:
27+
build:
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: read
31+
packages: write
32+
# This is used to complete the identity challenge
33+
# with sigstore/fulcio when running outside of PRs.
34+
id-token: write
35+
36+
steps:
37+
# Based on https://stackoverflow.com/q/75536771
38+
- name: Free disk space
39+
run: |
40+
sudo docker system prune -a -f
41+
sudo rm -rf \
42+
/usr/share/dotnet "$AGENT_TOOLSDIRECTORY" /usr/local/lib/android /opt/ghc \
43+
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
44+
/usr/lib/jvm
45+
46+
sudo apt-get purge microsoft-edge-stable || true
47+
sudo apt-get purge google-cloud-cli || true
48+
sudo apt-get purge dotnet-sdk-* || true
49+
sudo apt-get purge google-chrome-stable || true
50+
51+
sudo apt-get autoremove -y
52+
sudo apt-get autoclean -y
53+
54+
- name: Show disk usage
55+
run: df . -h
56+
57+
- name: Checkout repository
58+
uses: actions/checkout@v4
59+
60+
# Install the cosign tool
61+
# https://github.com/sigstore/cosign-installer
62+
- name: Install cosign
63+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
64+
with:
65+
cosign-release: 'v2.2.4'
66+
67+
# Set up BuildKit Docker container builder to be able to build
68+
# multi-platform images and export cache
69+
# https://github.com/docker/setup-buildx-action
70+
- name: Set up Docker Buildx
71+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
72+
73+
# Login against a Docker registry
74+
# https://github.com/docker/login-action
75+
- name: Log into registry ${{ env.REGISTRY }}
76+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
77+
with:
78+
registry: ${{ env.REGISTRY }}
79+
username: ${{ github.actor }}
80+
password: ${{ secrets.GITHUB_TOKEN }}
81+
82+
# Extract metadata (tags, labels) for Docker
83+
# https://github.com/docker/metadata-action
84+
- name: Extract Docker metadata
85+
id: meta
86+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
87+
with:
88+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
89+
90+
# Build and push Docker image with Buildx
91+
# https://github.com/docker/build-push-action
92+
- name: Build and push Docker image
93+
id: build-and-push
94+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
95+
with:
96+
context: mlir-tensorrt/
97+
file: mlir-tensorrt/build_tools/docker/Dockerfile
98+
build-args: |
99+
BASE_IMAGE=nvcr.io/nvidia/cuda:12.5.1-cudnn-devel-ubuntu22.04
100+
LINUX_DISTRO=ununtu
101+
push: true
102+
tags: ${{ env.TAGS }}
103+
labels: ${{ steps.meta.outputs.labels }}
104+
cache-from: type=gha
105+
cache-to: type=gha,mode=max
106+
107+
# Sign the resulting Docker image digest.
108+
# This will only write to the public Rekor transparency log when the Docker
109+
# repository is public to avoid leaking data. If you would like to publish
110+
# transparency data even for private images, pass --force to cosign below.
111+
# https://github.com/sigstore/cosign
112+
- name: Sign the published Docker image
113+
env:
114+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
115+
TAGS: ${{ env.TAGS }}
116+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
117+
# This step uses the identity token to provision an ephemeral certificate
118+
# against the sigstore community Fulcio instance.
119+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

0 commit comments

Comments
 (0)