mirror of
https://github.com/Dvorinka/excalidraw-full.git
synced 2026-07-29 07:33:47 +00:00
更新 Dockerfile 和 GitHub Actions 工作流,支持多平台构建。添加 QEMU 设置以支持不同架构,修改 Dockerfile 以使用动态平台参数构建前后端应用。 (#14)
This commit is contained in:
@@ -42,6 +42,9 @@ jobs:
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
@@ -51,6 +54,7 @@ jobs:
|
||||
context: .
|
||||
file: ./excalidraw-complete.Dockerfile
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:buildcache
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
||||
@@ -44,6 +44,9 @@ jobs:
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
@@ -53,6 +56,7 @@ jobs:
|
||||
context: .
|
||||
file: ./excalidraw-complete.Dockerfile
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:buildcache
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
||||
@@ -1,5 +1,5 @@
|
||||
# 前端构建阶段
|
||||
FROM node:18 AS frontend-builder
|
||||
FROM --platform=$BUILDPLATFORM node:18 AS frontend-builder
|
||||
WORKDIR /app
|
||||
# 复制 excalidraw 子模块
|
||||
COPY excalidraw/ ./excalidraw/
|
||||
@@ -7,9 +7,11 @@ 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
|
||||
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
|
||||
RUN apk --no-cache add ca-certificates
|
||||
WORKDIR /root/
|
||||
# 复制后端二进制文件(已包含嵌入的前端文件)
|
||||
|
||||
Reference in New Issue
Block a user