Files
frontend_v2/Dockerfile
toom1996 5a8dbf41cb
Some checks failed
deploy / deploy (push) Has been cancelled
update
2026-08-11 22:29:47 +08:00

25 lines
758 B
Docker
Raw Permalink 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.

# ---- 前端构建阶段 ----
FROM node:22-alpine AS build
WORKDIR /app
# 构建期 SSR 拉数据用的「后端内部地址」。
# 在 docker-compose 里通过 build.args.API_SSR 传入(= http://localhost:8090
# 配合 build.network: host让前端构建容器能访问已启动的 backend 容器)。
ARG API_SSR=http://localhost:8090
ENV API_SSR=$API_SSR
# 运行期浏览器调用地址:置空 = 同源相对路径 /api由下方 nginx 反代到 backend:8090
ENV PUBLIC_API_BASE=""
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# ---- 静态托管阶段 ----
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]