docker-build.yaml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
  15. permissions:
  16. contents: read
  17. packages: write
  18. strategy:
  19. fail-fast: false
  20. matrix:
  21. platform:
  22. - linux/amd64
  23. - linux/arm64
  24. steps:
  25. # GitHub Packages requires the entire repository name to be in lowercase
  26. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  27. - name: Set repository and image name to lowercase
  28. run: |
  29. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  30. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  31. env:
  32. IMAGE_NAME: '${{ github.repository }}'
  33. - name: Prepare
  34. run: |
  35. platform=${{ matrix.platform }}
  36. echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
  37. - name: Checkout repository
  38. uses: actions/checkout@v4
  39. - name: Set up QEMU
  40. uses: docker/setup-qemu-action@v3
  41. - name: Set up Docker Buildx
  42. uses: docker/setup-buildx-action@v3
  43. - name: Log in to the Container registry
  44. uses: docker/login-action@v3
  45. with:
  46. registry: ${{ env.REGISTRY }}
  47. username: ${{ github.actor }}
  48. password: ${{ secrets.GITHUB_TOKEN }}
  49. - name: Extract metadata for Docker images (default latest tag)
  50. id: meta
  51. uses: docker/metadata-action@v5
  52. with:
  53. images: ${{ env.FULL_IMAGE_NAME }}
  54. tags: |
  55. type=ref,event=branch
  56. type=ref,event=tag
  57. type=sha,prefix=git-
  58. type=semver,pattern={{version}}
  59. type=semver,pattern={{major}}.{{minor}}
  60. flavor: |
  61. latest=${{ github.ref == 'refs/heads/main' }}
  62. - name: Extract metadata for Docker cache
  63. id: cache-meta
  64. uses: docker/metadata-action@v5
  65. with:
  66. images: ${{ env.FULL_IMAGE_NAME }}
  67. tags: |
  68. type=ref,event=branch
  69. ${{ github.ref_type == 'tag' && 'type=raw,value=main' || '' }}
  70. flavor: |
  71. prefix=cache-${{ matrix.platform }}-
  72. latest=false
  73. - name: Build Docker image (latest)
  74. uses: docker/build-push-action@v5
  75. id: build
  76. with:
  77. context: .
  78. push: true
  79. platforms: ${{ matrix.platform }}
  80. labels: ${{ steps.meta.outputs.labels }}
  81. outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
  82. cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
  83. cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
  84. build-args: |
  85. BUILD_HASH=${{ github.sha }}
  86. - name: Export digest
  87. run: |
  88. mkdir -p /tmp/digests
  89. digest="${{ steps.build.outputs.digest }}"
  90. touch "/tmp/digests/${digest#sha256:}"
  91. - name: Upload digest
  92. uses: actions/upload-artifact@v4
  93. with:
  94. name: digests-main-${{ env.PLATFORM_PAIR }}
  95. path: /tmp/digests/*
  96. if-no-files-found: error
  97. retention-days: 1
  98. build-cuda-image:
  99. runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
  100. permissions:
  101. contents: read
  102. packages: write
  103. strategy:
  104. fail-fast: false
  105. matrix:
  106. platform:
  107. - linux/amd64
  108. - linux/arm64
  109. steps:
  110. # GitHub Packages requires the entire repository name to be in lowercase
  111. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  112. - name: Set repository and image name to lowercase
  113. run: |
  114. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  115. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  116. env:
  117. IMAGE_NAME: '${{ github.repository }}'
  118. - name: Prepare
  119. run: |
  120. platform=${{ matrix.platform }}
  121. echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
  122. - name: Checkout repository
  123. uses: actions/checkout@v4
  124. - name: Set up QEMU
  125. uses: docker/setup-qemu-action@v3
  126. - name: Set up Docker Buildx
  127. uses: docker/setup-buildx-action@v3
  128. - name: Log in to the Container registry
  129. uses: docker/login-action@v3
  130. with:
  131. registry: ${{ env.REGISTRY }}
  132. username: ${{ github.actor }}
  133. password: ${{ secrets.GITHUB_TOKEN }}
  134. - name: Extract metadata for Docker images (cuda tag)
  135. id: meta
  136. uses: docker/metadata-action@v5
  137. with:
  138. images: ${{ env.FULL_IMAGE_NAME }}
  139. tags: |
  140. type=ref,event=branch
  141. type=ref,event=tag
  142. type=sha,prefix=git-
  143. type=semver,pattern={{version}}
  144. type=semver,pattern={{major}}.{{minor}}
  145. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda
  146. flavor: |
  147. latest=${{ github.ref == 'refs/heads/main' }}
  148. suffix=-cuda,onlatest=true
  149. - name: Extract metadata for Docker cache
  150. id: cache-meta
  151. uses: docker/metadata-action@v5
  152. with:
  153. images: ${{ env.FULL_IMAGE_NAME }}
  154. tags: |
  155. type=ref,event=branch
  156. ${{ github.ref_type == 'tag' && 'type=raw,value=main' || '' }}
  157. flavor: |
  158. prefix=cache-cuda-${{ matrix.platform }}-
  159. latest=false
  160. - name: Build Docker image (cuda)
  161. uses: docker/build-push-action@v5
  162. id: build
  163. with:
  164. context: .
  165. push: true
  166. platforms: ${{ matrix.platform }}
  167. labels: ${{ steps.meta.outputs.labels }}
  168. outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
  169. cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
  170. cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
  171. build-args: |
  172. BUILD_HASH=${{ github.sha }}
  173. USE_CUDA=true
  174. - name: Export digest
  175. run: |
  176. mkdir -p /tmp/digests
  177. digest="${{ steps.build.outputs.digest }}"
  178. touch "/tmp/digests/${digest#sha256:}"
  179. - name: Upload digest
  180. uses: actions/upload-artifact@v4
  181. with:
  182. name: digests-cuda-${{ env.PLATFORM_PAIR }}
  183. path: /tmp/digests/*
  184. if-no-files-found: error
  185. retention-days: 1
  186. build-cuda126-image:
  187. runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
  188. permissions:
  189. contents: read
  190. packages: write
  191. strategy:
  192. fail-fast: false
  193. matrix:
  194. platform:
  195. - linux/amd64
  196. - linux/arm64
  197. steps:
  198. # GitHub Packages requires the entire repository name to be in lowercase
  199. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  200. - name: Set repository and image name to lowercase
  201. run: |
  202. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  203. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  204. env:
  205. IMAGE_NAME: '${{ github.repository }}'
  206. - name: Prepare
  207. run: |
  208. platform=${{ matrix.platform }}
  209. echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
  210. - name: Checkout repository
  211. uses: actions/checkout@v4
  212. - name: Set up QEMU
  213. uses: docker/setup-qemu-action@v3
  214. - name: Set up Docker Buildx
  215. uses: docker/setup-buildx-action@v3
  216. - name: Log in to the Container registry
  217. uses: docker/login-action@v3
  218. with:
  219. registry: ${{ env.REGISTRY }}
  220. username: ${{ github.actor }}
  221. password: ${{ secrets.GITHUB_TOKEN }}
  222. - name: Extract metadata for Docker images (cuda126 tag)
  223. id: meta
  224. uses: docker/metadata-action@v5
  225. with:
  226. images: ${{ env.FULL_IMAGE_NAME }}
  227. tags: |
  228. type=ref,event=branch
  229. type=ref,event=tag
  230. type=sha,prefix=git-
  231. type=semver,pattern={{version}}
  232. type=semver,pattern={{major}}.{{minor}}
  233. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda126
  234. flavor: |
  235. latest=${{ github.ref == 'refs/heads/main' }}
  236. suffix=-cuda126,onlatest=true
  237. - name: Extract metadata for Docker cache
  238. id: cache-meta
  239. uses: docker/metadata-action@v5
  240. with:
  241. images: ${{ env.FULL_IMAGE_NAME }}
  242. tags: |
  243. type=ref,event=branch
  244. ${{ github.ref_type == 'tag' && 'type=raw,value=main' || '' }}
  245. flavor: |
  246. prefix=cache-cuda126-${{ matrix.platform }}-
  247. latest=false
  248. - name: Build Docker image (cuda126)
  249. uses: docker/build-push-action@v5
  250. id: build
  251. with:
  252. context: .
  253. push: true
  254. platforms: ${{ matrix.platform }}
  255. labels: ${{ steps.meta.outputs.labels }}
  256. outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
  257. cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
  258. cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
  259. build-args: |
  260. BUILD_HASH=${{ github.sha }}
  261. USE_CUDA=true
  262. USE_CUDA_VER=cu126
  263. - name: Export digest
  264. run: |
  265. mkdir -p /tmp/digests
  266. digest="${{ steps.build.outputs.digest }}"
  267. touch "/tmp/digests/${digest#sha256:}"
  268. - name: Upload digest
  269. uses: actions/upload-artifact@v4
  270. with:
  271. name: digests-cuda126-${{ env.PLATFORM_PAIR }}
  272. path: /tmp/digests/*
  273. if-no-files-found: error
  274. retention-days: 1
  275. build-ollama-image:
  276. runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
  277. permissions:
  278. contents: read
  279. packages: write
  280. strategy:
  281. fail-fast: false
  282. matrix:
  283. platform:
  284. - linux/amd64
  285. - linux/arm64
  286. steps:
  287. # GitHub Packages requires the entire repository name to be in lowercase
  288. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  289. - name: Set repository and image name to lowercase
  290. run: |
  291. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  292. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  293. env:
  294. IMAGE_NAME: '${{ github.repository }}'
  295. - name: Prepare
  296. run: |
  297. platform=${{ matrix.platform }}
  298. echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
  299. - name: Checkout repository
  300. uses: actions/checkout@v4
  301. - name: Set up QEMU
  302. uses: docker/setup-qemu-action@v3
  303. - name: Set up Docker Buildx
  304. uses: docker/setup-buildx-action@v3
  305. - name: Log in to the Container registry
  306. uses: docker/login-action@v3
  307. with:
  308. registry: ${{ env.REGISTRY }}
  309. username: ${{ github.actor }}
  310. password: ${{ secrets.GITHUB_TOKEN }}
  311. - name: Extract metadata for Docker images (ollama tag)
  312. id: meta
  313. uses: docker/metadata-action@v5
  314. with:
  315. images: ${{ env.FULL_IMAGE_NAME }}
  316. tags: |
  317. type=ref,event=branch
  318. type=ref,event=tag
  319. type=sha,prefix=git-
  320. type=semver,pattern={{version}}
  321. type=semver,pattern={{major}}.{{minor}}
  322. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=ollama
  323. flavor: |
  324. latest=${{ github.ref == 'refs/heads/main' }}
  325. suffix=-ollama,onlatest=true
  326. - name: Extract metadata for Docker cache
  327. id: cache-meta
  328. uses: docker/metadata-action@v5
  329. with:
  330. images: ${{ env.FULL_IMAGE_NAME }}
  331. tags: |
  332. type=ref,event=branch
  333. ${{ github.ref_type == 'tag' && 'type=raw,value=main' || '' }}
  334. flavor: |
  335. prefix=cache-ollama-${{ matrix.platform }}-
  336. latest=false
  337. - name: Build Docker image (ollama)
  338. uses: docker/build-push-action@v5
  339. id: build
  340. with:
  341. context: .
  342. push: true
  343. platforms: ${{ matrix.platform }}
  344. labels: ${{ steps.meta.outputs.labels }}
  345. outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
  346. cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
  347. cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
  348. build-args: |
  349. BUILD_HASH=${{ github.sha }}
  350. USE_OLLAMA=true
  351. - name: Export digest
  352. run: |
  353. mkdir -p /tmp/digests
  354. digest="${{ steps.build.outputs.digest }}"
  355. touch "/tmp/digests/${digest#sha256:}"
  356. - name: Upload digest
  357. uses: actions/upload-artifact@v4
  358. with:
  359. name: digests-ollama-${{ env.PLATFORM_PAIR }}
  360. path: /tmp/digests/*
  361. if-no-files-found: error
  362. retention-days: 1
  363. merge-main-images:
  364. runs-on: ubuntu-latest
  365. needs: [build-main-image]
  366. steps:
  367. # GitHub Packages requires the entire repository name to be in lowercase
  368. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  369. - name: Set repository and image name to lowercase
  370. run: |
  371. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  372. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  373. env:
  374. IMAGE_NAME: '${{ github.repository }}'
  375. - name: Download digests
  376. uses: actions/download-artifact@v4
  377. with:
  378. pattern: digests-main-*
  379. path: /tmp/digests
  380. merge-multiple: true
  381. - name: Set up Docker Buildx
  382. uses: docker/setup-buildx-action@v3
  383. - name: Log in to the Container registry
  384. uses: docker/login-action@v3
  385. with:
  386. registry: ${{ env.REGISTRY }}
  387. username: ${{ github.actor }}
  388. password: ${{ secrets.GITHUB_TOKEN }}
  389. - name: Extract metadata for Docker images (default latest tag)
  390. id: meta
  391. uses: docker/metadata-action@v5
  392. with:
  393. images: ${{ env.FULL_IMAGE_NAME }}
  394. tags: |
  395. type=ref,event=branch
  396. type=ref,event=tag
  397. type=sha,prefix=git-
  398. type=semver,pattern={{version}}
  399. type=semver,pattern={{major}}.{{minor}}
  400. flavor: |
  401. latest=${{ github.ref == 'refs/heads/main' }}
  402. - name: Create manifest list and push
  403. working-directory: /tmp/digests
  404. run: |
  405. docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  406. $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
  407. - name: Inspect image
  408. run: |
  409. docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
  410. merge-cuda-images:
  411. runs-on: ubuntu-latest
  412. needs: [build-cuda-image]
  413. steps:
  414. # GitHub Packages requires the entire repository name to be in lowercase
  415. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  416. - name: Set repository and image name to lowercase
  417. run: |
  418. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  419. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  420. env:
  421. IMAGE_NAME: '${{ github.repository }}'
  422. - name: Download digests
  423. uses: actions/download-artifact@v4
  424. with:
  425. pattern: digests-cuda-*
  426. path: /tmp/digests
  427. merge-multiple: true
  428. - name: Set up Docker Buildx
  429. uses: docker/setup-buildx-action@v3
  430. - name: Log in to the Container registry
  431. uses: docker/login-action@v3
  432. with:
  433. registry: ${{ env.REGISTRY }}
  434. username: ${{ github.actor }}
  435. password: ${{ secrets.GITHUB_TOKEN }}
  436. - name: Extract metadata for Docker images (default latest tag)
  437. id: meta
  438. uses: docker/metadata-action@v5
  439. with:
  440. images: ${{ env.FULL_IMAGE_NAME }}
  441. tags: |
  442. type=ref,event=branch
  443. type=ref,event=tag
  444. type=sha,prefix=git-
  445. type=semver,pattern={{version}}
  446. type=semver,pattern={{major}}.{{minor}}
  447. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda
  448. flavor: |
  449. latest=${{ github.ref == 'refs/heads/main' }}
  450. suffix=-cuda,onlatest=true
  451. - name: Create manifest list and push
  452. working-directory: /tmp/digests
  453. run: |
  454. docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  455. $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
  456. - name: Inspect image
  457. run: |
  458. docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
  459. merge-cuda126-images:
  460. runs-on: ubuntu-latest
  461. needs: [build-cuda126-image]
  462. steps:
  463. # GitHub Packages requires the entire repository name to be in lowercase
  464. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  465. - name: Set repository and image name to lowercase
  466. run: |
  467. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  468. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  469. env:
  470. IMAGE_NAME: '${{ github.repository }}'
  471. - name: Download digests
  472. uses: actions/download-artifact@v4
  473. with:
  474. pattern: digests-cuda126-*
  475. path: /tmp/digests
  476. merge-multiple: true
  477. - name: Set up Docker Buildx
  478. uses: docker/setup-buildx-action@v3
  479. - name: Log in to the Container registry
  480. uses: docker/login-action@v3
  481. with:
  482. registry: ${{ env.REGISTRY }}
  483. username: ${{ github.actor }}
  484. password: ${{ secrets.GITHUB_TOKEN }}
  485. - name: Extract metadata for Docker images (default latest tag)
  486. id: meta
  487. uses: docker/metadata-action@v5
  488. with:
  489. images: ${{ env.FULL_IMAGE_NAME }}
  490. tags: |
  491. type=ref,event=branch
  492. type=ref,event=tag
  493. type=sha,prefix=git-
  494. type=semver,pattern={{version}}
  495. type=semver,pattern={{major}}.{{minor}}
  496. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda126
  497. flavor: |
  498. latest=${{ github.ref == 'refs/heads/main' }}
  499. suffix=-cuda126,onlatest=true
  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-ollama-images:
  509. runs-on: ubuntu-latest
  510. needs: [build-ollama-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-ollama-*
  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 ollama 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=ollama
  546. flavor: |
  547. latest=${{ github.ref == 'refs/heads/main' }}
  548. suffix=-ollama,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 }}