diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index 91b4cf831..7b673f8c7 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -25,13 +25,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - config-inline: | - [registry."192.168.0.110:5000"] - http = true - insecure = true + - name: Login to Harbor uses: docker/login-action@v3 @@ -42,35 +36,28 @@ jobs: # ── API 鏡像建置(含 Layer Cache 加速)────────────────────────────── - name: Build and Push API - uses: docker/build-push-action@v5 - with: - context: . - file: ./apps/api/Dockerfile - push: true - tags: | - ${{ env.HARBOR }}/awoooi/api:${{ github.sha }} - ${{ env.HARBOR }}/awoooi/api:latest - # Cache: 從 Harbor 先拉取上一次的 layer,命中就不重新建置 - cache-from: type=registry,ref=${{ env.HARBOR }}/awoooi/api:buildcache - cache-to: type=registry,ref=${{ env.HARBOR }}/awoooi/api:buildcache,mode=max - build-args: | - BUILDKIT_INLINE_CACHE=1 + run: | + docker build -f apps/api/Dockerfile \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --cache-from ${{ env.HARBOR }}/awoooi/api:latest \ + -t ${{ env.HARBOR }}/awoooi/api:${{ github.sha }} \ + -t ${{ env.HARBOR }}/awoooi/api:latest \ + . + docker push ${{ env.HARBOR }}/awoooi/api:${{ github.sha }} + docker push ${{ env.HARBOR }}/awoooi/api:latest # ── Web 鏡像建置(含 Layer Cache 加速)────────────────────────────── - name: Build and Push Web - uses: docker/build-push-action@v5 - with: - context: . - file: ./apps/web/Dockerfile - push: true - tags: | - ${{ env.HARBOR }}/awoooi/web:${{ github.sha }} - ${{ env.HARBOR }}/awoooi/web:latest - cache-from: type=registry,ref=${{ env.HARBOR }}/awoooi/web:buildcache - cache-to: type=registry,ref=${{ env.HARBOR }}/awoooi/web:buildcache,mode=max - build-args: | - NEXT_PUBLIC_API_URL=http://192.168.0.125:32334 - BUILDKIT_INLINE_CACHE=1 + run: | + docker build -f apps/web/Dockerfile \ + --build-arg NEXT_PUBLIC_API_URL=http://192.168.0.125:32334 \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --cache-from ${{ env.HARBOR }}/awoooi/web:latest \ + -t ${{ env.HARBOR }}/awoooi/web:${{ github.sha }} \ + -t ${{ env.HARBOR }}/awoooi/web:latest \ + . + docker push ${{ env.HARBOR }}/awoooi/web:${{ github.sha }} + docker push ${{ env.HARBOR }}/awoooi/web:latest # ── K8s 部署 ───────────────────────────────────────────────────────── - name: Deploy to K8s