mirror of
https://github.com/ollama/ollama.git
synced 2025-06-20 01:20:52 +02:00
ci: split docker build by platform
this improves build reliability and concurrency
This commit is contained in:
parent
4759ecae19
commit
63f0269f7f
80
.github/workflows/release.yaml
vendored
80
.github/workflows/release.yaml
vendored
@ -330,32 +330,71 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
dist/*.tgz
|
dist/*.tgz
|
||||||
|
|
||||||
docker-build:
|
# Build each Docker variant (OS, arch, and flavor) separately. Using QEMU is unreliable and slower.
|
||||||
|
docker-build-push:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- flavor: 'latest=false'
|
- os: linux
|
||||||
platforms: linux/amd64,linux/arm64
|
arch: arm64
|
||||||
build-args: |
|
build-args: |
|
||||||
CGO_CFLAGS
|
CGO_CFLAGS
|
||||||
CGO_CXXFLAGS
|
CGO_CXXFLAGS
|
||||||
GOFLAGS
|
GOFLAGS
|
||||||
- flavor: 'latest=false,suffix=-rocm'
|
- os: linux
|
||||||
platforms: linux/amd64
|
arch: amd64
|
||||||
|
build-args: |
|
||||||
|
CGO_CFLAGS
|
||||||
|
CGO_CXXFLAGS
|
||||||
|
GOFLAGS
|
||||||
|
- os: linux
|
||||||
|
arch: amd64
|
||||||
|
suffix: '-rocm'
|
||||||
build-args: |
|
build-args: |
|
||||||
CGO_CFLAGS
|
CGO_CFLAGS
|
||||||
CGO_CXXFLAGS
|
CGO_CXXFLAGS
|
||||||
GOFLAGS
|
GOFLAGS
|
||||||
FLAVOR=rocm
|
FLAVOR=rocm
|
||||||
env:
|
runs-on: ${{ matrix.arch == 'arm64' && format('{0}-{1}', matrix.os, matrix.arch) || matrix.os }}
|
||||||
GOFLAGS: ${{ needs.setup-environment.outputs.GOFLAGS }}
|
|
||||||
runs-on: linux
|
|
||||||
environment: release
|
environment: release
|
||||||
needs: setup-environment
|
needs: setup-environment
|
||||||
|
env:
|
||||||
|
GOFLAGS: ${{ needs.setup-environment.outputs.GOFLAGS }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: docker/setup-qemu-action@v2
|
|
||||||
- uses: docker/setup-buildx-action@v2
|
- uses: docker/setup-buildx-action@v2
|
||||||
|
- uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ vars.DOCKER_USER }}
|
||||||
|
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||||
|
- id: build-push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: ${{ matrix.os }}/${{ matrix.arch }}
|
||||||
|
build-args: ${{ matrix.build-args }}
|
||||||
|
outputs: type=image,name=ollama/ollama,push-by-digest=true,name-canonical=true,push=true
|
||||||
|
cache-from: type=registry,ref=ollama/ollama:latest
|
||||||
|
cache-to: type=inline
|
||||||
|
- run: |
|
||||||
|
mkdir -p ${{ matrix.os }}-${{ matrix.arch }}
|
||||||
|
echo "${{ steps.build-push.outputs.digest }}" >${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.suffix }}.txt
|
||||||
|
working-directory: ${{ runner.temp }}
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digest-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.suffix }}
|
||||||
|
path: |
|
||||||
|
${{ runner.temp }}/${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.suffix }}.txt
|
||||||
|
|
||||||
|
# Merge Docker images for the same flavor into a single multi-arch manifest
|
||||||
|
docker-merge-push:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
suffix: ['', '-rocm']
|
||||||
|
runs-on: linux
|
||||||
|
environment: release
|
||||||
|
needs: [docker-build-push]
|
||||||
|
steps:
|
||||||
- uses: docker/login-action@v3
|
- uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ vars.DOCKER_USER }}
|
username: ${{ vars.DOCKER_USER }}
|
||||||
@ -363,22 +402,23 @@ jobs:
|
|||||||
- id: metadata
|
- id: metadata
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
flavor: ${{ matrix.flavor }}
|
flavor: |
|
||||||
|
latest=false
|
||||||
|
suffix=${{ matrix.suffix }}
|
||||||
images: |
|
images: |
|
||||||
ollama/ollama
|
ollama/ollama
|
||||||
tags: |
|
tags: |
|
||||||
|
type=ref,enable=true,priority=600,prefix=pr-,event=pr
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
- uses: docker/build-push-action@v6
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
pattern: digest-*
|
||||||
push: true
|
path: ${{ runner.temp }}
|
||||||
platforms: ${{ matrix.platforms }}
|
merge-multiple: true
|
||||||
build-args: ${{ matrix.build-args }}
|
- run: |
|
||||||
tags: ${{ steps.metadata.outputs.tags }}
|
docker buildx imagetools create $(echo '${{ steps.metadata.outputs.json }}' | jq -cr '.tags | map("-t", .) | join(" ")') $(cat *-${{ matrix.suffix }}.txt | xargs printf 'ollama/ollama@%s ')
|
||||||
labels: ${{ steps.metadata.outputs.labels }}
|
docker buildx imagetools inspect ollama/ollama:${{ steps.metadata.outputs.version }}
|
||||||
cache-from: type=registry,ref=ollama/ollama:latest
|
working-directory: ${{ runner.temp }}
|
||||||
cache-to: type=inline
|
|
||||||
provenance: false
|
|
||||||
|
|
||||||
# Aggregate all the assets and ship a release
|
# Aggregate all the assets and ship a release
|
||||||
release:
|
release:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user