feat: cache docker layers to registry

This commit is contained in:
Jun Siang Cheah 2024-05-20 20:05:53 +01:00
parent 54677a3374
commit e142223ed1

View File

@ -63,6 +63,16 @@ jobs:
flavor: | flavor: |
latest=${{ github.ref == 'refs/heads/main' }} latest=${{ github.ref == 'refs/heads/main' }}
- name: Extract metadata for Docker cache
id: cache-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.FULL_IMAGE_NAME }}
tags: |
type=ref,event=branch
flavor: |
prefix=cache-${{ matrix.platform }}-
- name: Build Docker image (latest) - name: Build Docker image (latest)
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
id: build id: build
@ -72,8 +82,8 @@ jobs:
platforms: ${{ matrix.platform }} platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
cache-to: type=gha,mode=max cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
- name: Export digest - name: Export digest
run: | run: |
@ -123,7 +133,7 @@ jobs:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker images (default latest tag) - name: Extract metadata for Docker images (cuda tag)
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
@ -139,6 +149,16 @@ jobs:
latest=${{ github.ref == 'refs/heads/main' }} latest=${{ github.ref == 'refs/heads/main' }}
suffix=-cuda,onlatest=true suffix=-cuda,onlatest=true
- name: Extract metadata for Docker cache
id: cache-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.FULL_IMAGE_NAME }}
tags: |
type=ref,event=branch
flavor: |
prefix=cache-cuda-${{ matrix.platform }}-
- name: Build Docker image (cuda) - name: Build Docker image (cuda)
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
id: build id: build
@ -148,8 +168,8 @@ jobs:
platforms: ${{ matrix.platform }} platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
cache-to: type=gha,mode=max cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
build-args: USE_CUDA=true build-args: USE_CUDA=true
- name: Export digest - name: Export digest
@ -216,6 +236,16 @@ jobs:
latest=${{ github.ref == 'refs/heads/main' }} latest=${{ github.ref == 'refs/heads/main' }}
suffix=-ollama,onlatest=true suffix=-ollama,onlatest=true
- name: Extract metadata for Docker cache
id: cache-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.FULL_IMAGE_NAME }}
tags: |
type=ref,event=branch
flavor: |
prefix=cache-ollama-${{ matrix.platform }}-
- name: Build Docker image (ollama) - name: Build Docker image (ollama)
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
id: build id: build
@ -225,8 +255,8 @@ jobs:
platforms: ${{ matrix.platform }} platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
cache-to: type=gha,mode=max cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
build-args: USE_OLLAMA=true build-args: USE_OLLAMA=true
- name: Export digest - name: Export digest