refactor: frontend TS migration + Tailwind4/daisyUI5 unify + BUILDPLATFORM docker build
- migrate frontend to TypeScript (vue-tsc strict in build), upgrade all deps to latest (Vite 8, Tailwind 4, daisyUI 5, Pinia 4, vue-router 5) - restructure frontend dirs (api/components/common/layouts/styles/types/views) - drop Element Plus, add daisyUI TagInput; main CSS 490KB->163KB, entry JS 618KB->1.3KB - rewrite Dockerfile(.cn): frontend/backend stages pinned to $BUILDPLATFORM, CGO_ENABLED=0 cross-compile, no QEMU in multi-arch builds; add .dockerignore - local dev: Vite /api proxy + make dev targets; go:embed all:dist with .gitkeep so backend runs without prior frontend build - fix latent bugs: Keys.vue users ref, Settings.vue undefined userStore, Login.vue Ref-as-error display, res.error misuse - add REFACTOR_PLAN.md (phased refactor log)
This commit is contained in:
+28
-16
@@ -1,30 +1,42 @@
|
||||
FROM node:20-alpine AS frontend
|
||||
# syntax=docker/dockerfile:1
|
||||
# 国内镜像加速版:npm/apk/go proxy 均走国内源
|
||||
|
||||
# 前端阶段固定在构建机原生平台编译:多架构构建(linux/amd64,linux/arm64)时
|
||||
# 只编译一次,不再被 QEMU 模拟执行两遍
|
||||
FROM --platform=$BUILDPLATFORM node:22-alpine AS frontend
|
||||
WORKDIR /frontend-build
|
||||
COPY ./frontend .
|
||||
COPY ./frontend ./
|
||||
RUN npm config set registry https://registry.npmmirror.com \
|
||||
&& npm install -g pnpm@10.25.0 --registry=https://registry.npmmirror.com \
|
||||
&& pnpm install --frozen-lockfile \
|
||||
&& pnpm build
|
||||
|
||||
RUN npm config set registry https://registry.npmmirror.com && npm install -g pnpm --registry=https://registry.npmmirror.com && pnpm i && pnpm build
|
||||
|
||||
FROM golang:1.23-alpine AS backend
|
||||
LABEL anther="github.com/Sakurasan"
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
RUN apk --no-cache add make cmake upx
|
||||
# 后端:go.mod 使用纯 Go 的 glebarez/sqlite,可关闭 CGO 直接交叉编译到目标架构,
|
||||
# 因此同样固定在原生平台构建
|
||||
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS backend
|
||||
LABEL author="github.com/Sakurasan"
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk --no-cache add make upx
|
||||
WORKDIR /build
|
||||
COPY . .
|
||||
COPY --from=frontend /frontend-build/dist /build/cmd/openteam/dist
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
CMD [ "go mod tidy","go mod download" ]
|
||||
ENV GO111MODULE=on \
|
||||
GOPROXY=https://goproxy.cn,direct \
|
||||
CGO_ENABLED=0 \
|
||||
GOOS=$TARGETOS \
|
||||
GOARCH=$TARGETARCH
|
||||
RUN make build
|
||||
|
||||
FROM alpine:latest AS runner
|
||||
# 设置alpine 时间为上海时间
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
RUN apk update && apk --no-cache add tzdata ffmpeg && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& echo "Asia/Shanghai" > /etc/timezone
|
||||
# RUN apk update && apk --no-cache add openssl libgcc libstdc++ binutils
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk update && apk --no-cache add tzdata ffmpeg ca-certificates && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& echo "Asia/Shanghai" > /etc/timezone
|
||||
WORKDIR /app
|
||||
COPY --from=backend /build/bin/openteam /app/openteam
|
||||
ENV GIN_MODE=release
|
||||
ENV PATH=$PATH:/app
|
||||
EXPOSE 80 443
|
||||
ENTRYPOINT ["/app/openteam"]
|
||||
ENTRYPOINT ["/app/openteam"]
|
||||
|
||||
Reference in New Issue
Block a user