Skip to content

QEMU cross platform#14

Merged
BetterAndBetterII merged 1 commit into
mainfrom
qemu-package
Aug 25, 2025
Merged

QEMU cross platform#14
BetterAndBetterII merged 1 commit into
mainfrom
qemu-package

Conversation

@BetterAndBetterII
Copy link
Copy Markdown
Owner

This pull request updates the Docker build configuration and Dockerfile to support multi-platform builds (specifically linux/amd64 and linux/arm64). The changes ensure that builds can run on both x86 and ARM architectures by setting up QEMU for emulation, specifying build platforms in the workflow, and using platform-specific Dockerfile syntax and build arguments.

Multi-platform build support:

  • Added the Set up QEMU step in both .github/workflows/docker-build.yml and .github/workflows/docker-build-dev.yml to enable emulation for ARM builds. [1] [2]
  • Updated the Docker build steps in both workflows to specify platforms: linux/amd64,linux/arm64 for multi-architecture image builds. [1] [2]

Dockerfile improvements for cross-platform builds:

  • Modified all FROM instructions in excalidraw-complete.Dockerfile to use the --platform flag, enabling platform-specific builds.
  • Added build arguments (TARGETOS, TARGETARCH, TARGETPLATFORM) and updated the Go build command to use these for correct cross-compilation. [1] [2]

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @BetterAndBetterII, 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 enhances the build system by enabling multi-architecture Docker image creation, supporting both amd64 and arm64 platforms. It achieves this by integrating QEMU emulation into the GitHub Actions workflows and updating the Dockerfile to dynamically select base images and cross-compile the Go backend based on the target architecture. This change streamlines the deployment process across diverse hardware environments.

Highlights

  • Multi-platform Docker Builds: The pull request introduces support for building Docker images compatible with multiple architectures, specifically linux/amd64 and linux/arm64, ensuring broader compatibility.
  • QEMU Integration in CI: GitHub Actions workflows (docker-build.yml and docker-build-dev.yml) have been updated to include a 'Set up QEMU' step, which is crucial for emulating ARM environments during builds on x86 machines.
  • Dockerfile Platform Selection: The excalidraw-complete.Dockerfile has been modified to use the --platform flag in its FROM instructions, allowing Docker to select the appropriate base images for different target architectures.
  • Dynamic Go Cross-Compilation: The Go backend compilation process within the Dockerfile now dynamically uses TARGETOS and TARGETARCH build arguments, enabling correct cross-compilation for the specified target platform.
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.

Footnotes

  1. 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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly updates the Dockerfile to support multi-platform builds for linux/amd64 and linux/arm64. The use of BUILDPLATFORM, TARGETPLATFORM, TARGETOS, and TARGETARCH is appropriate and follows modern Docker practices. The Go build command is also improved by stripping the binary for a smaller size. My feedback focuses on improving the reproducibility and stability of the Docker builds by pinning base image versions instead of using floating or latest tags.


# 最终运行镜像
FROM alpine:latest
FROM --platform=$TARGETPLATFORM alpine:latest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using the latest tag for a base image in a production Dockerfile is risky because it can pull in breaking changes unexpectedly, making your builds non-reproducible. It's a strong best practice to pin to a specific version tag, for example alpine:3.20.

FROM --platform=$TARGETPLATFORM alpine:3.20

@@ -1,15 +1,17 @@
# 前端构建阶段
FROM node:18 AS frontend-builder
FROM --platform=$BUILDPLATFORM node:18 AS frontend-builder
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better reproducibility and to keep image layers consistent, it's recommended to use a specific version and variant for the base image. Using an Alpine-based image like node:18-alpine would also align with the other stages that use Alpine, potentially reducing the overall build size and complexity.

FROM --platform=$BUILDPLATFORM node:18-alpine AS frontend-builder


# 后端构建阶段
FROM golang:alpine AS backend-builder
FROM --platform=$BUILDPLATFORM golang:alpine AS backend-builder
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure consistent and reproducible builds, it's best to pin the Go image to a specific version rather than using a broad tag like alpine. Your go.mod file specifies toolchain go1.24.4, so using a matching image version is advisable.

FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS backend-builder

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@BetterAndBetterII BetterAndBetterII merged commit eadacd9 into main Aug 25, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants