ci: fix docker workflow - registry cache, build-push-action@v6, REGISTRY_TOKEN
- Replace type=gha cache (disabled on this runner) with type=registry cache - Upgrade docker/build-push-action v5 → v6 (matches whisper-rtx2080 pattern) - Switch auth to REGISTRY_USERNAME/REGISTRY_TOKEN repo secrets - Split into two parallel jobs (build-cpu / build-gpu) for visibility - Use github.ref conditions (Gitea compat) instead of is_default_branch
This commit is contained in:
@@ -9,77 +9,94 @@ on:
|
|||||||
- 'v*.*.*'
|
- 'v*.*.*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: git.sal.giize.com
|
||||||
|
IMAGE_NAME: mozempk/trueref
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
# ── CPU image ──────────────────────────────────────────────────────────────
|
||||||
name: Build and push
|
build-cpu:
|
||||||
|
name: Build and push CPU image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Set up Docker Buildx for efficient layer caching.
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
# Log in to the Gitea container registry.
|
|
||||||
# The built-in GITEA_TOKEN is injected automatically by Gitea Actions and
|
|
||||||
# has write access to packages in the same organisation/user namespace.
|
|
||||||
- name: Log in to Gitea registry
|
- name: Log in to Gitea registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: git.sal.giize.com
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ gitea.actor }}
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.GITEA_TOKEN }}
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
# ── Determine tags ───────────────────────────────────────────────────
|
|
||||||
# On a version tag (v1.2.3): latest, cpu, cpu-1.2.3, 1.2.3
|
# On a version tag (v1.2.3): latest, cpu, cpu-1.2.3, 1.2.3
|
||||||
# On branch push (main/master): latest, cpu
|
# On branch push (main/master): latest, cpu
|
||||||
- name: Docker metadata (CPU)
|
- name: Docker metadata (CPU)
|
||||||
id: meta_cpu
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: git.sal.giize.com/mozempk/trueref
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
flavor: |
|
|
||||||
latest=auto
|
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
|
||||||
type=raw,value=cpu,enable={{is_default_branch}}
|
type=raw,value=cpu,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
|
||||||
type=semver,pattern={{version}},prefix=cpu-
|
type=semver,pattern={{version}},prefix=cpu-
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
|
|
||||||
- name: Docker metadata (GPU)
|
|
||||||
id: meta_gpu
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: git.sal.giize.com/mozempk/trueref
|
|
||||||
flavor: |
|
|
||||||
latest=false
|
|
||||||
tags: |
|
|
||||||
type=raw,value=gpu,enable={{is_default_branch}}
|
|
||||||
type=semver,pattern={{version}},prefix=gpu-
|
|
||||||
|
|
||||||
# ── CPU image ────────────────────────────────────────────────────────
|
|
||||||
- name: Build and push CPU image
|
- name: Build and push CPU image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
push: true
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta_cpu.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta_cpu.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha,scope=cpu
|
# Registry-backed layer cache — works without the GHA cache service.
|
||||||
cache-to: type=gha,mode=max,scope=cpu
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-cpu
|
||||||
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-cpu,mode=max
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
# ── GPU image ──────────────────────────────────────────────────────────────
|
||||||
|
build-gpu:
|
||||||
|
name: Build and push GPU image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Gitea registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
# On a version tag (v1.2.3): gpu, gpu-1.2.3
|
||||||
|
# On branch push (main/master): gpu
|
||||||
|
- name: Docker metadata (GPU)
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=gpu,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
|
||||||
|
type=semver,pattern={{version}},prefix=gpu-
|
||||||
|
|
||||||
# ── GPU image ────────────────────────────────────────────────────────
|
|
||||||
# Built from the same source; only the runtime base image differs.
|
|
||||||
- name: Build and push GPU image
|
- name: Build and push GPU image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile.gpu
|
file: Dockerfile.gpu
|
||||||
push: true
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta_gpu.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta_gpu.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha,scope=gpu
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-gpu
|
||||||
cache-to: type=gha,mode=max,scope=gpu
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-gpu,mode=max
|
||||||
|
platforms: linux/amd64
|
||||||
|
|||||||
Reference in New Issue
Block a user