Merge pull request #2383 from xinnan-tech/docker-server-base

构建base镜像,只有当依赖发生变化时再进行重新构建,否则只使用之前的base镜像进行构建,能够使本地使用缓存的镜像
This commit is contained in:
hrz
2025-10-22 11:41:35 +08:00
committed by GitHub
4 changed files with 79 additions and 32 deletions
+49
View File
@@ -0,0 +1,49 @@
name: Build Base Image
on:
push:
branches:
- main
paths:
- 'main/xiaozhi-server/requirements.txt'
- 'Dockerfile-server-base'
- '.github/workflows/build-base-image.yml'
jobs:
build-base:
name: Build and push server base image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.TOKEN }}
- name: Build and push server-base
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile-server-base
push: true
tags: ghcr.io/${{ github.repository }}:server-base
platforms: linux/amd64
cache-from: type=gha,scope=server-base
cache-to: type=gha,mode=max,scope=server-base
build-args: |
BUILDKIT_PROGRESS=plain
- name: Output image info
run: |
echo "✅ Base image built and pushed successfully!"
echo "📦 Tag: ghcr.io/${{ github.repository }}:server-base"
+4
View File
@@ -5,6 +5,10 @@ on:
tags:
- 'v*.*.*' # 只在以 v 开头的标签推送时触发,例如 v1.0.0
workflow_dispatch:
workflow_run:
workflows: ["Build Base Image"]
types:
- completed
jobs:
release: