feature: 构建双架构镜像 (#101)

feature: 构建双架构镜像
This commit is contained in:
hhhhsc701
2025-11-24 11:34:53 +08:00
committed by GitHub
parent 9858388084
commit a53f6776b8
9 changed files with 198 additions and 20 deletions

View File

@@ -6,11 +6,13 @@ on:
paths:
- 'scripts/images/datamate-python/**'
- '.github/workflows/docker-image-backend-python.yml'
- '.github/workflows/docker-images-reusable.yml'
pull_request:
branches: [ "main" ]
paths:
- 'scripts/images/datamate-python/**'
- '.github/workflows/docker-image-backend-python.yml'
- '.github/workflows/docker-images-reusable.yml'
workflow_dispatch:
workflow_call:

View File

@@ -7,12 +7,14 @@ on:
- 'backend/**'
- 'scripts/images/backend/**'
- '.github/workflows/docker-image-backend.yml'
- '.github/workflows/docker-images-reusable.yml'
pull_request:
branches: [ "main" ]
paths:
- 'backend/**'
- 'scripts/images/backend/**'
- '.github/workflows/docker-image-backend.yml'
- '.github/workflows/docker-images-reusable.yml'
workflow_dispatch:
workflow_call:

View File

@@ -7,12 +7,14 @@ on:
- 'scripts/db/**'
- 'scripts/images/database/**'
- '.github/workflows/docker-image-database.yml'
- '.github/workflows/docker-images-reusable.yml'
pull_request:
branches: [ "main" ]
paths:
- 'scripts/db/**'
- 'scripts/images/database/**'
- '.github/workflows/docker-image-database.yml'
- '.github/workflows/docker-images-reusable.yml'
workflow_dispatch:
workflow_call:

View File

@@ -19,7 +19,7 @@ on:
workflow_call:
jobs:
build-and-push:
build-and-push-amd:
runs-on: ubuntu-latest
permissions:
contents: read
@@ -41,26 +41,114 @@ jobs:
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/v}
echo "TAGS=$TAG" >> $GITHUB_OUTPUT
echo "TAGS=amd64-$TAG" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/heads/main ]]; then
echo "TAGS=latest" >> $GITHUB_OUTPUT
echo "TAGS=amd64" >> $GITHUB_OUTPUT
else
echo "TAGS=temp" >> $GITHUB_OUTPUT
echo "TAGS=amd64-temp" >> $GITHUB_OUTPUT
fi
- name: Build Docker Image
run: |
make build-deer-flow VERSION=latest
cp -n runtime/deer-flow/.env.example runtime/deer-flow/.env
cp -n runtime/deer-flow/conf.yaml.example runtime/deer-flow/conf.yaml
docker build -t deer-flow-backend:amd64 . -f scripts/images/deer-flow-backend/Dockerfile
docker build -t deer-flow-frontend:amd64 . -f scripts/images/deer-flow-frontend/Dockerfile
- name: Tag Docker Image
run: |
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
docker tag deer-flow-backend:latest ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
docker tag deer-flow-frontend:latest ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}
- name: Push Docker Image
- name: Tag & Push Docker Image
if: github.event_name != 'pull_request'
run: |
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
docker tag deer-flow-backend:amd64 ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
docker tag deer-flow-frontend:amd64 ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}
docker push ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
docker push ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}
build-and-push-arm:
runs-on: ubuntu-24.04-arm
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Docker Image Tag
id: set-tag
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/v}
echo "TAGS=arm64-$TAG" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/heads/main ]]; then
echo "TAGS=arm64" >> $GITHUB_OUTPUT
else
echo "TAGS=arm64-temp" >> $GITHUB_OUTPUT
fi
- name: Build Docker Image
run: |
cp -n runtime/deer-flow/.env.example runtime/deer-flow/.env
cp -n runtime/deer-flow/conf.yaml.example runtime/deer-flow/conf.yaml
docker build -t deer-flow-backend:arm64 . -f scripts/images/deer-flow-backend/Dockerfile
docker build -t deer-flow-frontend:arm64 . -f scripts/images/deer-flow-frontend/Dockerfile
- name: Tag & Push Docker Image
if: github.event_name != 'pull_request'
run: |
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
docker tag deer-flow-backend:arm64 ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
docker tag deer-flow-frontend:arm64 ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}
docker push ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
docker push ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}
manifest:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
needs: [ build-and-push-amd, build-and-push-arm ]
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Docker Image Tag
id: set-tag
run: |
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
BASE_IMAGE=ghcr.io/$LOWERCASE_REPO/datamate-${{ inputs.service_name }}
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/v}
echo "TAGS=$TAG" >> $GITHUB_OUTPUT
echo "ARM_TAGS=arm64-$TAG" >> $GITHUB_OUTPUT
echo "AMD_TAGS=amd64-$TAG" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/heads/main ]]; then
echo "TAGS=latest" >> $GITHUB_OUTPUT
echo "ARM_TAGS=arm64" >> $GITHUB_OUTPUT
echo "AMD_TAGS=amd64" >> $GITHUB_OUTPUT
else
echo "TAGS=temp" >> $GITHUB_OUTPUT
echo "ARM_TAGS=arm64-temp" >> $GITHUB_OUTPUT
echo "AMD_TAGS=amd64-temp" >> $GITHUB_OUTPUT
fi
- name: Manifest Docker Image
run: |
docker manifest create ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }} \
ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.AMD_TAGS }} \
ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.ARM_TAGS }}
docker manifest push ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
docker manifest create ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }} \
ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.AMD_TAGS }} \
ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.ARM_TAGS }}
docker manifest push ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}

View File

@@ -7,12 +7,14 @@ on:
- 'frontend/**'
- 'scripts/images/frontend/**'
- '.github/workflows/docker-image-frontend.yml'
- '.github/workflows/docker-images-reusable.yml'
pull_request:
branches: [ "main" ]
paths:
- 'frontend/**'
- 'scripts/images/frontend/**'
- '.github/workflows/docker-image-frontend.yml'
- '.github/workflows/docker-images-reusable.yml'
workflow_dispatch:
workflow_call:

View File

@@ -8,6 +8,7 @@ on:
- 'runtime/python-executor/**'
- 'scripts/images/runtime/**'
- '.github/workflows/docker-image-runtime.yml'
- '.github/workflows/docker-images-reusable.yml'
pull_request:
branches: [ "main" ]
paths:
@@ -15,6 +16,7 @@ on:
- 'runtime/python-executor/**'
- 'scripts/images/runtime/**'
- '.github/workflows/docker-image-runtime.yml'
- '.github/workflows/docker-images-reusable.yml'
workflow_dispatch:
workflow_call:

View File

@@ -11,7 +11,7 @@ on:
type: string
jobs:
build-and-push:
build-and-push-amd:
runs-on: ubuntu-latest
permissions:
contents: read
@@ -35,19 +35,99 @@ jobs:
BASE_IMAGE=ghcr.io/$LOWERCASE_REPO/datamate-${{ inputs.service_name }}
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/v}
echo "TAGS=$BASE_IMAGE:$TAG" >> $GITHUB_OUTPUT
echo "TAGS=$BASE_IMAGE:amd64-$TAG" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/heads/main ]]; then
echo "TAGS=$BASE_IMAGE:latest" >> $GITHUB_OUTPUT
echo "TAGS=$BASE_IMAGE:amd64" >> $GITHUB_OUTPUT
else
echo "TAGS=$BASE_IMAGE:temp" >> $GITHUB_OUTPUT
echo "TAGS=$BASE_IMAGE:amd64-temp" >> $GITHUB_OUTPUT
fi
- name: Build Docker Image
run: |
make build-${{ inputs.service_name }} VERSION=latest
docker build -t datamate-${{ inputs.service_name }}:amd64 . -f scripts/images/${{ inputs.service_name }}/Dockerfile --platform amd64
- name: Tag & Push Docker Image
if: github.event_name != 'pull_request'
run: |
docker tag datamate-${{ inputs.service_name }}:latest ${{ steps.set-tag.outputs.TAGS }}
docker tag datamate-${{ inputs.service_name }}:amd64 ${{ steps.set-tag.outputs.TAGS }}
docker push ${{ steps.set-tag.outputs.TAGS }}
build-and-push-arm:
runs-on: ubuntu-24.04-arm
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Docker Image Tag
id: set-tag
run: |
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
BASE_IMAGE=ghcr.io/$LOWERCASE_REPO/datamate-${{ inputs.service_name }}
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/v}
echo "TAGS=$BASE_IMAGE:arm64-$TAG" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/heads/main ]]; then
echo "TAGS=$BASE_IMAGE:arm64" >> $GITHUB_OUTPUT
else
echo "TAGS=$BASE_IMAGE:arm64-temp" >> $GITHUB_OUTPUT
fi
- name: Build Docker Image
run: |
docker build -t datamate-${{ inputs.service_name }}:arm64 . -f scripts/images/${{ inputs.service_name }}/Dockerfile --platform arm64
- name: Tag & Push Docker Image
if: github.event_name != 'pull_request'
run: |
docker tag datamate-${{ inputs.service_name }}:arm64 ${{ steps.set-tag.outputs.TAGS }}
docker push ${{ steps.set-tag.outputs.TAGS }}
manifest:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
needs: [ build-and-push-amd, build-and-push-arm ]
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Docker Image Tag
id: set-tag
run: |
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
BASE_IMAGE=ghcr.io/$LOWERCASE_REPO/datamate-${{ inputs.service_name }}
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/v}
echo "TAGS=$BASE_IMAGE:$TAG" >> $GITHUB_OUTPUT
echo "ARM_TAGS=$BASE_IMAGE:arm64-$TAG" >> $GITHUB_OUTPUT
echo "AMD_TAGS=$BASE_IMAGE:amd64-$TAG" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/heads/main ]]; then
echo "TAGS=$BASE_IMAGE:latest" >> $GITHUB_OUTPUT
echo "ARM_TAGS=$BASE_IMAGE:arm64" >> $GITHUB_OUTPUT
echo "AMD_TAGS=$BASE_IMAGE:amd64" >> $GITHUB_OUTPUT
else
echo "TAGS=$BASE_IMAGE:temp" >> $GITHUB_OUTPUT
echo "ARM_TAGS=$BASE_IMAGE:arm64-temp" >> $GITHUB_OUTPUT
echo "AMD_TAGS=$BASE_IMAGE:amd64-temp" >> $GITHUB_OUTPUT
fi
- name: Manifest Docker Image
run: |
docker manifest create ${{ steps.set-tag.outputs.TAGS }} \
${{ steps.set-tag.outputs.AMD_TAGS }} \
${{ steps.set-tag.outputs.ARM_TAGS }}
docker manifest push ${{ steps.set-tag.outputs.TAGS }}

View File

@@ -119,7 +119,7 @@ runtime-docker-build:
.PHONY: backend-python-docker-build
backend-python-docker-build:
docker build -t datamate-backend-python:$(VERSION) . -f scripts/images/datamate-python/Dockerfile
docker build -t datamate-backend-python:$(VERSION) . -f scripts/images/backend-python/Dockerfile
.PHONY: deer-flow-docker-build
deer-flow-docker-build: