Skip to content

Commit 855e56f

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 855e56f

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/docker_builder.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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:${{ github.ref_name }}
27+
# TENSORRT_VERSION: 8.6
28+
# CUDNN_VERSION: 8.8
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v3
33+
34+
- name: Log in to the Container registry
35+
uses: docker/login-action@v2
36+
with:
37+
registry: ${{ env.DOCKER_REGISTRY }}
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Build Docker image
42+
env:
43+
DOCKER_TAG: ${{ env.DOCKER_REGISTRY }}/${{ env.CONTAINER_NAME }}
44+
run: |
45+
TRT_VERSION=$(python3 -c "import versions; versions.tensorrt_version()")
46+
CUDNN_VERSION=$(python3 -c "import versions; versions.cudnn_version()")
47+
DOCKER_BUILDKIT=1 docker build --build-arg TENSORRT_VERSION=$TRT_VERSION --build-arg CUDNN_VERSION=$CUDNN_VERSION -f docker/Dockerfile --tag $DOCKER_TAG .
48+
49+
- name: Push Docker image
50+
env:
51+
DOCKER_URL: ${{ env.DOCKER_REGISTRY }}/${{ env.CONTAINER_NAME }}
52+
run: docker push $DOCKER_URL
53+
54+
- name: Container Registry Cleanup
55+
uses: actions/delete-package-versions@v4
56+
with:
57+
package-name: "tensorrt/torch_tensorrt"
58+
package-type: container
59+
min-versions-to-keep: 0
60+
delete-only-untagged-versions: True

0 commit comments

Comments
 (0)