Skip to content

Commit a53f677

Browse files
authored
feature: 构建双架构镜像 (#101)
feature: 构建双架构镜像
1 parent 9858388 commit a53f677

File tree

9 files changed

+195
-17
lines changed

9 files changed

+195
-17
lines changed

.github/workflows/docker-image-backend-python.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ on:
66
paths:
77
- 'scripts/images/datamate-python/**'
88
- '.github/workflows/docker-image-backend-python.yml'
9+
- '.github/workflows/docker-images-reusable.yml'
910
pull_request:
1011
branches: [ "main" ]
1112
paths:
1213
- 'scripts/images/datamate-python/**'
1314
- '.github/workflows/docker-image-backend-python.yml'
15+
- '.github/workflows/docker-images-reusable.yml'
1416
workflow_dispatch:
1517
workflow_call:
1618

.github/workflows/docker-image-backend.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ on:
77
- 'backend/**'
88
- 'scripts/images/backend/**'
99
- '.github/workflows/docker-image-backend.yml'
10+
- '.github/workflows/docker-images-reusable.yml'
1011
pull_request:
1112
branches: [ "main" ]
1213
paths:
1314
- 'backend/**'
1415
- 'scripts/images/backend/**'
1516
- '.github/workflows/docker-image-backend.yml'
17+
- '.github/workflows/docker-images-reusable.yml'
1618
workflow_dispatch:
1719
workflow_call:
1820

.github/workflows/docker-image-database.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ on:
77
- 'scripts/db/**'
88
- 'scripts/images/database/**'
99
- '.github/workflows/docker-image-database.yml'
10+
- '.github/workflows/docker-images-reusable.yml'
1011
pull_request:
1112
branches: [ "main" ]
1213
paths:
1314
- 'scripts/db/**'
1415
- 'scripts/images/database/**'
1516
- '.github/workflows/docker-image-database.yml'
17+
- '.github/workflows/docker-images-reusable.yml'
1618
workflow_dispatch:
1719
workflow_call:
1820

.github/workflows/docker-image-deer-flow.yml

Lines changed: 97 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on:
1919
workflow_call:
2020

2121
jobs:
22-
build-and-push:
22+
build-and-push-amd:
2323
runs-on: ubuntu-latest
2424
permissions:
2525
contents: read
@@ -41,26 +41,114 @@ jobs:
4141
run: |
4242
if [[ $GITHUB_REF == refs/tags/v* ]]; then
4343
TAG=${GITHUB_REF#refs/tags/v}
44-
echo "TAGS=$TAG" >> $GITHUB_OUTPUT
44+
echo "TAGS=amd64-$TAG" >> $GITHUB_OUTPUT
4545
elif [[ $GITHUB_REF == refs/heads/main ]]; then
46-
echo "TAGS=latest" >> $GITHUB_OUTPUT
46+
echo "TAGS=amd64" >> $GITHUB_OUTPUT
4747
else
48-
echo "TAGS=temp" >> $GITHUB_OUTPUT
48+
echo "TAGS=amd64-temp" >> $GITHUB_OUTPUT
4949
fi
5050
5151
- name: Build Docker Image
5252
run: |
53-
make build-deer-flow VERSION=latest
53+
cp -n runtime/deer-flow/.env.example runtime/deer-flow/.env
54+
cp -n runtime/deer-flow/conf.yaml.example runtime/deer-flow/conf.yaml
55+
docker build -t deer-flow-backend:amd64 . -f scripts/images/deer-flow-backend/Dockerfile
56+
docker build -t deer-flow-frontend:amd64 . -f scripts/images/deer-flow-frontend/Dockerfile
5457
55-
- name: Tag Docker Image
58+
- name: Tag & Push Docker Image
59+
if: github.event_name != 'pull_request'
5660
run: |
5761
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
58-
docker tag deer-flow-backend:latest ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
59-
docker tag deer-flow-frontend:latest ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}
62+
docker tag deer-flow-backend:amd64 ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
63+
docker tag deer-flow-frontend:amd64 ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}
64+
docker push ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
65+
docker push ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}
66+
6067
61-
- name: Push Docker Image
68+
build-and-push-arm:
69+
runs-on: ubuntu-24.04-arm
70+
permissions:
71+
contents: read
72+
packages: write
73+
74+
steps:
75+
- uses: actions/checkout@v4
76+
77+
- name: Login to GitHub Container Registry
78+
if: github.event_name != 'pull_request'
79+
uses: docker/login-action@v3
80+
with:
81+
registry: ghcr.io
82+
username: ${{ github.actor }}
83+
password: ${{ secrets.GITHUB_TOKEN }}
84+
85+
- name: Set Docker Image Tag
86+
id: set-tag
87+
run: |
88+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
89+
TAG=${GITHUB_REF#refs/tags/v}
90+
echo "TAGS=arm64-$TAG" >> $GITHUB_OUTPUT
91+
elif [[ $GITHUB_REF == refs/heads/main ]]; then
92+
echo "TAGS=arm64" >> $GITHUB_OUTPUT
93+
else
94+
echo "TAGS=arm64-temp" >> $GITHUB_OUTPUT
95+
fi
96+
97+
- name: Build Docker Image
98+
run: |
99+
cp -n runtime/deer-flow/.env.example runtime/deer-flow/.env
100+
cp -n runtime/deer-flow/conf.yaml.example runtime/deer-flow/conf.yaml
101+
docker build -t deer-flow-backend:arm64 . -f scripts/images/deer-flow-backend/Dockerfile
102+
docker build -t deer-flow-frontend:arm64 . -f scripts/images/deer-flow-frontend/Dockerfile
103+
104+
- name: Tag & Push Docker Image
62105
if: github.event_name != 'pull_request'
63106
run: |
64107
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
108+
docker tag deer-flow-backend:arm64 ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
109+
docker tag deer-flow-frontend:arm64 ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}
65110
docker push ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
66111
docker push ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}
112+
113+
manifest:
114+
runs-on: ubuntu-latest
115+
if: github.event_name != 'pull_request'
116+
needs: [ build-and-push-amd, build-and-push-arm ]
117+
steps:
118+
- name: Login to GitHub Container Registry
119+
uses: docker/login-action@v3
120+
with:
121+
registry: ghcr.io
122+
username: ${{ github.actor }}
123+
password: ${{ secrets.GITHUB_TOKEN }}
124+
125+
- name: Set Docker Image Tag
126+
id: set-tag
127+
run: |
128+
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
129+
BASE_IMAGE=ghcr.io/$LOWERCASE_REPO/datamate-${{ inputs.service_name }}
130+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
131+
TAG=${GITHUB_REF#refs/tags/v}
132+
echo "TAGS=$TAG" >> $GITHUB_OUTPUT
133+
echo "ARM_TAGS=arm64-$TAG" >> $GITHUB_OUTPUT
134+
echo "AMD_TAGS=amd64-$TAG" >> $GITHUB_OUTPUT
135+
elif [[ $GITHUB_REF == refs/heads/main ]]; then
136+
echo "TAGS=latest" >> $GITHUB_OUTPUT
137+
echo "ARM_TAGS=arm64" >> $GITHUB_OUTPUT
138+
echo "AMD_TAGS=amd64" >> $GITHUB_OUTPUT
139+
else
140+
echo "TAGS=temp" >> $GITHUB_OUTPUT
141+
echo "ARM_TAGS=arm64-temp" >> $GITHUB_OUTPUT
142+
echo "AMD_TAGS=amd64-temp" >> $GITHUB_OUTPUT
143+
fi
144+
145+
- name: Manifest Docker Image
146+
run: |
147+
docker manifest create ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }} \
148+
ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.AMD_TAGS }} \
149+
ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.ARM_TAGS }}
150+
docker manifest push ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
151+
docker manifest create ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }} \
152+
ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.AMD_TAGS }} \
153+
ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.ARM_TAGS }}
154+
docker manifest push ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}

.github/workflows/docker-image-frontend.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ on:
77
- 'frontend/**'
88
- 'scripts/images/frontend/**'
99
- '.github/workflows/docker-image-frontend.yml'
10+
- '.github/workflows/docker-images-reusable.yml'
1011
pull_request:
1112
branches: [ "main" ]
1213
paths:
1314
- 'frontend/**'
1415
- 'scripts/images/frontend/**'
1516
- '.github/workflows/docker-image-frontend.yml'
17+
- '.github/workflows/docker-images-reusable.yml'
1618
workflow_dispatch:
1719
workflow_call:
1820

.github/workflows/docker-image-runtime.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ on:
88
- 'runtime/python-executor/**'
99
- 'scripts/images/runtime/**'
1010
- '.github/workflows/docker-image-runtime.yml'
11+
- '.github/workflows/docker-images-reusable.yml'
1112
pull_request:
1213
branches: [ "main" ]
1314
paths:
1415
- 'runtime/ops/**'
1516
- 'runtime/python-executor/**'
1617
- 'scripts/images/runtime/**'
1718
- '.github/workflows/docker-image-runtime.yml'
19+
- '.github/workflows/docker-images-reusable.yml'
1820
workflow_dispatch:
1921
workflow_call:
2022

.github/workflows/docker-images-reusable.yml

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
type: string
1212

1313
jobs:
14-
build-and-push:
14+
build-and-push-amd:
1515
runs-on: ubuntu-latest
1616
permissions:
1717
contents: read
@@ -35,19 +35,99 @@ jobs:
3535
BASE_IMAGE=ghcr.io/$LOWERCASE_REPO/datamate-${{ inputs.service_name }}
3636
if [[ $GITHUB_REF == refs/tags/v* ]]; then
3737
TAG=${GITHUB_REF#refs/tags/v}
38-
echo "TAGS=$BASE_IMAGE:$TAG" >> $GITHUB_OUTPUT
38+
echo "TAGS=$BASE_IMAGE:amd64-$TAG" >> $GITHUB_OUTPUT
3939
elif [[ $GITHUB_REF == refs/heads/main ]]; then
40-
echo "TAGS=$BASE_IMAGE:latest" >> $GITHUB_OUTPUT
40+
echo "TAGS=$BASE_IMAGE:amd64" >> $GITHUB_OUTPUT
4141
else
42-
echo "TAGS=$BASE_IMAGE:temp" >> $GITHUB_OUTPUT
42+
echo "TAGS=$BASE_IMAGE:amd64-temp" >> $GITHUB_OUTPUT
4343
fi
4444
4545
- name: Build Docker Image
4646
run: |
47-
make build-${{ inputs.service_name }} VERSION=latest
47+
docker build -t datamate-${{ inputs.service_name }}:amd64 . -f scripts/images/${{ inputs.service_name }}/Dockerfile --platform amd64
4848
4949
- name: Tag & Push Docker Image
5050
if: github.event_name != 'pull_request'
5151
run: |
52-
docker tag datamate-${{ inputs.service_name }}:latest ${{ steps.set-tag.outputs.TAGS }}
53-
docker push ${{ steps.set-tag.outputs.TAGS }}
52+
docker tag datamate-${{ inputs.service_name }}:amd64 ${{ steps.set-tag.outputs.TAGS }}
53+
docker push ${{ steps.set-tag.outputs.TAGS }}
54+
55+
build-and-push-arm:
56+
runs-on: ubuntu-24.04-arm
57+
permissions:
58+
contents: read
59+
packages: write
60+
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- name: Login to GitHub Container Registry
65+
if: github.event_name != 'pull_request'
66+
uses: docker/login-action@v3
67+
with:
68+
registry: ghcr.io
69+
username: ${{ github.actor }}
70+
password: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Set Docker Image Tag
73+
id: set-tag
74+
run: |
75+
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
76+
BASE_IMAGE=ghcr.io/$LOWERCASE_REPO/datamate-${{ inputs.service_name }}
77+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
78+
TAG=${GITHUB_REF#refs/tags/v}
79+
echo "TAGS=$BASE_IMAGE:arm64-$TAG" >> $GITHUB_OUTPUT
80+
elif [[ $GITHUB_REF == refs/heads/main ]]; then
81+
echo "TAGS=$BASE_IMAGE:arm64" >> $GITHUB_OUTPUT
82+
else
83+
echo "TAGS=$BASE_IMAGE:arm64-temp" >> $GITHUB_OUTPUT
84+
fi
85+
86+
- name: Build Docker Image
87+
run: |
88+
docker build -t datamate-${{ inputs.service_name }}:arm64 . -f scripts/images/${{ inputs.service_name }}/Dockerfile --platform arm64
89+
90+
- name: Tag & Push Docker Image
91+
if: github.event_name != 'pull_request'
92+
run: |
93+
docker tag datamate-${{ inputs.service_name }}:arm64 ${{ steps.set-tag.outputs.TAGS }}
94+
docker push ${{ steps.set-tag.outputs.TAGS }}
95+
96+
manifest:
97+
runs-on: ubuntu-latest
98+
if: github.event_name != 'pull_request'
99+
needs: [ build-and-push-amd, build-and-push-arm ]
100+
steps:
101+
- name: Login to GitHub Container Registry
102+
uses: docker/login-action@v3
103+
with:
104+
registry: ghcr.io
105+
username: ${{ github.actor }}
106+
password: ${{ secrets.GITHUB_TOKEN }}
107+
108+
- name: Set Docker Image Tag
109+
id: set-tag
110+
run: |
111+
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
112+
BASE_IMAGE=ghcr.io/$LOWERCASE_REPO/datamate-${{ inputs.service_name }}
113+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
114+
TAG=${GITHUB_REF#refs/tags/v}
115+
echo "TAGS=$BASE_IMAGE:$TAG" >> $GITHUB_OUTPUT
116+
echo "ARM_TAGS=$BASE_IMAGE:arm64-$TAG" >> $GITHUB_OUTPUT
117+
echo "AMD_TAGS=$BASE_IMAGE:amd64-$TAG" >> $GITHUB_OUTPUT
118+
elif [[ $GITHUB_REF == refs/heads/main ]]; then
119+
echo "TAGS=$BASE_IMAGE:latest" >> $GITHUB_OUTPUT
120+
echo "ARM_TAGS=$BASE_IMAGE:arm64" >> $GITHUB_OUTPUT
121+
echo "AMD_TAGS=$BASE_IMAGE:amd64" >> $GITHUB_OUTPUT
122+
else
123+
echo "TAGS=$BASE_IMAGE:temp" >> $GITHUB_OUTPUT
124+
echo "ARM_TAGS=$BASE_IMAGE:arm64-temp" >> $GITHUB_OUTPUT
125+
echo "AMD_TAGS=$BASE_IMAGE:amd64-temp" >> $GITHUB_OUTPUT
126+
fi
127+
128+
- name: Manifest Docker Image
129+
run: |
130+
docker manifest create ${{ steps.set-tag.outputs.TAGS }} \
131+
${{ steps.set-tag.outputs.AMD_TAGS }} \
132+
${{ steps.set-tag.outputs.ARM_TAGS }}
133+
docker manifest push ${{ steps.set-tag.outputs.TAGS }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ runtime-docker-build:
119119

120120
.PHONY: backend-python-docker-build
121121
backend-python-docker-build:
122-
docker build -t datamate-backend-python:$(VERSION) . -f scripts/images/datamate-python/Dockerfile
122+
docker build -t datamate-backend-python:$(VERSION) . -f scripts/images/backend-python/Dockerfile
123123

124124
.PHONY: deer-flow-docker-build
125125
deer-flow-docker-build:

0 commit comments

Comments
 (0)