docker-build.yaml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. name: Create and publish Docker images with specific build args
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - main
  7. - dev
  8. tags:
  9. - v*
  10. env:
  11. REGISTRY: ghcr.io
  12. jobs:
  13. build-main-image:
  14. runs-on: ${{ matrix.runner }}
  15. permissions:
  16. contents: read
  17. packages: write
  18. strategy:
  19. fail-fast: false
  20. matrix:
  21. include:
  22. - platform: linux/amd64
  23. runner: ubuntu-latest
  24. - platform: linux/arm64
  25. runner: ubuntu-24.04-arm
  26. steps:
  27. # GitHub Packages requires the entire repository name to be in lowercase
  28. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  29. - name: Set repository and image name to lowercase
  30. run: |
  31. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  32. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  33. env:
  34. IMAGE_NAME: '${{ github.repository }}'
  35. - name: Prepare
  36. run: |
  37. platform=${{ matrix.platform }}
  38. echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
  39. - name: Checkout repository
  40. uses: actions/checkout@v4
  41. - name: Set up QEMU
  42. uses: docker/setup-qemu-action@v3
  43. - name: Set up Docker Buildx
  44. uses: docker/setup-buildx-action@v3
  45. - name: Log in to the Container registry
  46. uses: docker/login-action@v3
  47. with:
  48. registry: ${{ env.REGISTRY }}
  49. username: ${{ github.actor }}
  50. password: ${{ secrets.GITHUB_TOKEN }}
  51. - name: Extract metadata for Docker images (default latest tag)
  52. id: meta
  53. uses: docker/metadata-action@v5
  54. with:
  55. images: ${{ env.FULL_IMAGE_NAME }}
  56. tags: |
  57. type=ref,event=branch
  58. type=ref,event=tag
  59. type=sha,prefix=git-
  60. type=semver,pattern={{version}}
  61. type=semver,pattern={{major}}.{{minor}}
  62. flavor: |
  63. latest=${{ github.ref == 'refs/heads/main' }}
  64. - name: Extract metadata for Docker cache
  65. id: cache-meta
  66. uses: docker/metadata-action@v5
  67. with:
  68. images: ${{ env.FULL_IMAGE_NAME }}
  69. tags: |
  70. type=ref,event=branch
  71. ${{ github.ref_type == 'tag' && 'type=raw,value=main' || '' }}
  72. flavor: |
  73. prefix=cache-${{ matrix.platform }}-
  74. latest=false
  75. - name: Build Docker image (latest)
  76. uses: docker/build-push-action@v5
  77. id: build
  78. with:
  79. context: .
  80. push: true
  81. platforms: ${{ matrix.platform }}
  82. labels: ${{ steps.meta.outputs.labels }}
  83. outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
  84. cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
  85. cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
  86. build-args: |
  87. BUILD_HASH=${{ github.sha }}
  88. - name: Export digest
  89. run: |
  90. mkdir -p /tmp/digests
  91. digest="${{ steps.build.outputs.digest }}"
  92. touch "/tmp/digests/${digest#sha256:}"
  93. - name: Upload digest
  94. uses: actions/upload-artifact@v4
  95. with:
  96. name: digests-main-${{ env.PLATFORM_PAIR }}
  97. path: /tmp/digests/*
  98. if-no-files-found: error
  99. retention-days: 1
  100. build-cuda-image:
  101. runs-on: ${{ matrix.runner }}
  102. permissions:
  103. contents: read
  104. packages: write
  105. strategy:
  106. fail-fast: false
  107. matrix:
  108. include:
  109. - platform: linux/amd64
  110. runner: ubuntu-latest
  111. - platform: linux/arm64
  112. runner: ubuntu-24.04-arm
  113. steps:
  114. # GitHub Packages requires the entire repository name to be in lowercase
  115. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  116. - name: Set repository and image name to lowercase
  117. run: |
  118. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  119. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  120. env:
  121. IMAGE_NAME: '${{ github.repository }}'
  122. - name: Prepare
  123. run: |
  124. platform=${{ matrix.platform }}
  125. echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
  126. - name: Checkout repository
  127. uses: actions/checkout@v4
  128. - name: Set up QEMU
  129. uses: docker/setup-qemu-action@v3
  130. - name: Set up Docker Buildx
  131. uses: docker/setup-buildx-action@v3
  132. - name: Log in to the Container registry
  133. uses: docker/login-action@v3
  134. with:
  135. registry: ${{ env.REGISTRY }}
  136. username: ${{ github.actor }}
  137. password: ${{ secrets.GITHUB_TOKEN }}
  138. - name: Extract metadata for Docker images (cuda tag)
  139. id: meta
  140. uses: docker/metadata-action@v5
  141. with:
  142. images: ${{ env.FULL_IMAGE_NAME }}
  143. tags: |
  144. type=ref,event=branch
  145. type=ref,event=tag
  146. type=sha,prefix=git-
  147. type=semver,pattern={{version}}
  148. type=semver,pattern={{major}}.{{minor}}
  149. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda
  150. flavor: |
  151. latest=${{ github.ref == 'refs/heads/main' }}
  152. suffix=-cuda,onlatest=true
  153. - name: Extract metadata for Docker cache
  154. id: cache-meta
  155. uses: docker/metadata-action@v5
  156. with:
  157. images: ${{ env.FULL_IMAGE_NAME }}
  158. tags: |
  159. type=ref,event=branch
  160. ${{ github.ref_type == 'tag' && 'type=raw,value=main' || '' }}
  161. flavor: |
  162. prefix=cache-cuda-${{ matrix.platform }}-
  163. latest=false
  164. - name: Build Docker image (cuda)
  165. uses: docker/build-push-action@v5
  166. id: build
  167. with:
  168. context: .
  169. push: true
  170. platforms: ${{ matrix.platform }}
  171. labels: ${{ steps.meta.outputs.labels }}
  172. outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
  173. cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
  174. cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
  175. build-args: |
  176. BUILD_HASH=${{ github.sha }}
  177. USE_CUDA=true
  178. - name: Export digest
  179. run: |
  180. mkdir -p /tmp/digests
  181. digest="${{ steps.build.outputs.digest }}"
  182. touch "/tmp/digests/${digest#sha256:}"
  183. - name: Upload digest
  184. uses: actions/upload-artifact@v4
  185. with:
  186. name: digests-cuda-${{ env.PLATFORM_PAIR }}
  187. path: /tmp/digests/*
  188. if-no-files-found: error
  189. retention-days: 1
  190. build-cuda126-image:
  191. runs-on: ${{ matrix.runner }}
  192. permissions:
  193. contents: read
  194. packages: write
  195. strategy:
  196. fail-fast: false
  197. matrix:
  198. include:
  199. - platform: linux/amd64
  200. runner: ubuntu-latest
  201. - platform: linux/arm64
  202. runner: ubuntu-24.04-arm
  203. steps:
  204. # GitHub Packages requires the entire repository name to be in lowercase
  205. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  206. - name: Set repository and image name to lowercase
  207. run: |
  208. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  209. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  210. env:
  211. IMAGE_NAME: '${{ github.repository }}'
  212. - name: Prepare
  213. run: |
  214. platform=${{ matrix.platform }}
  215. echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
  216. - name: Checkout repository
  217. uses: actions/checkout@v4
  218. - name: Set up QEMU
  219. uses: docker/setup-qemu-action@v3
  220. - name: Set up Docker Buildx
  221. uses: docker/setup-buildx-action@v3
  222. - name: Log in to the Container registry
  223. uses: docker/login-action@v3
  224. with:
  225. registry: ${{ env.REGISTRY }}
  226. username: ${{ github.actor }}
  227. password: ${{ secrets.GITHUB_TOKEN }}
  228. - name: Extract metadata for Docker images (cuda126 tag)
  229. id: meta
  230. uses: docker/metadata-action@v5
  231. with:
  232. images: ${{ env.FULL_IMAGE_NAME }}
  233. tags: |
  234. type=ref,event=branch
  235. type=ref,event=tag
  236. type=sha,prefix=git-
  237. type=semver,pattern={{version}}
  238. type=semver,pattern={{major}}.{{minor}}
  239. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda126
  240. flavor: |
  241. latest=${{ github.ref == 'refs/heads/main' }}
  242. suffix=-cuda126,onlatest=true
  243. - name: Extract metadata for Docker cache
  244. id: cache-meta
  245. uses: docker/metadata-action@v5
  246. with:
  247. images: ${{ env.FULL_IMAGE_NAME }}
  248. tags: |
  249. type=ref,event=branch
  250. ${{ github.ref_type == 'tag' && 'type=raw,value=main' || '' }}
  251. flavor: |
  252. prefix=cache-cuda126-${{ matrix.platform }}-
  253. latest=false
  254. - name: Build Docker image (cuda126)
  255. uses: docker/build-push-action@v5
  256. id: build
  257. with:
  258. context: .
  259. push: true
  260. platforms: ${{ matrix.platform }}
  261. labels: ${{ steps.meta.outputs.labels }}
  262. outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
  263. cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
  264. cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
  265. build-args: |
  266. BUILD_HASH=${{ github.sha }}
  267. USE_CUDA=true
  268. USE_CUDA_VER=cu126
  269. - name: Export digest
  270. run: |
  271. mkdir -p /tmp/digests
  272. digest="${{ steps.build.outputs.digest }}"
  273. touch "/tmp/digests/${digest#sha256:}"
  274. - name: Upload digest
  275. uses: actions/upload-artifact@v4
  276. with:
  277. name: digests-cuda126-${{ env.PLATFORM_PAIR }}
  278. path: /tmp/digests/*
  279. if-no-files-found: error
  280. retention-days: 1
  281. build-ollama-image:
  282. runs-on: ${{ matrix.runner }}
  283. permissions:
  284. contents: read
  285. packages: write
  286. strategy:
  287. fail-fast: false
  288. matrix:
  289. include:
  290. - platform: linux/amd64
  291. runner: ubuntu-latest
  292. - platform: linux/arm64
  293. runner: ubuntu-24.04-arm
  294. steps:
  295. # GitHub Packages requires the entire repository name to be in lowercase
  296. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  297. - name: Set repository and image name to lowercase
  298. run: |
  299. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  300. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  301. env:
  302. IMAGE_NAME: '${{ github.repository }}'
  303. - name: Prepare
  304. run: |
  305. platform=${{ matrix.platform }}
  306. echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
  307. - name: Checkout repository
  308. uses: actions/checkout@v4
  309. - name: Set up QEMU
  310. uses: docker/setup-qemu-action@v3
  311. - name: Set up Docker Buildx
  312. uses: docker/setup-buildx-action@v3
  313. - name: Log in to the Container registry
  314. uses: docker/login-action@v3
  315. with:
  316. registry: ${{ env.REGISTRY }}
  317. username: ${{ github.actor }}
  318. password: ${{ secrets.GITHUB_TOKEN }}
  319. - name: Extract metadata for Docker images (ollama tag)
  320. id: meta
  321. uses: docker/metadata-action@v5
  322. with:
  323. images: ${{ env.FULL_IMAGE_NAME }}
  324. tags: |
  325. type=ref,event=branch
  326. type=ref,event=tag
  327. type=sha,prefix=git-
  328. type=semver,pattern={{version}}
  329. type=semver,pattern={{major}}.{{minor}}
  330. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=ollama
  331. flavor: |
  332. latest=${{ github.ref == 'refs/heads/main' }}
  333. suffix=-ollama,onlatest=true
  334. - name: Extract metadata for Docker cache
  335. id: cache-meta
  336. uses: docker/metadata-action@v5
  337. with:
  338. images: ${{ env.FULL_IMAGE_NAME }}
  339. tags: |
  340. type=ref,event=branch
  341. ${{ github.ref_type == 'tag' && 'type=raw,value=main' || '' }}
  342. flavor: |
  343. prefix=cache-ollama-${{ matrix.platform }}-
  344. latest=false
  345. - name: Build Docker image (ollama)
  346. uses: docker/build-push-action@v5
  347. id: build
  348. with:
  349. context: .
  350. push: true
  351. platforms: ${{ matrix.platform }}
  352. labels: ${{ steps.meta.outputs.labels }}
  353. outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
  354. cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
  355. cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
  356. build-args: |
  357. BUILD_HASH=${{ github.sha }}
  358. USE_OLLAMA=true
  359. - name: Export digest
  360. run: |
  361. mkdir -p /tmp/digests
  362. digest="${{ steps.build.outputs.digest }}"
  363. touch "/tmp/digests/${digest#sha256:}"
  364. - name: Upload digest
  365. uses: actions/upload-artifact@v4
  366. with:
  367. name: digests-ollama-${{ env.PLATFORM_PAIR }}
  368. path: /tmp/digests/*
  369. if-no-files-found: error
  370. retention-days: 1
  371. build-slim-image:
  372. runs-on: ${{ matrix.runner }}
  373. permissions:
  374. contents: read
  375. packages: write
  376. strategy:
  377. fail-fast: false
  378. matrix:
  379. include:
  380. - platform: linux/amd64
  381. runner: ubuntu-latest
  382. - platform: linux/arm64
  383. runner: ubuntu-24.04-arm
  384. steps:
  385. # GitHub Packages requires the entire repository name to be in lowercase
  386. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  387. - name: Set repository and image name to lowercase
  388. run: |
  389. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  390. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  391. env:
  392. IMAGE_NAME: '${{ github.repository }}'
  393. - name: Prepare
  394. run: |
  395. platform=${{ matrix.platform }}
  396. echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
  397. - name: Checkout repository
  398. uses: actions/checkout@v4
  399. - name: Set up QEMU
  400. uses: docker/setup-qemu-action@v3
  401. - name: Set up Docker Buildx
  402. uses: docker/setup-buildx-action@v3
  403. - name: Log in to the Container registry
  404. uses: docker/login-action@v3
  405. with:
  406. registry: ${{ env.REGISTRY }}
  407. username: ${{ github.actor }}
  408. password: ${{ secrets.GITHUB_TOKEN }}
  409. - name: Extract metadata for Docker images (slim tag)
  410. id: meta
  411. uses: docker/metadata-action@v5
  412. with:
  413. images: ${{ env.FULL_IMAGE_NAME }}
  414. tags: |
  415. type=ref,event=branch
  416. type=ref,event=tag
  417. type=sha,prefix=git-
  418. type=semver,pattern={{version}}
  419. type=semver,pattern={{major}}.{{minor}}
  420. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=slim
  421. flavor: |
  422. latest=${{ github.ref == 'refs/heads/main' }}
  423. suffix=-slim,onlatest=true
  424. - name: Extract metadata for Docker cache
  425. id: cache-meta
  426. uses: docker/metadata-action@v5
  427. with:
  428. images: ${{ env.FULL_IMAGE_NAME }}
  429. tags: |
  430. type=ref,event=branch
  431. ${{ github.ref_type == 'tag' && 'type=raw,value=main' || '' }}
  432. flavor: |
  433. prefix=cache-slim-${{ matrix.platform }}-
  434. latest=false
  435. - name: Build Docker image (slim)
  436. uses: docker/build-push-action@v5
  437. id: build
  438. with:
  439. context: .
  440. push: true
  441. platforms: ${{ matrix.platform }}
  442. labels: ${{ steps.meta.outputs.labels }}
  443. outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
  444. cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
  445. cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
  446. build-args: |
  447. BUILD_HASH=${{ github.sha }}
  448. USE_SLIM=true
  449. - name: Export digest
  450. run: |
  451. mkdir -p /tmp/digests
  452. digest="${{ steps.build.outputs.digest }}"
  453. touch "/tmp/digests/${digest#sha256:}"
  454. - name: Upload digest
  455. uses: actions/upload-artifact@v4
  456. with:
  457. name: digests-slim-${{ env.PLATFORM_PAIR }}
  458. path: /tmp/digests/*
  459. if-no-files-found: error
  460. retention-days: 1
  461. merge-main-images:
  462. runs-on: ubuntu-latest
  463. needs: [build-main-image]
  464. steps:
  465. # GitHub Packages requires the entire repository name to be in lowercase
  466. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  467. - name: Set repository and image name to lowercase
  468. run: |
  469. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  470. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  471. env:
  472. IMAGE_NAME: '${{ github.repository }}'
  473. - name: Download digests
  474. uses: actions/download-artifact@v4
  475. with:
  476. pattern: digests-main-*
  477. path: /tmp/digests
  478. merge-multiple: true
  479. - name: Set up Docker Buildx
  480. uses: docker/setup-buildx-action@v3
  481. - name: Log in to the Container registry
  482. uses: docker/login-action@v3
  483. with:
  484. registry: ${{ env.REGISTRY }}
  485. username: ${{ github.actor }}
  486. password: ${{ secrets.GITHUB_TOKEN }}
  487. - name: Extract metadata for Docker images (default latest tag)
  488. id: meta
  489. uses: docker/metadata-action@v5
  490. with:
  491. images: ${{ env.FULL_IMAGE_NAME }}
  492. tags: |
  493. type=ref,event=branch
  494. type=ref,event=tag
  495. type=sha,prefix=git-
  496. type=semver,pattern={{version}}
  497. type=semver,pattern={{major}}.{{minor}}
  498. flavor: |
  499. latest=${{ github.ref == 'refs/heads/main' }}
  500. - name: Create manifest list and push
  501. working-directory: /tmp/digests
  502. run: |
  503. docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  504. $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
  505. - name: Inspect image
  506. run: |
  507. docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
  508. merge-cuda-images:
  509. runs-on: ubuntu-latest
  510. needs: [build-cuda-image]
  511. steps:
  512. # GitHub Packages requires the entire repository name to be in lowercase
  513. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  514. - name: Set repository and image name to lowercase
  515. run: |
  516. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  517. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  518. env:
  519. IMAGE_NAME: '${{ github.repository }}'
  520. - name: Download digests
  521. uses: actions/download-artifact@v4
  522. with:
  523. pattern: digests-cuda-*
  524. path: /tmp/digests
  525. merge-multiple: true
  526. - name: Set up Docker Buildx
  527. uses: docker/setup-buildx-action@v3
  528. - name: Log in to the Container registry
  529. uses: docker/login-action@v3
  530. with:
  531. registry: ${{ env.REGISTRY }}
  532. username: ${{ github.actor }}
  533. password: ${{ secrets.GITHUB_TOKEN }}
  534. - name: Extract metadata for Docker images (default latest tag)
  535. id: meta
  536. uses: docker/metadata-action@v5
  537. with:
  538. images: ${{ env.FULL_IMAGE_NAME }}
  539. tags: |
  540. type=ref,event=branch
  541. type=ref,event=tag
  542. type=sha,prefix=git-
  543. type=semver,pattern={{version}}
  544. type=semver,pattern={{major}}.{{minor}}
  545. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda
  546. flavor: |
  547. latest=${{ github.ref == 'refs/heads/main' }}
  548. suffix=-cuda,onlatest=true
  549. - name: Create manifest list and push
  550. working-directory: /tmp/digests
  551. run: |
  552. docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  553. $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
  554. - name: Inspect image
  555. run: |
  556. docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
  557. merge-cuda126-images:
  558. runs-on: ubuntu-latest
  559. needs: [build-cuda126-image]
  560. steps:
  561. # GitHub Packages requires the entire repository name to be in lowercase
  562. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  563. - name: Set repository and image name to lowercase
  564. run: |
  565. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  566. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  567. env:
  568. IMAGE_NAME: '${{ github.repository }}'
  569. - name: Download digests
  570. uses: actions/download-artifact@v4
  571. with:
  572. pattern: digests-cuda126-*
  573. path: /tmp/digests
  574. merge-multiple: true
  575. - name: Set up Docker Buildx
  576. uses: docker/setup-buildx-action@v3
  577. - name: Log in to the Container registry
  578. uses: docker/login-action@v3
  579. with:
  580. registry: ${{ env.REGISTRY }}
  581. username: ${{ github.actor }}
  582. password: ${{ secrets.GITHUB_TOKEN }}
  583. - name: Extract metadata for Docker images (default latest tag)
  584. id: meta
  585. uses: docker/metadata-action@v5
  586. with:
  587. images: ${{ env.FULL_IMAGE_NAME }}
  588. tags: |
  589. type=ref,event=branch
  590. type=ref,event=tag
  591. type=sha,prefix=git-
  592. type=semver,pattern={{version}}
  593. type=semver,pattern={{major}}.{{minor}}
  594. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda126
  595. flavor: |
  596. latest=${{ github.ref == 'refs/heads/main' }}
  597. suffix=-cuda126,onlatest=true
  598. - name: Create manifest list and push
  599. working-directory: /tmp/digests
  600. run: |
  601. docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  602. $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
  603. - name: Inspect image
  604. run: |
  605. docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
  606. merge-ollama-images:
  607. runs-on: ubuntu-latest
  608. needs: [build-ollama-image]
  609. steps:
  610. # GitHub Packages requires the entire repository name to be in lowercase
  611. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  612. - name: Set repository and image name to lowercase
  613. run: |
  614. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  615. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  616. env:
  617. IMAGE_NAME: '${{ github.repository }}'
  618. - name: Download digests
  619. uses: actions/download-artifact@v4
  620. with:
  621. pattern: digests-ollama-*
  622. path: /tmp/digests
  623. merge-multiple: true
  624. - name: Set up Docker Buildx
  625. uses: docker/setup-buildx-action@v3
  626. - name: Log in to the Container registry
  627. uses: docker/login-action@v3
  628. with:
  629. registry: ${{ env.REGISTRY }}
  630. username: ${{ github.actor }}
  631. password: ${{ secrets.GITHUB_TOKEN }}
  632. - name: Extract metadata for Docker images (default ollama tag)
  633. id: meta
  634. uses: docker/metadata-action@v5
  635. with:
  636. images: ${{ env.FULL_IMAGE_NAME }}
  637. tags: |
  638. type=ref,event=branch
  639. type=ref,event=tag
  640. type=sha,prefix=git-
  641. type=semver,pattern={{version}}
  642. type=semver,pattern={{major}}.{{minor}}
  643. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=ollama
  644. flavor: |
  645. latest=${{ github.ref == 'refs/heads/main' }}
  646. suffix=-ollama,onlatest=true
  647. - name: Create manifest list and push
  648. working-directory: /tmp/digests
  649. run: |
  650. docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  651. $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
  652. - name: Inspect image
  653. run: |
  654. docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
  655. merge-slim-images:
  656. runs-on: ubuntu-latest
  657. needs: [build-slim-image]
  658. steps:
  659. # GitHub Packages requires the entire repository name to be in lowercase
  660. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  661. - name: Set repository and image name to lowercase
  662. run: |
  663. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  664. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  665. env:
  666. IMAGE_NAME: '${{ github.repository }}'
  667. - name: Download digests
  668. uses: actions/download-artifact@v4
  669. with:
  670. pattern: digests-slim-*
  671. path: /tmp/digests
  672. merge-multiple: true
  673. - name: Set up Docker Buildx
  674. uses: docker/setup-buildx-action@v3
  675. - name: Log in to the Container registry
  676. uses: docker/login-action@v3
  677. with:
  678. registry: ${{ env.REGISTRY }}
  679. username: ${{ github.actor }}
  680. password: ${{ secrets.GITHUB_TOKEN }}
  681. - name: Extract metadata for Docker images (default slim tag)
  682. id: meta
  683. uses: docker/metadata-action@v5
  684. with:
  685. images: ${{ env.FULL_IMAGE_NAME }}
  686. tags: |
  687. type=ref,event=branch
  688. type=ref,event=tag
  689. type=sha,prefix=git-
  690. type=semver,pattern={{version}}
  691. type=semver,pattern={{major}}.{{minor}}
  692. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=slim
  693. flavor: |
  694. latest=${{ github.ref == 'refs/heads/main' }}
  695. suffix=-slim,onlatest=true
  696. - name: Create manifest list and push
  697. working-directory: /tmp/digests
  698. run: |
  699. docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  700. $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
  701. - name: Inspect image
  702. run: |
  703. docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}