From b0b7acef432db858de81afda9fc7acb403053545 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Thu, 28 Mar 2024 15:34:19 -0700 Subject: [PATCH] CI automation for tagging latest images --- .github/workflows/latest.yaml | 20 ++++++++++++++++++++ scripts/tag_latest.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/latest.yaml create mode 100755 scripts/tag_latest.sh diff --git a/.github/workflows/latest.yaml b/.github/workflows/latest.yaml new file mode 100644 index 00000000000..cecb5cc6c32 --- /dev/null +++ b/.github/workflows/latest.yaml @@ -0,0 +1,20 @@ +name: latest + +on: + release: + types: [released] + +jobs: + update-latest: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: fetch images + env: + ARCH_IMAGE_REPO: dhiltgen/release + FINAL_IMAGE_REPO: dhiltgen/ollama + # PUSH: "1" + run: | + export "VERSION=${GITHUB_REF_NAME#v}" + env + ./scripts/tag_latest.sh diff --git a/scripts/tag_latest.sh b/scripts/tag_latest.sh new file mode 100755 index 00000000000..efb4b8d28fd --- /dev/null +++ b/scripts/tag_latest.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +set -eu + +# We use 2 different image repositories to handle combining architecture images into multiarch manifest +# (The ROCm image is x86 only and is not a multiarch manifest) +# For developers, you can override the DOCKER_ORG to generate multiarch manifests +# DOCKER_ORG=jdoe PUSH=1 ./scripts/build_docker.sh +DOCKER_ORG=${DOCKER_ORG:-"ollama"} +ARCH_IMAGE_REPO=${ARCH_IMAGE_REPO:-"${DOCKER_ORG}/release"} +FINAL_IMAGE_REPO=${FINAL_IMAGE_REPO:-"${DOCKER_ORG}/ollama"} + +# Set PUSH to a non-empty string to trigger push instead of load +PUSH=${PUSH:-""} + +echo "Assembling manifest and tagging latest" +docker manifest rm ${FINAL_IMAGE_REPO}:latest || true +docker manifest create ${FINAL_IMAGE_REPO}:latest \ + ${ARCH_IMAGE_REPO}:$VERSION-amd64 \ + ${ARCH_IMAGE_REPO}:$VERSION-arm64 + +docker pull ${ARCH_IMAGE_REPO}:$VERSION-rocm +docker tag ${ARCH_IMAGE_REPO}:$VERSION-rocm ${FINAL_IMAGE_REPO}:rocm + +if [ -n "${PUSH}" ]; then + echo "Pushing latest tags up..." + docker manifest push ${FINAL_IMAGE_REPO}:latest + docker push ${FINAL_IMAGE_REPO}:rocm +else + echo "Not pushing ${FINAL_IMAGE_REPO}:latest and ${FINAL_IMAGE_REPO}:rocm" +fi + +