refactor(部署): 重构部署架构,使用本地代理服务器替代环境变量配置
- 删除 Dockerfile.dev 和 entrypoint.sh,简化开发环境配置 - 修改 Dockerfile 使用 node 基础镜像并添加代理服务器 - 新增 proxy-server.js 处理 API 请求代理 - 更新 nginx 配置指向本地代理服务 - 修改前端请求添加自定义 base URL 头支持
This commit is contained in:
22
Dockerfile
22
Dockerfile
@@ -10,16 +10,24 @@ COPY . .
|
||||
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
FROM node:20-alpine
|
||||
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
WORKDIR /app
|
||||
|
||||
COPY nginx.conf.template /etc/nginx/templates/nginx.conf.template
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=builder /app/proxy-server.js ./
|
||||
|
||||
COPY entrypoint.sh /docker-entrypoint.sh
|
||||
RUN npm install express cors http-proxy-middleware
|
||||
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
RUN apk add --no-cache nginx
|
||||
|
||||
EXPOSE 80
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
CMD ["/docker-entrypoint.sh"]
|
||||
COPY start.sh /start.sh
|
||||
|
||||
RUN chmod +x /start.sh
|
||||
|
||||
EXPOSE 80 3000
|
||||
|
||||
CMD ["/start.sh"]
|
||||
|
||||
Reference in New Issue
Block a user