chore(build): Optimize Docker build configuration and process, adjust task names

This commit is contained in:
begoniezhao
2025-09-18 17:23:05 +08:00
parent 7973128f4c
commit 8f723b38fb
2 changed files with 23 additions and 14 deletions

View File

@@ -9,7 +9,7 @@ concurrency:
cancel-in-progress: false
jobs:
build-app:
build-images:
runs-on: ubuntu-latest
strategy:
matrix:
@@ -42,12 +42,6 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set up Go
if: matrix.service_name == 'app'
uses: actions/setup-go@v4
with:
go-version: '1.24'
- name: Prepare version info
id: version
run: |
@@ -62,6 +56,20 @@ jobs:
# 显示版本信息
./scripts/get_version.sh info
- name: Build Cache for Docker
uses: actions/cache@v4
id: cache
with:
path: go-build-cache
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
- name: Inject go-build-cache
uses: reproducible-containers/buildkit-cache-dance@v3
with:
cache-source: go-build-cache
dockerfile: ${{ matrix.file }}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Build ${{ matrix.service_name }} Image
uses: docker/build-push-action@v3
with:
@@ -78,4 +86,5 @@ jobs:
${{ secrets.DOCKERHUB_USERNAME }}/weknora-${{ matrix.service_name }}:latest
${{ secrets.DOCKERHUB_USERNAME }}/weknora-${{ matrix.service_name }}:${{ steps.version.outputs.version }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/weknora-${{ matrix.service_name }}:cache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/weknora-${{ matrix.service_name }}:cache,mode=max
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/weknora-${{ matrix.service_name }}:cache,mode=max