docker-build.yaml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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. merge-main-images:
  372. runs-on: ubuntu-latest
  373. needs: [build-main-image]
  374. steps:
  375. # GitHub Packages requires the entire repository name to be in lowercase
  376. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  377. - name: Set repository and image name to lowercase
  378. run: |
  379. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  380. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  381. env:
  382. IMAGE_NAME: '${{ github.repository }}'
  383. - name: Download digests
  384. uses: actions/download-artifact@v4
  385. with:
  386. pattern: digests-main-*
  387. path: /tmp/digests
  388. merge-multiple: true
  389. - name: Set up Docker Buildx
  390. uses: docker/setup-buildx-action@v3
  391. - name: Log in to the Container registry
  392. uses: docker/login-action@v3
  393. with:
  394. registry: ${{ env.REGISTRY }}
  395. username: ${{ github.actor }}
  396. password: ${{ secrets.GITHUB_TOKEN }}
  397. - name: Extract metadata for Docker images (default latest tag)
  398. id: meta
  399. uses: docker/metadata-action@v5
  400. with:
  401. images: ${{ env.FULL_IMAGE_NAME }}
  402. tags: |
  403. type=ref,event=branch
  404. type=ref,event=tag
  405. type=sha,prefix=git-
  406. type=semver,pattern={{version}}
  407. type=semver,pattern={{major}}.{{minor}}
  408. flavor: |
  409. latest=${{ github.ref == 'refs/heads/main' }}
  410. - name: Create manifest list and push
  411. working-directory: /tmp/digests
  412. run: |
  413. docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  414. $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
  415. - name: Inspect image
  416. run: |
  417. docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
  418. merge-cuda-images:
  419. runs-on: ubuntu-latest
  420. needs: [build-cuda-image]
  421. steps:
  422. # GitHub Packages requires the entire repository name to be in lowercase
  423. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  424. - name: Set repository and image name to lowercase
  425. run: |
  426. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  427. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  428. env:
  429. IMAGE_NAME: '${{ github.repository }}'
  430. - name: Download digests
  431. uses: actions/download-artifact@v4
  432. with:
  433. pattern: digests-cuda-*
  434. path: /tmp/digests
  435. merge-multiple: true
  436. - name: Set up Docker Buildx
  437. uses: docker/setup-buildx-action@v3
  438. - name: Log in to the Container registry
  439. uses: docker/login-action@v3
  440. with:
  441. registry: ${{ env.REGISTRY }}
  442. username: ${{ github.actor }}
  443. password: ${{ secrets.GITHUB_TOKEN }}
  444. - name: Extract metadata for Docker images (default latest tag)
  445. id: meta
  446. uses: docker/metadata-action@v5
  447. with:
  448. images: ${{ env.FULL_IMAGE_NAME }}
  449. tags: |
  450. type=ref,event=branch
  451. type=ref,event=tag
  452. type=sha,prefix=git-
  453. type=semver,pattern={{version}}
  454. type=semver,pattern={{major}}.{{minor}}
  455. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda
  456. flavor: |
  457. latest=${{ github.ref == 'refs/heads/main' }}
  458. suffix=-cuda,onlatest=true
  459. - name: Create manifest list and push
  460. working-directory: /tmp/digests
  461. run: |
  462. docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  463. $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
  464. - name: Inspect image
  465. run: |
  466. docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
  467. merge-cuda126-images:
  468. runs-on: ubuntu-latest
  469. needs: [build-cuda126-image]
  470. steps:
  471. # GitHub Packages requires the entire repository name to be in lowercase
  472. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  473. - name: Set repository and image name to lowercase
  474. run: |
  475. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  476. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  477. env:
  478. IMAGE_NAME: '${{ github.repository }}'
  479. - name: Download digests
  480. uses: actions/download-artifact@v4
  481. with:
  482. pattern: digests-cuda126-*
  483. path: /tmp/digests
  484. merge-multiple: true
  485. - name: Set up Docker Buildx
  486. uses: docker/setup-buildx-action@v3
  487. - name: Log in to the Container registry
  488. uses: docker/login-action@v3
  489. with:
  490. registry: ${{ env.REGISTRY }}
  491. username: ${{ github.actor }}
  492. password: ${{ secrets.GITHUB_TOKEN }}
  493. - name: Extract metadata for Docker images (default latest tag)
  494. id: meta
  495. uses: docker/metadata-action@v5
  496. with:
  497. images: ${{ env.FULL_IMAGE_NAME }}
  498. tags: |
  499. type=ref,event=branch
  500. type=ref,event=tag
  501. type=sha,prefix=git-
  502. type=semver,pattern={{version}}
  503. type=semver,pattern={{major}}.{{minor}}
  504. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda126
  505. flavor: |
  506. latest=${{ github.ref == 'refs/heads/main' }}
  507. suffix=-cuda126,onlatest=true
  508. - name: Create manifest list and push
  509. working-directory: /tmp/digests
  510. run: |
  511. docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  512. $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
  513. - name: Inspect image
  514. run: |
  515. docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
  516. merge-ollama-images:
  517. runs-on: ubuntu-latest
  518. needs: [build-ollama-image]
  519. steps:
  520. # GitHub Packages requires the entire repository name to be in lowercase
  521. # although the repository owner has a lowercase username, this prevents some people from running actions after forking
  522. - name: Set repository and image name to lowercase
  523. run: |
  524. echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
  525. echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
  526. env:
  527. IMAGE_NAME: '${{ github.repository }}'
  528. - name: Download digests
  529. uses: actions/download-artifact@v4
  530. with:
  531. pattern: digests-ollama-*
  532. path: /tmp/digests
  533. merge-multiple: true
  534. - name: Set up Docker Buildx
  535. uses: docker/setup-buildx-action@v3
  536. - name: Log in to the Container registry
  537. uses: docker/login-action@v3
  538. with:
  539. registry: ${{ env.REGISTRY }}
  540. username: ${{ github.actor }}
  541. password: ${{ secrets.GITHUB_TOKEN }}
  542. - name: Extract metadata for Docker images (default ollama tag)
  543. id: meta
  544. uses: docker/metadata-action@v5
  545. with:
  546. images: ${{ env.FULL_IMAGE_NAME }}
  547. tags: |
  548. type=ref,event=branch
  549. type=ref,event=tag
  550. type=sha,prefix=git-
  551. type=semver,pattern={{version}}
  552. type=semver,pattern={{major}}.{{minor}}
  553. type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=ollama
  554. flavor: |
  555. latest=${{ github.ref == 'refs/heads/main' }}
  556. suffix=-ollama,onlatest=true
  557. - name: Create manifest list and push
  558. working-directory: /tmp/digests
  559. run: |
  560. docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
  561. $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
  562. - name: Inspect image
  563. run: |
  564. docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}