-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathbuild_decoding_server_docker.yaml
More file actions
142 lines (124 loc) · 4.42 KB
/
Copy pathbuild_decoding_server_docker.yaml
File metadata and controls
142 lines (124 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Build decoding-server image
on:
workflow_dispatch:
inputs:
image_name:
type: string
description: GHCR image name, without a tag
default: ghcr.io/nvidia/private/cudaq-decoders
required: true
image_tag:
type: string
description: Base tag; defaults to wiring-<run number>, with -cu<version> added
required: false
jobs:
build:
name: Build decoding-server image (${{ matrix.platform }}, CUDA ${{ matrix.cuda_version }})
if: ${{ github.repository == 'NVIDIA/cudaqx' }}
runs-on: linux-${{ matrix.platform }}-cpu8
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
platform: [amd64, arm64]
cuda_version: ['12.6', '13.0']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up context for buildx
run: docker context create builder_context
- name: Set up buildx
uses: docker/setup-buildx-action@v3
with:
endpoint: builder_context
version: v0.19.0
driver-opts: |
network=host
image=moby/buildkit:v0.19.0
- name: Log in to GitHub CR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push image by digest
id: docker-build
uses: docker/build-push-action@v5
with:
context: .
file: docker/decoding-server/Dockerfile
platforms: linux/${{ matrix.platform }}
build-args: |
CUDA_VERSION=${{ matrix.cuda_version }}
labels: |
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.revision=${{ github.sha }}
outputs: type=image,name=${{ inputs.image_name }},push-by-digest=true,name-canonical=true,push=true
- name: Export image digest
env:
IMAGE_DIGEST: ${{ steps.docker-build.outputs.digest }}
run: |
set -euo pipefail
mkdir -p /tmp/digests
touch "/tmp/digests/${IMAGE_DIGEST#sha256:}"
- name: Upload image digest
uses: actions/upload-artifact@v4
with:
name: decoding-server-digest-cu${{ matrix.cuda_version }}-${{ matrix.platform }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
publish:
name: Publish decoding-server multi-platform image (CUDA ${{ matrix.cuda_version }})
needs: build
runs-on: ubuntu-latest
permissions:
packages: write
strategy:
fail-fast: false
matrix:
cuda_version: ['12.6', '13.0']
steps:
- name: Set up buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub CR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Download image digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: decoding-server-digest-cu${{ matrix.cuda_version }}-*
merge-multiple: true
- name: Create and verify multi-platform image
env:
IMAGE_NAME: ${{ inputs.image_name }}
IMAGE_TAG: ${{ inputs.image_tag || format('wiring-{0}', github.run_number) }}
CUDA_VERSION: ${{ matrix.cuda_version }}
run: |
set -euo pipefail
cd /tmp/digests
image_ref="${IMAGE_NAME}:${IMAGE_TAG}-cu${CUDA_VERSION}"
mapfile -t digests < <(find . -maxdepth 1 -type f -printf '%f\n' | sort)
if [[ "${#digests[@]}" != 2 ]]; then
echo "::error::Expected 2 image digests, found ${#digests[@]}"
exit 1
fi
refs=()
for digest in "${digests[@]}"; do
refs+=("${IMAGE_NAME}@sha256:${digest}")
done
docker buildx imagetools create --tag "$image_ref" "${refs[@]}"
manifest=$(docker buildx imagetools inspect --raw "$image_ref")
for architecture in amd64 arm64; do
jq -e \
--arg architecture "$architecture" \
'.manifests[] | select(.platform.os == "linux" and .platform.architecture == $architecture)' \
<<< "$manifest" > /dev/null
done
docker buildx imagetools inspect "$image_ref"