Some checks failed
Build and Deploy Front / deploy (push) Has been cancelled
Dockerfile 误用 production 构建会把 VITE_API_ORIGIN 打成 api.ideship.com;运行时按 hostname 纠正,并支持 FRONT_BUILD_SCRIPT=build:test。 Co-authored-by: Cursor <cursoragent@cursor.com>
23 lines
1.0 KiB
Docker
23 lines
1.0 KiB
Docker
# k3s / Kaniko:静态 SPA(方案 A)。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}
|
||
|
||
FROM docker.m.daocloud.io/library/nginx:1.27-alpine
|
||
COPY --from=build /app/dist /usr/share/nginx/html/
|
||
COPY nginx-k3s.conf /etc/nginx/conf.d/default.conf
|
||
EXPOSE 80
|