- 删除 Dockerfile.dev 和 entrypoint.sh,简化开发环境配置 - 修改 Dockerfile 使用 node 基础镜像并添加代理服务器 - 新增 proxy-server.js 处理 API 请求代理 - 更新 nginx 配置指向本地代理服务 - 修改前端请求添加自定义 base URL 头支持
34 lines
531 B
Docker
34 lines
531 B
Docker
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package*.json ./
|
|
|
|
RUN npm install
|
|
|
|
COPY . .
|
|
|
|
RUN npm run build
|
|
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/dist ./dist
|
|
COPY --from=builder /app/proxy-server.js ./
|
|
|
|
RUN npm install express cors http-proxy-middleware
|
|
|
|
RUN apk add --no-cache nginx
|
|
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
COPY start.sh /start.sh
|
|
|
|
RUN chmod +x /start.sh
|
|
|
|
EXPOSE 80 3000
|
|
|
|
CMD ["/start.sh"]
|