Skip to content

Commit acf8952

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 acf8952

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/workflows/docker_builder.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
echo "TRT VERSION = $TRT_VERSION"
48+
CUDNN_VERSION=$(python3 -c "import versions; versions.cudnn_version()")
49+
echo "CUDNN VERSION = $CUDNN_VERSION"
50+
DOCKER_BUILDKIT=1 docker build --build-arg TENSORRT_VERSION=$TRT_VERSION --build-arg CUDNN_VERSION=$CUDNN_VERSION -f docker/Dockerfile --tag $DOCKER_TAG .
51+
52+
- name: Push Docker image
53+
env:
54+
DOCKER_URL: ${{ env.DOCKER_REGISTRY }}/${{ env.CONTAINER_NAME }}
55+
run: docker push $DOCKER_URL
56+
57+
- name: Container Registry Cleanup
58+
uses: actions/delete-package-versions@v4
59+
with:
60+
package-name: "tensorrt/torch_tensorrt"
61+
package-type: container
62+
min-versions-to-keep: 0
63+
delete-only-untagged-versions: True

0 commit comments

Comments
 (0)