mirror of
https://github.com/Dvorinka/excalidraw-full.git
synced 2026-06-03 13:52:56 +00:00
更新 Dockerfile 和 GitHub Actions 工作流,支持多平台构建。添加 QEMU 设置以支持不同架构,修改 Dockerfile 以使用动态平台参数构建前后端应用。 (#14)
This commit is contained in:
@@ -42,6 +42,9 @@ jobs:
|
|||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
@@ -51,6 +54,7 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: ./excalidraw-complete.Dockerfile
|
file: ./excalidraw-complete.Dockerfile
|
||||||
push: true
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:buildcache
|
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
|
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=semver,pattern={{major}}.{{minor}}
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
@@ -53,6 +56,7 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: ./excalidraw-complete.Dockerfile
|
file: ./excalidraw-complete.Dockerfile
|
||||||
push: true
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:buildcache
|
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
|
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
|
WORKDIR /app
|
||||||
# 复制 excalidraw 子模块
|
# 复制 excalidraw 子模块
|
||||||
COPY excalidraw/ ./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
|
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
|
RUN apk update && apk add --no-cache git
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
# 复制 Go 模块文件
|
# 复制 Go 模块文件
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
@@ -18,10 +20,10 @@ COPY . .
|
|||||||
# 复制前端构建文件到正确位置,以便 Go embed 可以找到
|
# 复制前端构建文件到正确位置,以便 Go embed 可以找到
|
||||||
COPY --from=frontend-builder /app/excalidraw/excalidraw-app/build ./frontend/
|
COPY --from=frontend-builder /app/excalidraw/excalidraw-app/build ./frontend/
|
||||||
# 构建 Go 应用
|
# 构建 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
|
RUN apk --no-cache add ca-certificates
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
# 复制后端二进制文件(已包含嵌入的前端文件)
|
# 复制后端二进制文件(已包含嵌入的前端文件)
|
||||||
|
|||||||
Reference in New Issue
Block a user