forked from ollama/ollama
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow to push a testing Docker image for amd64 (#3)
- Loading branch information
Showing
1 changed file
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
name: release testing artifacts | ||
|
||
on: | ||
push: | ||
branches: | ||
# Branch that we merge proposed changes to for internal testing. | ||
- testing | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
build-container-image: | ||
strategy: | ||
matrix: | ||
# Need a real arm64 runner to build llama.cpp since cross-compilation | ||
# and emulation aren't practical for it. | ||
# TODO: Add arm64 runner | ||
runner: | ||
- ubuntu-24.04 | ||
runs-on: ${{ matrix.runner }} | ||
env: | ||
FINAL_IMAGE_REPO: ghcr.io/${{ github.repository }}/ollama | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.FINAL_IMAGE_REPO }} | ||
flavor: | | ||
latest=false | ||
tags: | | ||
type=ref | ||
type=sha,format=long | ||
- name: Set Version | ||
shell: bash | ||
run: | | ||
machine=$(uname -m) | ||
case ${machine} in | ||
x86_64) echo ARCH=amd64; echo PLATFORM_PAIR=linux-amd64 ;; | ||
aarch64) echo ARCH=arm64; echo PLATFORM_PAIR=linux-arm64 ;; | ||
esac >>$GITHUB_ENV | ||
echo GOFLAGS="'-ldflags=-w -s \"-X=github.com/ollama/ollama/version.Version=${{ env.DOCKER_METADATA_OUTPUT_VERSION }}\" \"-X=github.com/ollama/ollama/server.mode=release\"'" >>$GITHUB_ENV | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push by digest | ||
id: build | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: '.' | ||
platforms: linux/${{ env.ARCH }} | ||
build-args: | | ||
GOFLAGS | ||
outputs: type=image,name=${{ env.FINAL_IMAGE_REPO }},push-by-digest=true,name-canonical=true,push=true | ||
- name: Export digest | ||
run: | | ||
mkdir -p /tmp/digests | ||
digest="${{ steps.build.outputs.digest }}" | ||
touch "/tmp/digests/${digest#sha256:}" | ||
- name: Upload digest | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: digests-${{ env.PLATFORM_PAIR }} | ||
path: /tmp/digests/* | ||
if-no-files-found: error | ||
retention-days: 1 | ||
merge: | ||
runs-on: ubuntu-24.04 | ||
needs: | ||
- build-container-image | ||
env: | ||
FINAL_IMAGE_REPO: ghcr.io/${{ github.repository }}/ollama | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Download digests | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: /tmp/digests | ||
pattern: digests-* | ||
merge-multiple: true | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.FINAL_IMAGE_REPO }} | ||
flavor: | | ||
latest=false | ||
tags: | | ||
type=ref | ||
type=sha,format=long | ||
- name: Set Version | ||
shell: bash | ||
run: | | ||
machine=$(uname -m) | ||
case ${machine} in | ||
x86_64) echo ARCH=amd64; echo PLATFORM_PAIR=linux-amd64 ;; | ||
aarch64) echo ARCH=arm64; echo PLATFORM_PAIR=linux-arm64 ;; | ||
esac >>$GITHUB_ENV | ||
echo GOFLAGS="'-ldflags=-w -s \"-X=github.com/ollama/ollama/version.Version=${{ env.DOCKER_METADATA_OUTPUT_VERSION }}\" \"-X=github.com/ollama/ollama/server.mode=release\"'" >>$GITHUB_ENV | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Create manifest list and push | ||
working-directory: /tmp/digests | ||
run: | | ||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||
$(printf '${{ env.FINAL_IMAGE_REPO }}@sha256:%s ' *) | ||
- name: Inspect image | ||
run: | | ||
docker buildx imagetools inspect ${{ env.FINAL_IMAGE_REPO }}:${{ steps.meta.outputs.version }} |