front/Dockerfile.k3s
zzh c6723ab476
Some checks failed
Build and Deploy Front / deploy (push) Failing after 32m20s
chore: 前端部署去掉 nginx,静态由 serve,TLS 交 Traefik
生产不再内置 nginx/`__cos__`;镜像用 serve -s,HTTPS 由 Traefik+cert-manager;面单预览走 stream。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-23 12:24:36 +08:00

28 lines
1.3 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# k3s / Kaniko:静态 SPA(方案 A)。TLS 由 Traefik(websecure) + cert-manager 终结。
# API 由浏览器按站点域名直连:
# test.ideship.com → api.test.ideship.com;其余 → api.ideship.com
# FRONT_BUILD_SCRIPT:
# prod 默认 build(.env.production → api.ideship.com)
# test 传 build:test(.env.ideship-test → api.test.ideship.com)
# 即使误用 production 构建,运行时也会按 hostname 纠正到测试 API。
FROM docker.m.daocloud.io/library/node:20-alpine AS build
WORKDIR /app
ARG FRONT_BUILD_SCRIPT=build
RUN npm config set registry https://registry.npmmirror.com \
&& npm install -g pnpm@9.15.9
COPY package.json pnpm-lock.yaml ./
# --ignore-scripts:跳过 gifsicle/optipng 等原生编译(需 autoreconf;vite 未启用 imagemin)
RUN pnpm config set registry https://registry.npmmirror.com \
&& pnpm install --frozen-lockfile --ignore-scripts
COPY . .
RUN pnpm run ${FRONT_BUILD_SCRIPT}
# 仅静态托管 + SPA fallback;不再内置 nginx(网关层 Traefik 负责 HTTPS)
FROM docker.m.daocloud.io/library/node:20-alpine
WORKDIR /app
RUN npm config set registry https://registry.npmmirror.com \
&& npm install -g serve@14.2.4
COPY --from=build /app/dist ./dist
EXPOSE 80
CMD ["serve", "-s", "dist", "-l", "80"]