-
Notifications
You must be signed in to change notification settings - Fork 25
QEMU cross platform #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,17 @@ | ||
| # 前端构建阶段 | ||
| FROM node:18 AS frontend-builder | ||
| FROM --platform=$BUILDPLATFORM node:18 AS frontend-builder | ||
| WORKDIR /app | ||
| # 复制 excalidraw 子模块 | ||
| COPY excalidraw/ ./excalidraw/ | ||
| # 构建前端 | ||
| RUN cd excalidraw && npm install -g pnpm && pnpm install && cd excalidraw-app && DISABLE_VITE_CHECKER=true pnpm build:app:docker | ||
|
|
||
| # 后端构建阶段 | ||
| FROM golang:alpine AS backend-builder | ||
| FROM --platform=$BUILDPLATFORM golang:alpine AS backend-builder | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 |
||
| RUN apk update && apk add --no-cache git | ||
| WORKDIR /app | ||
| ARG TARGETOS | ||
| ARG TARGETARCH | ||
| # 复制 Go 模块文件 | ||
| COPY go.mod go.sum ./ | ||
| RUN go mod download | ||
|
|
@@ -18,10 +20,10 @@ COPY . . | |
| # 复制前端构建文件到正确位置,以便 Go embed 可以找到 | ||
| COPY --from=frontend-builder /app/excalidraw/excalidraw-app/build ./frontend/ | ||
| # 构建 Go 应用 | ||
| RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . | ||
| RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w" -o main . | ||
|
|
||
| # 最终运行镜像 | ||
| FROM alpine:latest | ||
| FROM --platform=$TARGETPLATFORM alpine:latest | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| RUN apk --no-cache add ca-certificates | ||
| WORKDIR /root/ | ||
| # 复制后端二进制文件(已包含嵌入的前端文件) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-alpinewould also align with the other stages that use Alpine, potentially reducing the overall build size and complexity.