1
This commit is contained in:
+10
-22
@@ -1,17 +1,15 @@
|
||||
# ============================================================
|
||||
# 统一构建:Flutter web 前端 + Go 后端 + Node 渲染器
|
||||
# 统一构建:uni-app H5 前端 + Go 后端
|
||||
# 构建上下文必须为仓库根目录(docker build -f server/Dockerfile .)
|
||||
# ============================================================
|
||||
|
||||
# ---------- 前端:Flutter web 构建 ----------
|
||||
FROM ghcr.io/cirruslabs/flutter:stable AS web-builder
|
||||
ENV PUB_HOSTED_URL=https://pub.flutter-io.cn
|
||||
ENV FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
|
||||
# ---------- 前端:uni-app H5 构建 ----------
|
||||
FROM node:20-alpine AS web-builder
|
||||
WORKDIR /web
|
||||
COPY app/pubspec.yaml app/pubspec.lock ./
|
||||
RUN flutter pub get
|
||||
COPY app/ .
|
||||
RUN flutter build web --release
|
||||
COPY app-uni/package.json app-uni/package-lock.json ./
|
||||
RUN npm ci --registry=https://registry.npmmirror.com
|
||||
COPY app-uni/ .
|
||||
RUN npm run build:h5
|
||||
|
||||
# ---------- 后端:Go 编译 ----------
|
||||
FROM golang:alpine AS builder
|
||||
@@ -28,26 +26,16 @@ RUN go mod download
|
||||
COPY server/ .
|
||||
RUN go build -ldflags="-s -w" -o main ./main.go
|
||||
|
||||
# ---------- 渲染器:Node + headless-gl(需原生编译) ----------
|
||||
FROM node:20-alpine AS renderer
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk add --no-cache git python3 make g++ mesa mesa-dev ca-certificates tzdata
|
||||
WORKDIR /render
|
||||
COPY server/scripts/avatar-render/package*.json ./
|
||||
RUN npm ci --omit=dev --registry=https://registry.npmmirror.com
|
||||
|
||||
# ---------- 运行时 ----------
|
||||
FROM alpine:3.19
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk add --no-cache ca-certificates tzdata libstdc++ libgcc mesa nodejs
|
||||
&& apk add --no-cache ca-certificates tzdata libstdc++ libgcc
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
WORKDIR /app
|
||||
COPY --from=web-builder /web/build/web ./web
|
||||
COPY --from=web-builder /web/dist/build/h5 ./web
|
||||
COPY --from=builder /build/config.yml .
|
||||
COPY --from=builder /build/main .
|
||||
COPY --from=renderer /render/node_modules ./scripts/avatar-render/node_modules
|
||||
COPY server/scripts/avatar-render/ ./scripts/avatar-render/
|
||||
RUN mkdir -p /app/workspace /app/data
|
||||
EXPOSE 3007
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["./main"]
|
||||
|
||||
Reference in New Issue
Block a user