24
Dockerfile
Normal file
24
Dockerfile
Normal file
@ -0,0 +1,24 @@
|
||||
# ---- 前端构建阶段 ----
|
||||
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;"]
|
||||
Reference in New Issue
Block a user