[CI] Add Docker build and push workflows with cross-platform support#279
[CI] Add Docker build and push workflows with cross-platform support#279hzxuzhonghu merged 18 commits intovolcano-sh:mainfrom huntersman:hunter/dev/CI
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @huntersman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly upgrades the project's Docker build and deployment infrastructure. It introduces new GitHub Actions workflows to automate the building and pushing of Docker images, ensuring a more streamlined and consistent CI/CD pipeline. Furthermore, the changes optimize Dockerfile build steps by implementing Go module dependency caching, leading to faster and more efficient builds. The Makefile has also been refactored to enhance cross-platform build support and simplify the overall build process for all services.
Highlights
- CI/CD Automation: New GitHub Actions workflows (
docker-build.ymlanddocker-push.yml) have been added to automate the Docker image build process on pull requests and push to the main branch, including proper authentication for GitHub Container Registry. - Docker Build Optimization: All service Dockerfiles have been updated to include a
RUN go mod downloadstep before the main build, which significantly improves build performance and reliability by caching Go module dependencies. - Makefile Enhancements: The
Makefilehas been refactored to include a newdocker-build-alltarget for building all service images at once. Additionally, thedocker-buildxtarget now dynamically creates temporary Dockerfiles with--platform=${BUILDPLATFORM}for robust cross-platform builds and includes cleanup steps.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Code flows, builds take flight,Docker hums, cross-platform dreams,New images rise.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces CI/CD workflows for Docker builds and improves Dockerfiles for better caching. My review focuses on the Makefile and Dockerfile changes.
I've identified a critical issue in the Makefile's docker-buildx target where the logic for creating cross-platform Dockerfiles is flawed and will not work as intended. I also pointed out that build errors are being suppressed, which could hide problems in CI.
Furthermore, the Dockerfile changes intended to improve caching are not implemented optimally. For several services, the entire project is copied before downloading dependencies, which negates caching benefits. For others, the order of COPY operations is incorrect, leading to the same problem. I've provided suggestions to fix these caching issues to align with best practices and the PR's goal.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request significantly improves the Docker build process by introducing CI/CD workflows and optimizing the Dockerfiles for better layer caching. The changes to the Dockerfiles to cache Go module dependencies are excellent and follow best practices. My main feedback is on the Makefile's docker-buildx target, which currently suppresses build errors. I've provided a critical comment with a suggestion to make the build process more robust by ensuring errors are propagated and cleanup is handled reliably.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
|
I am thinking if we can use https://github.com/docker/build-push-action and then |
This comment was marked as resolved.
This comment was marked as resolved.
|
they does not conflict, seems |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
| with: | ||
| context: ./python | ||
| platforms: ${{ steps.platforms.outputs.platforms }} | ||
| push: ${{ github.event_name != 'pull_request' }} |
There was a problem hiding this comment.
💯 Curious why separate the job
There was a problem hiding this comment.
If someone only modified Python, we don't expect to build the Go Docker image, right?
There was a problem hiding this comment.
Building an amd64 image is fast, but building an arm64 image is very slow. Separate the job to save time.
Prepare your ladder, lol |
hzxuzhonghu
left a comment
There was a problem hiding this comment.
We can make use of docker buildx cache to speed up image build later https://docs.docker.com/build/cache/

What type of PR is this?
/kind enhancement
What this PR does / why we need it:
This pull request introduces significant improvements to the Docker build and deployment process by adding GitHub Actions workflows for building and pushing Docker images, optimizing Dockerfile build steps for better caching, and refactoring the Makefile for more robust cross-platform builds.
CI/CD Automation:
.github/workflows/docker-build.ymlto automate Docker image builds on pull requests and manual triggers using GitHub Actions..github/workflows/docker-push.ymlto build and push Docker images to GitHub Container Registry on pushes tomain, with proper authentication and permissions.Docker Build Improvements:
Makefile Refactoring:
docker-build-alltarget to theMakefileto streamline building all service images at once.docker-buildxtarget to use temporary Dockerfiles with the--platform=${BUILDPLATFORM}directive for better cross-platform support, and to clean up after builds.Which issue(s) this PR fixes:
Fixes #226 #227
Special notes for your reviewer:
Docker build will run when a PR is created to check if the Docker image can be built successfully.
Docker push will only run in
matrixinfer-ai/matrixinferwhen PR is merged.It takes about 16 minutes for
docker build, 30 minutes fordocker push.docker pushusesdocker buildx, which costs more time thandocker buildSelf test -> https://github.com/huntersman/matrixinfer/actions/runs/17232176380/job/48888528367

And all images are tagged
latest. I think we can use a specific tag for the release branch, and for the main branch, uselatest.Both

docker buildanddocker pushcan be manually run in actions.Does this PR introduce a user-facing change?: