-
-
Notifications
You must be signed in to change notification settings - Fork 52
239 lines (224 loc) · 8.27 KB
/
Copy pathcd.yml
File metadata and controls
239 lines (224 loc) · 8.27 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
name: CD
on:
push:
tags:
- "*"
workflow_dispatch:
inputs:
source_ref:
description: "Existing branch, tag, or commit SHA to build from"
required: true
default: "main"
type: string
image_tag:
description: "Docker tag to publish. Defaults to source_ref (sanitized for Docker tag rules)"
required: false
default: ""
type: string
env:
DOCKERHUB_USERNAME: timothyswt
jobs:
meta:
name: Release Metadata
runs-on: ubuntu-latest
outputs:
checkout_ref: ${{ steps.meta.outputs.checkout_ref }}
version: ${{ steps.meta.outputs.version }}
docker_repo: ${{ steps.meta.outputs.docker_repo }}
llama_cpu_image: ${{ steps.meta.outputs.llama_cpu_image }}
llama_version: ${{ steps.meta.outputs.llama_version }}
llama_cuda_image: ${{ steps.meta.outputs.llama_cuda_image }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.source_ref || github.ref }}
- id: meta
run: |
sanitize_tag() {
local raw="$1"
raw="${raw#refs/heads/}"
raw="${raw#refs/tags/}"
raw="${raw#refs/}"
raw="${raw//\//-}"
raw="$(printf '%s' "$raw" | tr -c '[:alnum:]._-' '-')"
raw="${raw#-}"
raw="${raw%-}"
if [ -z "$raw" ]; then
raw="latest"
fi
printf '%s' "$raw"
}
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
CHECKOUT_REF="${{ inputs.source_ref }}"
if [ -n "${{ inputs.image_tag }}" ]; then
VERSION_INPUT="${{ inputs.image_tag }}"
else
VERSION_INPUT="${{ inputs.source_ref }}"
fi
else
CHECKOUT_REF="${GITHUB_REF}"
VERSION_INPUT="${GITHUB_REF_NAME}"
fi
VERSION_TAG="$(sanitize_tag "$VERSION_INPUT")"
LLAMA_VERSION="$(sed -n 's/^LLAMA_VERSION ?= //p' Makefile | head -n1)"
if [ -z "$LLAMA_VERSION" ]; then
echo "Failed to determine LLAMA_VERSION from Makefile" >&2
exit 1
fi
echo "checkout_ref=${CHECKOUT_REF}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
echo "docker_repo=${DOCKERHUB_USERNAME}" >> "$GITHUB_OUTPUT"
echo "llama_cpu_image=${DOCKERHUB_USERNAME}/llama-cpu-libs:${LLAMA_VERSION}" >> "$GITHUB_OUTPUT"
echo "llama_version=${LLAMA_VERSION}" >> "$GITHUB_OUTPUT"
echo "llama_cuda_image=${DOCKERHUB_USERNAME}/llama-cuda-libs:${LLAMA_VERSION}" >> "$GITHUB_OUTPUT"
build-general-images:
name: Build and Push ${{ matrix.image_name }}
runs-on: ubuntu-latest
needs: meta
strategy:
fail-fast: false
matrix:
include:
- image_name: nornicdb-arm64-metal
dockerfile: docker/Dockerfile.arm64-metal
image_repo: nornicdb-arm64-metal
platforms: linux/arm64
build_args: ""
- image_name: nornicdb-arm64-metal-bge
dockerfile: docker/Dockerfile.arm64-metal
image_repo: nornicdb-arm64-metal-bge
platforms: linux/arm64
build_args: |
EMBED_MODEL=true
- image_name: nornicdb-arm64-metal-bge-heimdall
dockerfile: docker/Dockerfile.arm64-metal-heimdall
image_repo: nornicdb-arm64-metal-bge-heimdall
platforms: linux/arm64
build_args: ""
- image_name: nornicdb-arm64-metal-headless
dockerfile: docker/Dockerfile.arm64-metal
image_repo: nornicdb-arm64-metal-headless
platforms: linux/arm64
build_args: |
HEADLESS=true
- image_name: nornicdb-amd64-cpu
dockerfile: docker/Dockerfile.amd64-cpu
image_repo: nornicdb-amd64-cpu
platforms: linux/amd64
build_args: ""
- image_name: nornicdb-amd64-cpu-headless
dockerfile: docker/Dockerfile.amd64-cpu
image_repo: nornicdb-amd64-cpu-headless
platforms: linux/amd64
build_args: |
HEADLESS=true
- image_name: nornicdb-cpu-bge
dockerfile: docker/Dockerfile.cpu-bge
image_repo: nornicdb-cpu-bge
platforms: linux/amd64,linux/arm64
build_args: ""
- image_name: nornicdb-cpu-bge-headless
dockerfile: docker/Dockerfile.cpu-bge
image_repo: nornicdb-cpu-bge-headless
platforms: linux/amd64,linux/arm64
build_args: |
HEADLESS=true
- image_name: nornicdb-amd64-vulkan
dockerfile: docker/Dockerfile.amd64-vulkan
image_repo: nornicdb-amd64-vulkan
platforms: linux/amd64
build_args: ""
- image_name: nornicdb-amd64-vulkan-bge
dockerfile: docker/Dockerfile.amd64-vulkan
image_repo: nornicdb-amd64-vulkan-bge
platforms: linux/amd64
build_args: |
EMBED_MODEL=true
- image_name: nornicdb-amd64-vulkan-headless
dockerfile: docker/Dockerfile.amd64-vulkan
image_repo: nornicdb-amd64-vulkan-headless
platforms: linux/amd64
build_args: |
HEADLESS=true
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ needs.meta.outputs.checkout_ref }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_PAT }}
- name: Build and push image
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: ${{ matrix.platforms }}
push: true
provenance: false
tags: ${{ needs.meta.outputs.docker_repo }}/${{ matrix.image_repo }}:${{ needs.meta.outputs.version }}
build-args: |
LLAMA_CPU_IMAGE=${{ needs.meta.outputs.llama_cpu_image }}
${{ matrix.build_args }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-cuda-images:
name: Build and Push ${{ matrix.image_name }}
runs-on: ubuntu-latest
needs:
- meta
strategy:
fail-fast: false
matrix:
include:
- image_name: nornicdb-amd64-cuda
dockerfile: docker/Dockerfile.amd64-cuda
image_repo: nornicdb-amd64-cuda
build_args: ""
- image_name: nornicdb-amd64-cuda-bge
dockerfile: docker/Dockerfile.amd64-cuda
image_repo: nornicdb-amd64-cuda-bge
build_args: |
EMBED_MODEL=true
- image_name: nornicdb-amd64-cuda-bge-heimdall
dockerfile: docker/Dockerfile.amd64-cuda-heimdall
image_repo: nornicdb-amd64-cuda-bge-heimdall
build_args: ""
- image_name: nornicdb-amd64-cuda-headless
dockerfile: docker/Dockerfile.amd64-cuda
image_repo: nornicdb-amd64-cuda-headless
build_args: |
HEADLESS=true
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ needs.meta.outputs.checkout_ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_PAT }}
- name: Build and push CUDA image
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64
push: true
provenance: false
tags: ${{ needs.meta.outputs.docker_repo }}/${{ matrix.image_repo }}:${{ needs.meta.outputs.version }}
build-args: |
LLAMA_CUDA_IMAGE=${{ needs.meta.outputs.llama_cuda_image }}
${{ matrix.build_args }}
cache-from: type=gha
cache-to: type=gha,mode=max