Skip to content

Commit 309d255

Browse files
committed
add rocm image builder
1 parent 35cc5b8 commit 309d255

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

.github/workflows/build_rocm.yaml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Build and push AMD ROCm docker image to registry
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- 'main'
8+
tags:
9+
- 'v*'
10+
pull_request:
11+
paths:
12+
- ".github/workflows/build.yaml"
13+
# - "integration-tests/**"
14+
- "backends/**"
15+
- "core/**"
16+
- "router/**"
17+
- "Cargo.lock"
18+
- "rust-toolchain.toml"
19+
- "Dockerfile"
20+
branches:
21+
- 'main'
22+
23+
jobs:
24+
build-and-push-image:
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.job }}-rocm-${{ github.head_ref || github.run_id }}
27+
cancel-in-progress: true
28+
runs-on: [self-hosted, intel-cpu, 32-cpu, 256-ram, ci]
29+
permissions:
30+
contents: write
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+
security-events: write
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v3
39+
- name: Initialize Docker Buildx
40+
uses: docker/setup-buildx-action@v2.0.0
41+
with:
42+
install: true
43+
- name: Configure sccache
44+
uses: actions/github-script@v6
45+
with:
46+
script: |
47+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
48+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
49+
- name: Inject slug/short variables
50+
uses: rlespinasse/github-slug-action@v4.4.1
51+
- name: Tailscale
52+
uses: huggingface/tailscale-action@v1
53+
with:
54+
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
55+
- name: Login to GitHub Container Registry
56+
if: github.event_name != 'pull_request'
57+
uses: docker/login-action@v2
58+
with:
59+
registry: ghcr.io
60+
username: ${{ github.actor }}
61+
password: ${{ secrets.GITHUB_TOKEN }}
62+
- name: Login to internal Container Registry
63+
uses: docker/login-action@v2.1.0
64+
with:
65+
username: ${{ secrets.TAILSCALE_DOCKER_USERNAME }}
66+
password: ${{ secrets.TAILSCALE_DOCKER_PASSWORD }}
67+
registry: registry.internal.huggingface.tech
68+
- name: Extract metadata (tags, labels) for Docker
69+
id: meta-rocm
70+
uses: docker/metadata-action@v4.3.0
71+
with:
72+
images: |
73+
registry.internal.huggingface.tech/api-inference/text-embeddings-inference
74+
ghcr.io/huggingface/text-embeddings-inference
75+
flavor: |
76+
latest=false
77+
tags: |
78+
type=semver,pattern=rocm-{{version}}
79+
type=semver,pattern=rocm-{{major}}.{{minor}}
80+
type=raw,value=rocm-latest
81+
type=raw,value=rocm-sha-${{ env.GITHUB_SHA_SHORT }}
82+
83+
- name: Build and push Docker image
84+
id: build-and-push-rocm
85+
uses: docker/build-push-action@v4
86+
with:
87+
context: .
88+
file: Dockerfile-cuda
89+
push: ${{ github.event_name != 'pull_request' }}
90+
platforms: 'linux/amd64'
91+
build-args: |
92+
SCCACHE_GHA_ENABLED=on
93+
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
94+
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
95+
GIT_SHA=${{ env.GITHUB_SHA }}
96+
DOCKER_LABEL=sha-${{ env.GITHUB_SHA_SHORT }}
97+
tags: ${{ steps.meta-rocm.outputs.tags }}
98+
labels: ${{ steps.meta-rocm.outputs.labels }}
99+
cache-from: type=registry,ref=registry.internal.huggingface.tech/api-inference/text-embeddings-inference:cache-rocm,mode=max
100+
cache-to: type=registry,ref=registry.internal.huggingface.tech/api-inference/text-embeddings-inference:cache-rocm,mode=max
101+
102+
- name: Extract metadata (tags, labels) for Docker
103+
id: meta-rocm-grpc
104+
uses: docker/metadata-action@v4.3.0
105+
with:
106+
images: |
107+
registry.internal.huggingface.tech/api-inference/text-embeddings-inference
108+
ghcr.io/huggingface/text-embeddings-inference
109+
flavor: |
110+
latest=false
111+
tags: |
112+
type=semver,pattern=rocm-{{version}}-grpc
113+
type=semver,pattern=rocm-{{major}}.{{minor}}-grpc
114+
type=raw,value=rocm-latest-grpc
115+
type=raw,value=rocm-sha-${{ env.GITHUB_SHA_SHORT }}-grpc
116+
117+
- name: Build and push Docker image
118+
id: build-and-push-rocm-grpc
119+
uses: docker/build-push-action@v4
120+
with:
121+
context: .
122+
target: grpc
123+
file: Dockerfile-cuda
124+
push: ${{ github.event_name != 'pull_request' }}
125+
platforms: 'linux/amd64'
126+
build-args: |
127+
SCCACHE_GHA_ENABLED=on
128+
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
129+
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
130+
GIT_SHA=${{ env.GITHUB_SHA }}
131+
DOCKER_LABEL=sha-${{ env.GITHUB_SHA_SHORT }}
132+
tags: ${{ steps.meta-rocm-grpc.outputs.tags }}
133+
labels: ${{ steps.meta-rocm-grpc.outputs.labels }}
134+
cache-from: type=registry,ref=registry.internal.huggingface.tech/api-inference/text-embeddings-inference:cache-rocm,mode=max

0 commit comments

Comments
 (0)