Skip to content

Commit 9dd26d6

Browse files
authored
feature: 数据库镜像制作 (#70)
* feature: 数据库镜像制作 * feature: 增加归档包流水线
1 parent 8a0228b commit 9dd26d6

28 files changed

+379
-79
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
- 'scripts/images/datamate-python/**'
1515
- '.github/workflows/docker-image-backend-python.yml'
1616
workflow_dispatch:
17+
workflow_call:
1718

1819
jobs:
1920
call-docker-build:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
- 'scripts/images/backend/**'
1515
- '.github/workflows/docker-image-backend.yml'
1616
workflow_dispatch:
17+
workflow_call:
1718

1819
jobs:
1920
call-docker-build:
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Database Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- 'scripts/db/**'
8+
- 'scripts/images/database/**'
9+
- '.github/workflows/docker-image-database.yml'
10+
pull_request:
11+
branches: [ "main" ]
12+
paths:
13+
- 'scripts/db/**'
14+
- 'scripts/images/database/**'
15+
- '.github/workflows/docker-image-database.yml'
16+
workflow_dispatch:
17+
workflow_call:
18+
19+
jobs:
20+
call-docker-build:
21+
name: Build and Push Database Docker Image
22+
uses: ./.github/workflows/docker-images-reusable.yml
23+
permissions:
24+
contents: read
25+
packages: write
26+
with:
27+
service_name: database
28+
build_dir: .

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
- 'scripts/images/deer-flow-frontend/**'
1717
- '.github/workflows/docker-image-deer-flow.yml'
1818
workflow_dispatch:
19+
workflow_call:
1920

2021
jobs:
2122
build-and-push:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
- 'scripts/images/frontend/**'
1515
- '.github/workflows/docker-image-frontend.yml'
1616
workflow_dispatch:
17+
workflow_call:
1718

1819
jobs:
1920
call-docker-build:

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@ on:
44
push:
55
branches: [ "main" ]
66
paths:
7-
- 'runtime/**'
7+
- 'runtime/ops/**'
8+
- 'runtime/python-executor/**'
89
- 'scripts/images/runtime/**'
910
- '.github/workflows/docker-image-runtime.yml'
1011
pull_request:
1112
branches: [ "main" ]
1213
paths:
13-
- 'runtime/**'
14+
- 'runtime/ops/**'
15+
- 'runtime/python-executor/**'
1416
- 'scripts/images/runtime/**'
1517
- '.github/workflows/docker-image-runtime.yml'
1618
workflow_dispatch:
19+
workflow_call:
1720

1821
jobs:
1922
call-docker-build:

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,18 @@ jobs:
5151
docker tag datamate-${{ inputs.service_name }}:latest ${{ steps.set-tag.outputs.TAGS }}
5252
5353
- name: Push Docker Image
54-
if: github.event_name != 'pull_request'
54+
if: github.event_name != 'pull_request' && !startsWith(github.workflow, 'Package')
5555
run: |
5656
docker push ${{ steps.set-tag.outputs.TAGS }}
5757
58+
- name: Save Docker Image
59+
if: startsWith(github.workflow, 'Package')
60+
run: |
61+
docker save -o datamate-${{ inputs.service_name }}.tar ${{ steps.set-tag.outputs.TAGS }}
62+
63+
- name: Upload Docker Image
64+
if: startsWith(github.workflow, 'Package')
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: datamate-${{ inputs.service_name }}
68+
path: datamate-${{ inputs.service_name }}.tar

.github/workflows/package.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Package All
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
backend-docker-build:
8+
name: Build and Push Backend Docker Image
9+
uses: ./.github/workflows/docker-image-backend.yml
10+
11+
frontend-docker-build:
12+
name: Build and Push Frontend Docker Image
13+
uses: ./.github/workflows/docker-image-frontend.yml
14+
15+
database-docker-build:
16+
name: Build and Push Database Docker Image
17+
uses: ./.github/workflows/docker-image-database.yml
18+
19+
runtime-docker-build:
20+
name: Build and Push Runtime Docker Image
21+
uses: ./.github/workflows/docker-image-runtime.yml
22+
23+
backend-python-docker-build:
24+
name: Build and Push Backend Python Docker Image
25+
uses: ./.github/workflows/docker-image-backend-python.yml
26+
27+
package-all:
28+
needs:
29+
- backend-docker-build
30+
- frontend-docker-build
31+
- database-docker-build
32+
- backend-python-docker-build
33+
- runtime-docker-build
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Save Image
40+
uses: actions/download-artifact@v5
41+
with:
42+
path: images
43+
pattern: datamate-*
44+
merge-multiple: true
45+
46+
- name: Package
47+
run: |
48+
cp runtime/deer-flow/.env.example deployment/docker/deer-flow/.env
49+
cp runtime/deer-flow/conf.yaml.example deployment/docker/deer-flow/conf.yaml
50+
cp runtime/deer-flow/.env.example deployment/helm/deer-flow/charts/public/.env
51+
cp runtime/deer-flow/conf.yaml.example deployment/helm/deer-flow/charts/public/conf.yaml
52+
tar -cvf datamate.tar deployment/ images
53+
54+
- name: Upload Package
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: package
58+
path: datamate.tar

Makefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ build-%:
1818
$(MAKE) $*-docker-build
1919

2020
.PHONY: build
21-
build: backend-docker-build frontend-docker-build runtime-docker-build
21+
build: database-docker-build backend-docker-build frontend-docker-build runtime-docker-build
2222

2323
.PHONY: create-namespace
2424
create-namespace:
@@ -105,6 +105,10 @@ endif
105105
backend-docker-build:
106106
docker build -t datamate-backend:$(VERSION) . -f scripts/images/backend/Dockerfile
107107

108+
.PHONY: database-docker-build
109+
database-docker-build:
110+
docker build -t datamate-database:$(VERSION) . -f scripts/images/database/Dockerfile
111+
108112
.PHONY: frontend-docker-build
109113
frontend-docker-build:
110114
docker build -t datamate-frontend:$(VERSION) . -f scripts/images/frontend/Dockerfile
@@ -206,20 +210,18 @@ milvus-docker-uninstall:
206210

207211
.PHONY: datamate-k8s-install
208212
datamate-k8s-install: create-namespace
209-
kubectl create configmap datamate-init-sql --from-file=scripts/db/ --dry-run=client -o yaml | kubectl apply -f - -n $(NAMESPACE)
210-
helm upgrade datamate deployment/helm/datamate/ -n $(NAMESPACE) --install --set global.image.repository=$(REPOSITORY)
213+
helm upgrade datamate deployment/helm/datamate/ -n $(NAMESPACE) --install --set global.image.repository=$(REGISTRY)
211214

212215
.PHONY: datamate-k8s-uninstall
213216
datamate-k8s-uninstall:
214217
helm uninstall datamate -n $(NAMESPACE) --ignore-not-found
215-
kubectl delete configmap datamate-init-sql -n $(NAMESPACE) --ignore-not-found
216218

217219
.PHONY: deer-flow-k8s-install
218220
deer-flow-k8s-install:
219-
helm upgrade datamate deployment/helm/datamate/ -n $(NAMESPACE) --install --set global.deerFlow.enable=true --set global.image.repository=$(REPOSITORY)
221+
helm upgrade datamate deployment/helm/datamate/ -n $(NAMESPACE) --install --set global.deerFlow.enable=true --set global.image.repository=$(REGISTRY)
220222
cp runtime/deer-flow/.env deployment/helm/deer-flow/charts/public/.env
221223
cp runtime/deer-flow/conf.yaml deployment/helm/deer-flow/charts/public/conf.yaml
222-
helm upgrade deer-flow deployment/helm/deer-flow -n $(NAMESPACE) --install --set global.image.repository=$(REPOSITORY)
224+
helm upgrade deer-flow deployment/helm/deer-flow -n $(NAMESPACE) --install --set global.image.repository=$(REGISTRY)
223225

224226
.PHONY: deer-flow-k8s-uninstall
225227
deer-flow-k8s-uninstall:

deployment/docker/datamate/docker-compose.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ services:
4949
# 3) database
5050
datamate-database:
5151
container_name: datamate-database
52-
image: mysql:8
52+
image: ${REGISTRY:-}datamate-database
5353
restart: on-failure
5454
environment:
5555
MYSQL_ROOT_PASSWORD: password
@@ -61,8 +61,6 @@ services:
6161
"
6262
volumes:
6363
- mysql_volume:/var/lib/mysql
64-
- ../../../scripts/db:/docker-entrypoint-initdb.d
65-
- ./utf8.cnf:/etc/mysql/conf.d/utf8.cnf:ro
6664
- database_log_volume:/var/log/datamate/database
6765
ports:
6866
- "3306:3306"

0 commit comments

Comments
 (0)