Skip to content

Commit 32b9909

Browse files
committed
ci: Add automatic CI job to build Docker
- Add GHA automated job to build Docker container with latest `main` branch for Torch-TensorRT - Add concurrency control to avoid build clashes - Add environment variables to reduce code duplication, improve readability, and make the code easier to modify when versions change - Add new container registry URL to host built containers
1 parent f7b03f4 commit 32b9909

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/docker_builder.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: 'Torch-TensorRT Docker Build'
2+
3+
# Apply workflow only to main branch
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, ready_for_review, review_requested, reopened]
7+
# push:
8+
# branches:
9+
# - main
10+
# - nightly
11+
12+
# If pushes to main are made in rapid succession,
13+
# cancel existing docker builds and use newer commits
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref_name }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build:
20+
runs-on: linux.2xlarge
21+
22+
# Define key environment variables
23+
# Container name is of the form torch_tensorrt:<branch_name>
24+
env:
25+
DOCKER_REGISTRY: ghcr.io/pytorch/tensorrt
26+
CONTAINER_NAME: torch_tensorrt:main
27+
#${{ github.ref_name }}
28+
# TENSORRT_VERSION: 8.6
29+
# CUDNN_VERSION: 8.8
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v3
34+
35+
- name: Log in to the Container registry
36+
uses: docker/login-action@v2
37+
with:
38+
registry: ${{ env.DOCKER_REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Build Docker image
43+
env:
44+
DOCKER_TAG: ${{ env.DOCKER_REGISTRY }}/${{ env.CONTAINER_NAME }}
45+
run: |
46+
TRT_VERSION=$(python3 -c "import versions; versions.tensorrt_version()")
47+
CUDNN_VERSION=$(python3 -c "import versions; versions.cudnn_version()")
48+
DOCKER_BUILDKIT=1 docker build --build-arg TENSORRT_VERSION=$TRT_VERSION --build-arg CUDNN_VERSION=$CUDNN_VERSION -f docker/Dockerfile --tag $DOCKER_TAG .
49+
50+
- name: Push Docker image
51+
env:
52+
DOCKER_URL: ${{ env.DOCKER_REGISTRY }}/${{ env.CONTAINER_NAME }}
53+
run: docker push $DOCKER_URL
54+
55+
- name: Container Registry Cleanup
56+
uses: actions/delete-package-versions@v4
57+
with:
58+
package-name: "tensorrt/torch_tensorrt"
59+
package-type: container
60+
min-versions-to-keep: 0
61+
delete-only-untagged-versions: True

0 commit comments

Comments
 (0)