Skip to content

Commit d8b7b45

Browse files
authored
ci: add docker image build workflow and improve mcp tool handling (#194)
* fix: improve MCP tool parameter handling and upgrade agentscope - Fix required parameter handling in MCP tool schema conversion - Fix DashScope image model client constructor compatibility - Upgrade agentscope from 1.0.6 to 1.0.10 🤖 Generated with [Qoder][https://qoder.com] * feat: add Docker image build and push workflow - Build 4 images: backend, admin, frontend, sandbox - Trigger on main branch push and version tags - Support multi-arch (amd64/arm64) - Only run in main repo or authorized forks 🤖 Generated with [Qoder](https://qoder.com)
1 parent 3560bb2 commit d8b7b45

File tree

1 file changed

+373
-0
lines changed

1 file changed

+373
-0
lines changed
Lines changed: 373 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,373 @@
1+
name: Build Docker Images and Push to Image Registry
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*.*.*"
9+
workflow_dispatch:
10+
inputs:
11+
push_images:
12+
description: "Push images to registry"
13+
required: false
14+
default: "true"
15+
type: boolean
16+
17+
# Limit workflow permissions
18+
permissions:
19+
contents: read
20+
21+
env:
22+
# Default registry (can be overridden by repository variables)
23+
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY || 'opensource-registry.cn-hangzhou.cr.aliyuncs.com' }}
24+
IMAGE_NAMESPACE: ${{ vars.IMAGE_NAMESPACE || 'himarket' }}
25+
26+
jobs:
27+
# ===========================================
28+
# Backend Image Build
29+
# ===========================================
30+
build-backend:
31+
name: Build Backend Image
32+
runs-on: ubuntu-latest
33+
# Only run in the main repository or specific forks (others don't have registry credentials)
34+
if: github.repository == 'higress-group/himarket' || github.repository == 'lexburner/himarket'
35+
environment: image-registry
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
41+
- name: Set up JDK 17
42+
uses: actions/setup-java@v4
43+
with:
44+
java-version: '17'
45+
distribution: 'temurin'
46+
cache: 'maven'
47+
48+
- name: Build with Maven
49+
run: mvn clean package -DskipTests -B
50+
51+
- name: Set up QEMU
52+
uses: docker/setup-qemu-action@v3
53+
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
57+
- name: Login to Docker Registry
58+
if: github.event_name == 'push' || inputs.push_images == true
59+
uses: docker/login-action@v3
60+
with:
61+
registry: ${{ env.IMAGE_REGISTRY }}
62+
username: ${{ secrets.REGISTRY_USERNAME }}
63+
password: ${{ secrets.REGISTRY_PASSWORD }}
64+
65+
- name: Calculate Docker metadata
66+
id: docker-meta
67+
uses: docker/metadata-action@v5
68+
with:
69+
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-backend
70+
tags: |
71+
type=sha
72+
type=ref,event=tag
73+
type=semver,pattern={{version}}
74+
type=raw,value=latest
75+
76+
- name: Build and push Docker image
77+
uses: docker/build-push-action@v5
78+
with:
79+
context: himarket-bootstrap
80+
file: himarket-bootstrap/Dockerfile
81+
platforms: linux/amd64,linux/arm64
82+
push: ${{ github.event_name == 'push' || inputs.push_images == true }}
83+
tags: ${{ steps.docker-meta.outputs.tags }}
84+
labels: ${{ steps.docker-meta.outputs.labels }}
85+
cache-from: type=gha
86+
cache-to: type=gha,mode=max
87+
88+
- name: Build summary
89+
run: |
90+
echo "## 🐳 Backend Image Build" >> $GITHUB_STEP_SUMMARY
91+
echo "" >> $GITHUB_STEP_SUMMARY
92+
echo "**Image**: \`${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-backend\`" >> $GITHUB_STEP_SUMMARY
93+
echo "" >> $GITHUB_STEP_SUMMARY
94+
echo "**Tags**:" >> $GITHUB_STEP_SUMMARY
95+
echo "${{ steps.docker-meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
96+
97+
# ===========================================
98+
# Frontend - Admin Portal Build
99+
# ===========================================
100+
build-admin:
101+
name: Build Admin Portal Image
102+
runs-on: ubuntu-latest
103+
if: github.repository == 'higress-group/himarket' || github.repository == 'lexburner/himarket'
104+
environment: image-registry
105+
106+
steps:
107+
- name: Checkout code
108+
uses: actions/checkout@v4
109+
110+
- name: Set up Node.js
111+
uses: actions/setup-node@v4
112+
with:
113+
node-version: '20'
114+
115+
- name: Install dependencies
116+
working-directory: himarket-web/himarket-admin
117+
run: npm install --legacy-peer-deps
118+
119+
- name: Build project
120+
working-directory: himarket-web/himarket-admin
121+
run: npm run build
122+
env:
123+
NODE_ENV: production
124+
125+
- name: Set up QEMU
126+
uses: docker/setup-qemu-action@v3
127+
128+
- name: Set up Docker Buildx
129+
uses: docker/setup-buildx-action@v3
130+
131+
- name: Login to Docker Registry
132+
if: github.event_name == 'push' || inputs.push_images == true
133+
uses: docker/login-action@v3
134+
with:
135+
registry: ${{ env.IMAGE_REGISTRY }}
136+
username: ${{ secrets.REGISTRY_USERNAME }}
137+
password: ${{ secrets.REGISTRY_PASSWORD }}
138+
139+
- name: Calculate Docker metadata
140+
id: docker-meta
141+
uses: docker/metadata-action@v5
142+
with:
143+
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-admin
144+
tags: |
145+
type=sha
146+
type=ref,event=tag
147+
type=semver,pattern={{version}}
148+
type=raw,value=latest
149+
150+
- name: Build and push Docker image
151+
uses: docker/build-push-action@v5
152+
with:
153+
context: himarket-web/himarket-admin
154+
file: himarket-web/himarket-admin/Dockerfile
155+
platforms: linux/amd64,linux/arm64
156+
push: ${{ github.event_name == 'push' || inputs.push_images == true }}
157+
tags: ${{ steps.docker-meta.outputs.tags }}
158+
labels: ${{ steps.docker-meta.outputs.labels }}
159+
cache-from: type=gha
160+
cache-to: type=gha,mode=max
161+
162+
- name: Build summary
163+
run: |
164+
echo "## 🐳 Admin Portal Image Build" >> $GITHUB_STEP_SUMMARY
165+
echo "" >> $GITHUB_STEP_SUMMARY
166+
echo "**Image**: \`${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-admin\`" >> $GITHUB_STEP_SUMMARY
167+
echo "" >> $GITHUB_STEP_SUMMARY
168+
echo "**Tags**:" >> $GITHUB_STEP_SUMMARY
169+
echo "${{ steps.docker-meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
170+
171+
# ===========================================
172+
# Frontend - Developer Portal Build
173+
# ===========================================
174+
build-frontend:
175+
name: Build Developer Portal Image
176+
runs-on: ubuntu-latest
177+
if: github.repository == 'higress-group/himarket' || github.repository == 'lexburner/himarket'
178+
environment: image-registry
179+
180+
steps:
181+
- name: Checkout code
182+
uses: actions/checkout@v4
183+
184+
- name: Set up Node.js
185+
uses: actions/setup-node@v4
186+
with:
187+
node-version: '20'
188+
189+
- name: Install dependencies
190+
working-directory: himarket-web/himarket-frontend
191+
run: npm install --legacy-peer-deps
192+
193+
- name: Build project
194+
working-directory: himarket-web/himarket-frontend
195+
run: npm run build
196+
env:
197+
NODE_ENV: production
198+
199+
- name: Set up QEMU
200+
uses: docker/setup-qemu-action@v3
201+
202+
- name: Set up Docker Buildx
203+
uses: docker/setup-buildx-action@v3
204+
205+
- name: Login to Docker Registry
206+
if: github.event_name == 'push' || inputs.push_images == true
207+
uses: docker/login-action@v3
208+
with:
209+
registry: ${{ env.IMAGE_REGISTRY }}
210+
username: ${{ secrets.REGISTRY_USERNAME }}
211+
password: ${{ secrets.REGISTRY_PASSWORD }}
212+
213+
- name: Calculate Docker metadata
214+
id: docker-meta
215+
uses: docker/metadata-action@v5
216+
with:
217+
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-frontend
218+
tags: |
219+
type=sha
220+
type=ref,event=tag
221+
type=semver,pattern={{version}}
222+
type=raw,value=latest
223+
224+
- name: Build and push Docker image
225+
uses: docker/build-push-action@v5
226+
with:
227+
context: himarket-web/himarket-frontend
228+
file: himarket-web/himarket-frontend/Dockerfile
229+
platforms: linux/amd64,linux/arm64
230+
push: ${{ github.event_name == 'push' || inputs.push_images == true }}
231+
tags: ${{ steps.docker-meta.outputs.tags }}
232+
labels: ${{ steps.docker-meta.outputs.labels }}
233+
cache-from: type=gha
234+
cache-to: type=gha,mode=max
235+
236+
- name: Build summary
237+
run: |
238+
echo "## 🐳 Developer Portal Image Build" >> $GITHUB_STEP_SUMMARY
239+
echo "" >> $GITHUB_STEP_SUMMARY
240+
echo "**Image**: \`${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-frontend\`" >> $GITHUB_STEP_SUMMARY
241+
echo "" >> $GITHUB_STEP_SUMMARY
242+
echo "**Tags**:" >> $GITHUB_STEP_SUMMARY
243+
echo "${{ steps.docker-meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
244+
245+
# ===========================================
246+
# Sandbox Image Build
247+
# ===========================================
248+
build-sandbox:
249+
name: Build Sandbox Image
250+
runs-on: ubuntu-latest
251+
if: github.repository == 'higress-group/himarket' || github.repository == 'lexburner/himarket'
252+
environment: image-registry
253+
254+
steps:
255+
- name: Checkout code
256+
uses: actions/checkout@v4
257+
258+
- name: Set up QEMU
259+
uses: docker/setup-qemu-action@v3
260+
261+
- name: Set up Docker Buildx
262+
uses: docker/setup-buildx-action@v3
263+
264+
- name: Login to Docker Registry
265+
if: github.event_name == 'push' || inputs.push_images == true
266+
uses: docker/login-action@v3
267+
with:
268+
registry: ${{ env.IMAGE_REGISTRY }}
269+
username: ${{ secrets.REGISTRY_USERNAME }}
270+
password: ${{ secrets.REGISTRY_PASSWORD }}
271+
272+
- name: Calculate Docker metadata
273+
id: docker-meta
274+
uses: docker/metadata-action@v5
275+
with:
276+
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-sandbox
277+
tags: |
278+
type=sha
279+
type=ref,event=tag
280+
type=semver,pattern={{version}}
281+
type=raw,value=latest
282+
283+
- name: Build and push Docker image
284+
uses: docker/build-push-action@v5
285+
with:
286+
context: sandbox
287+
file: sandbox/Dockerfile
288+
platforms: linux/amd64,linux/arm64
289+
push: ${{ github.event_name == 'push' || inputs.push_images == true }}
290+
tags: ${{ steps.docker-meta.outputs.tags }}
291+
labels: ${{ steps.docker-meta.outputs.labels }}
292+
cache-from: type=gha
293+
cache-to: type=gha,mode=max
294+
295+
- name: Build summary
296+
run: |
297+
echo "## 🐳 Sandbox Image Build" >> $GITHUB_STEP_SUMMARY
298+
echo "" >> $GITHUB_STEP_SUMMARY
299+
echo "**Image**: \`${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-sandbox\`" >> $GITHUB_STEP_SUMMARY
300+
echo "" >> $GITHUB_STEP_SUMMARY
301+
echo "**Tags**:" >> $GITHUB_STEP_SUMMARY
302+
echo "${{ steps.docker-meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
303+
304+
# ===========================================
305+
# Build Summary
306+
# ===========================================
307+
build-summary:
308+
name: Build Summary
309+
runs-on: ubuntu-latest
310+
needs: [build-backend, build-admin, build-frontend, build-sandbox]
311+
if: always()
312+
313+
steps:
314+
- name: Generate summary
315+
uses: actions/github-script@v7
316+
with:
317+
script: |
318+
const jobs = [
319+
{ name: 'Backend Image', status: '${{ needs.build-backend.result }}' },
320+
{ name: 'Admin Portal Image', status: '${{ needs.build-admin.result }}' },
321+
{ name: 'Developer Portal Image', status: '${{ needs.build-frontend.result }}' },
322+
{ name: 'Sandbox Image', status: '${{ needs.build-sandbox.result }}' }
323+
];
324+
325+
let summary = '## 🐳 Docker Image Build Summary\n\n';
326+
let allPassed = true;
327+
328+
jobs.forEach(job => {
329+
let icon = '✅';
330+
let statusText = job.status;
331+
332+
if (job.status === 'success') {
333+
icon = '✅';
334+
statusText = 'Built & Pushed';
335+
} else if (job.status === 'failure') {
336+
icon = '❌';
337+
statusText = 'Failed';
338+
allPassed = false;
339+
} else if (job.status === 'cancelled') {
340+
icon = '🚫';
341+
statusText = 'Cancelled';
342+
allPassed = false;
343+
} else if (job.status === 'skipped') {
344+
icon = '⏭️';
345+
statusText = 'Skipped';
346+
} else {
347+
icon = '⚠️';
348+
allPassed = false;
349+
}
350+
351+
summary += `${icon} **${job.name}**: ${statusText}\n`;
352+
});
353+
354+
summary += '\n---\n\n';
355+
356+
if (allPassed) {
357+
summary += '🎉 **All images built and pushed successfully!**\n\n';
358+
summary += '### 📦 Images\n\n';
359+
summary += `- Backend: \`${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-backend:latest\`\n';
360+
summary += `- Admin Portal: \`${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-admin:latest\`\n';
361+
summary += `- Developer Portal: \`${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-frontend:latest\`\n';
362+
summary += `- Sandbox: \`${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/himarket-sandbox:latest\`\n`;
363+
} else {
364+
summary += '⚠️ **Some image builds failed.** Please check the logs above.\n';
365+
}
366+
367+
await core.summary
368+
.addRaw(summary)
369+
.write();
370+
371+
if (!allPassed) {
372+
core.setFailed('Some Docker image builds failed');
373+
}

0 commit comments

Comments
 (0)