Skip to content

Commit 7229d62

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 7229d62

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/docker_builder.yml

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

0 commit comments

Comments
 (0)