Skip to content
Latchkey

Publish Base Docker image (Models) workflow (aigc-apps/PAI-RAG)

The Publish Base Docker image (Models) workflow from aigc-apps/PAI-RAG, explained and optimized by Latchkey.

C

CI health: C - fair

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: aigc-apps/PAI-RAG.github/workflows/docker-base.ymlLicense MITView source

What it does

This is the Publish Base Docker image (Models) workflow from the aigc-apps/PAI-RAG repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Publish Base Docker image (Models)

# This workflow builds the base image containing ML models.
# It should only be triggered when models change (rarely).
on:
  workflow_dispatch:
    inputs:
      version_tag:
        description: 'Version tag for the base image (e.g., v1.0, latest)'
        required: false
        default: 'latest'
        type: string
  push:
    branches: ["feature"]
    paths:
      - 'Dockerfile.base'

env:
  REGISTRY: mybigpai-public-registry.cn-beijing.cr.aliyuncs.com

jobs:
  build-and-push-base-image:
    runs-on: self-hosted
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Check disk space
        run: df . -h

      - name: Set version tag
        run: |
          if [ "${{ github.event.inputs.version_tag }}" != "" ]; then
            echo "BASE_VERSION_TAG=${{ github.event.inputs.version_tag }}" >> $GITHUB_ENV
          else
            CURRENT_TIME="`date +%Y%m%d`"
            echo "BASE_VERSION_TAG=$CURRENT_TIME" >> $GITHUB_ENV
          fi

      - name: Copy local models
        run: |
          cp -r /home/ecs-user/model_repository_1121 ./model_repository

      - name: Login to ACR Hangzhou region
        uses: docker/login-action@v1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ secrets.ACR_USER }}
          password: ${{ secrets.ACR_PUBLIC_PASSWORD }}

      - name: Build and push base image
        env:
          BASE_IMAGE_TAG: ${{ env.BASE_VERSION_TAG }}
        run: |
          # Build base image
          docker build -f Dockerfile.base -t ${{ env.REGISTRY }}/mybigpai/pairag-base:$BASE_IMAGE_TAG .
          
          # Also tag as latest
          docker tag ${{ env.REGISTRY }}/mybigpai/pairag-base:$BASE_IMAGE_TAG ${{ env.REGISTRY }}/mybigpai/pairag-base:latest
          
          # Push both tags
          docker push ${{ env.REGISTRY }}/mybigpai/pairag-base:$BASE_IMAGE_TAG
          docker push ${{ env.REGISTRY }}/mybigpai/pairag-base:latest

      - name: Free disk space
        run: |
          docker image prune --filter "until=168h" --force -a
          docker builder prune --filter "until=24h" -f

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Publish Base Docker image (Models)
 
# This workflow builds the base image containing ML models.
# It should only be triggered when models change (rarely).
on:
  workflow_dispatch:
    inputs:
      version_tag:
        description: 'Version tag for the base image (e.g., v1.0, latest)'
        required: false
        default: 'latest'
        type: string
  push:
    branches: ["feature"]
    paths:
      - 'Dockerfile.base'
 
env:
  REGISTRY: mybigpai-public-registry.cn-beijing.cr.aliyuncs.com
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build-and-push-base-image:
    timeout-minutes: 30
    runs-on: self-hosted
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
 
      - name: Check disk space
        run: df . -h
 
      - name: Set version tag
        run: |
          if [ "${{ github.event.inputs.version_tag }}" != "" ]; then
            echo "BASE_VERSION_TAG=${{ github.event.inputs.version_tag }}" >> $GITHUB_ENV
          else
            CURRENT_TIME="`date +%Y%m%d`"
            echo "BASE_VERSION_TAG=$CURRENT_TIME" >> $GITHUB_ENV
          fi
 
      - name: Copy local models
        run: |
          cp -r /home/ecs-user/model_repository_1121 ./model_repository
 
      - name: Login to ACR Hangzhou region
        uses: docker/login-action@v1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ secrets.ACR_USER }}
          password: ${{ secrets.ACR_PUBLIC_PASSWORD }}
 
      - name: Build and push base image
        env:
          BASE_IMAGE_TAG: ${{ env.BASE_VERSION_TAG }}
        run: |
          # Build base image
          docker build -f Dockerfile.base -t ${{ env.REGISTRY }}/mybigpai/pairag-base:$BASE_IMAGE_TAG .
          
          # Also tag as latest
          docker tag ${{ env.REGISTRY }}/mybigpai/pairag-base:$BASE_IMAGE_TAG ${{ env.REGISTRY }}/mybigpai/pairag-base:latest
          
          # Push both tags
          docker push ${{ env.REGISTRY }}/mybigpai/pairag-base:$BASE_IMAGE_TAG
          docker push ${{ env.REGISTRY }}/mybigpai/pairag-base:latest
 
      - name: Free disk space
        run: |
          docker image prune --filter "until=168h" --force -a
          docker builder prune --filter "until=24h" -f
 
 

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow