2024-03-20 09:05:38 +01:00
|
|
|
name: Create and publish Docker images with specific build args
|
2023-11-06 22:00:11 +01:00
|
|
|
|
|
|
|
on:
|
2024-04-05 21:29:11 +02:00
|
|
|
workflow_dispatch:
|
2023-11-06 22:00:11 +01:00
|
|
|
push:
|
2023-12-27 16:38:32 +01:00
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- dev
|
2023-11-06 22:00:11 +01:00
|
|
|
tags:
|
|
|
|
- v*
|
|
|
|
|
|
|
|
env:
|
2024-04-09 15:45:27 +02:00
|
|
|
REGISTRY: git.depeuter.dev
|
2023-11-06 22:00:11 +01:00
|
|
|
IMAGE_NAME: ${{ github.repository }}
|
2024-04-09 15:45:27 +02:00
|
|
|
RUNNER_TOOL_CACHE: /toolcache
|
2024-05-04 18:01:49 +02:00
|
|
|
FULL_IMAGE_NAME: ${{ env.REGISTRY }}/${{ github.repository }}
|
2023-11-06 22:00:11 +01:00
|
|
|
|
|
|
|
jobs:
|
2024-04-10 14:13:39 +02:00
|
|
|
build-main-image:
|
2023-11-06 22:00:11 +01:00
|
|
|
runs-on: ubuntu-latest
|
2024-04-09 15:45:27 +02:00
|
|
|
container:
|
|
|
|
image: catthehacker/ubuntu:act-latest
|
2023-11-06 22:00:11 +01:00
|
|
|
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
2024-04-10 14:13:39 +02:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2024-05-04 19:27:10 +02:00
|
|
|
platform: [ linux/amd64, linux/arm64 ]
|
2024-03-20 09:05:38 +01:00
|
|
|
|
2023-11-06 22:00:11 +01:00
|
|
|
steps:
|
2024-04-10 14:13:39 +02:00
|
|
|
- name: Prepare
|
|
|
|
run: |
|
|
|
|
platform=${{ matrix.platform }}
|
|
|
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
|
|
|
|
2023-11-06 22:00:11 +01:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
2024-04-10 14:13:39 +02:00
|
|
|
|
2023-12-08 11:50:58 +01:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v3
|
2024-04-10 14:13:39 +02:00
|
|
|
|
2023-12-08 11:50:58 +01:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
2024-04-10 14:13:39 +02:00
|
|
|
|
2023-11-06 22:00:11 +01:00
|
|
|
- name: Log in to the Container registry
|
2023-12-27 16:39:18 +01:00
|
|
|
uses: docker/login-action@v3
|
2023-11-06 22:00:11 +01:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
2024-04-09 15:45:27 +02:00
|
|
|
password: ${{ secrets.CI_TOKEN }}
|
2024-02-15 06:55:33 +01:00
|
|
|
|
2024-03-20 09:05:38 +01:00
|
|
|
- name: Extract metadata for Docker images (default latest tag)
|
2023-11-06 22:00:11 +01:00
|
|
|
id: meta
|
2023-12-27 16:39:18 +01:00
|
|
|
uses: docker/metadata-action@v5
|
2023-11-06 22:00:11 +01:00
|
|
|
with:
|
2024-04-10 14:13:39 +02:00
|
|
|
images: ${{ env.FULL_IMAGE_NAME }}
|
2024-02-15 06:55:33 +01:00
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=tag
|
|
|
|
type=sha,prefix=git-
|
|
|
|
type=semver,pattern={{version}}
|
2024-02-25 22:57:33 +01:00
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
2024-02-15 06:55:33 +01:00
|
|
|
flavor: |
|
|
|
|
latest=${{ github.ref == 'refs/heads/main' }}
|
|
|
|
|
2024-04-10 14:13:39 +02:00
|
|
|
- name: Build Docker image (latest)
|
2023-12-08 11:50:58 +01:00
|
|
|
uses: docker/build-push-action@v5
|
2024-04-10 14:13:39 +02:00
|
|
|
id: build
|
2023-11-06 22:00:11 +01:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
2024-04-10 14:13:39 +02:00
|
|
|
platforms: ${{ matrix.platform }}
|
2023-11-06 22:00:11 +01:00
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
2024-04-10 14:13:39 +02:00
|
|
|
outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
|
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
|
|
|
|
|
|
|
- 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-main-${{ env.PLATFORM_PAIR }}
|
|
|
|
path: /tmp/digests/*
|
|
|
|
if-no-files-found: error
|
|
|
|
retention-days: 1
|
|
|
|
|
|
|
|
build-cuda-image:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
platform:
|
|
|
|
- linux/amd64
|
|
|
|
- linux/arm64
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Prepare
|
|
|
|
run: |
|
|
|
|
platform=${{ matrix.platform }}
|
|
|
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
|
|
- name: Log in to the Container registry
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
2024-05-04 18:01:49 +02:00
|
|
|
password: ${{ secrets.CI_TOKEN }}
|
2024-04-10 14:13:39 +02:00
|
|
|
|
|
|
|
- name: Extract metadata for Docker images (default latest tag)
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
images: ${{ env.FULL_IMAGE_NAME }}
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=tag
|
|
|
|
type=sha,prefix=git-
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
2024-04-10 21:41:36 +02:00
|
|
|
type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda
|
2024-04-10 14:13:39 +02:00
|
|
|
flavor: |
|
|
|
|
latest=${{ github.ref == 'refs/heads/main' }}
|
|
|
|
suffix=-cuda,onlatest=true
|
2024-03-20 09:05:38 +01:00
|
|
|
|
2024-04-10 14:13:39 +02:00
|
|
|
- name: Build Docker image (cuda)
|
2024-03-20 09:05:38 +01:00
|
|
|
uses: docker/build-push-action@v5
|
2024-04-10 14:13:39 +02:00
|
|
|
id: build
|
2024-03-20 09:05:38 +01:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
2024-04-10 14:13:39 +02:00
|
|
|
platforms: ${{ matrix.platform }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
|
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2024-03-20 09:05:38 +01:00
|
|
|
build-args: USE_CUDA=true
|
2024-02-15 06:55:33 +01:00
|
|
|
|
2024-04-10 14:13:39 +02:00
|
|
|
- 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-cuda-${{ env.PLATFORM_PAIR }}
|
|
|
|
path: /tmp/digests/*
|
|
|
|
if-no-files-found: error
|
|
|
|
retention-days: 1
|
|
|
|
|
|
|
|
build-ollama-image:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
platform:
|
|
|
|
- linux/amd64
|
|
|
|
- linux/arm64
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Prepare
|
|
|
|
run: |
|
|
|
|
platform=${{ matrix.platform }}
|
|
|
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
|
|
- name: Log in to the Container registry
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
2024-05-04 18:01:49 +02:00
|
|
|
password: ${{ secrets.CI_TOKEN }}
|
2024-04-10 14:13:39 +02:00
|
|
|
|
|
|
|
- name: Extract metadata for Docker images (ollama tag)
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
images: ${{ env.FULL_IMAGE_NAME }}
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=tag
|
|
|
|
type=sha,prefix=git-
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
2024-04-10 21:41:36 +02:00
|
|
|
type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=ollama
|
2024-04-10 14:13:39 +02:00
|
|
|
flavor: |
|
|
|
|
latest=${{ github.ref == 'refs/heads/main' }}
|
|
|
|
suffix=-ollama,onlatest=true
|
|
|
|
|
|
|
|
- name: Build Docker image (ollama)
|
2023-12-08 11:50:58 +01:00
|
|
|
uses: docker/build-push-action@v5
|
2024-04-10 14:13:39 +02:00
|
|
|
id: build
|
2023-11-06 22:00:11 +01:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
2024-04-10 14:13:39 +02:00
|
|
|
platforms: ${{ matrix.platform }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
|
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2024-04-02 14:47:52 +02:00
|
|
|
build-args: USE_OLLAMA=true
|
2024-04-10 14:13:39 +02:00
|
|
|
|
|
|
|
- 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-ollama-${{ env.PLATFORM_PAIR }}
|
|
|
|
path: /tmp/digests/*
|
|
|
|
if-no-files-found: error
|
|
|
|
retention-days: 1
|
|
|
|
|
|
|
|
merge-main-images:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [ build-main-image ]
|
|
|
|
steps:
|
|
|
|
- name: Download digests
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
pattern: digests-main-*
|
|
|
|
path: /tmp/digests
|
|
|
|
merge-multiple: true
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
|
|
- name: Log in to the Container registry
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
2024-05-04 18:01:49 +02:00
|
|
|
password: ${{ secrets.CI_TOKEN }}
|
2024-04-10 14:13:39 +02:00
|
|
|
|
|
|
|
- name: Extract metadata for Docker images (default latest tag)
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
images: ${{ env.FULL_IMAGE_NAME }}
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=tag
|
|
|
|
type=sha,prefix=git-
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
flavor: |
|
|
|
|
latest=${{ github.ref == 'refs/heads/main' }}
|
|
|
|
|
|
|
|
- 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.FULL_IMAGE_NAME }}@sha256:%s ' *)
|
|
|
|
|
|
|
|
- name: Inspect image
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
|
|
|
|
|
|
|
|
|
|
|
|
merge-cuda-images:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [ build-cuda-image ]
|
|
|
|
steps:
|
|
|
|
- name: Download digests
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
pattern: digests-cuda-*
|
|
|
|
path: /tmp/digests
|
|
|
|
merge-multiple: true
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
|
|
- name: Log in to the Container registry
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
2024-05-04 18:01:49 +02:00
|
|
|
password: ${{ secrets.CI_TOKEN }}
|
2024-04-10 14:13:39 +02:00
|
|
|
|
|
|
|
- name: Extract metadata for Docker images (default latest tag)
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
images: ${{ env.FULL_IMAGE_NAME }}
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=tag
|
|
|
|
type=sha,prefix=git-
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
2024-04-10 21:55:49 +02:00
|
|
|
type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=cuda
|
2024-04-10 14:13:39 +02:00
|
|
|
flavor: |
|
|
|
|
latest=${{ github.ref == 'refs/heads/main' }}
|
|
|
|
suffix=-cuda,onlatest=true
|
|
|
|
|
|
|
|
- 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.FULL_IMAGE_NAME }}@sha256:%s ' *)
|
|
|
|
|
|
|
|
- name: Inspect image
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
|
|
|
|
|
|
|
|
merge-ollama-images:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [ build-ollama-image ]
|
|
|
|
steps:
|
|
|
|
- name: Download digests
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
pattern: digests-ollama-*
|
|
|
|
path: /tmp/digests
|
|
|
|
merge-multiple: true
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
|
|
- name: Log in to the Container registry
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
2024-05-04 18:01:49 +02:00
|
|
|
password: ${{ secrets.CI_TOKEN }}
|
2024-04-10 14:13:39 +02:00
|
|
|
|
|
|
|
- name: Extract metadata for Docker images (default ollama tag)
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
images: ${{ env.FULL_IMAGE_NAME }}
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=tag
|
|
|
|
type=sha,prefix=git-
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
2024-04-10 21:55:49 +02:00
|
|
|
type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=ollama
|
2024-04-10 14:13:39 +02:00
|
|
|
flavor: |
|
|
|
|
latest=${{ github.ref == 'refs/heads/main' }}
|
|
|
|
suffix=-ollama,onlatest=true
|
|
|
|
|
|
|
|
- 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.FULL_IMAGE_NAME }}@sha256:%s ' *)
|
|
|
|
|
|
|
|
- name: Inspect image
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
|