Files
freedom-web/Dockerfile
T
yiciheng 867647d2cd
CI/CD Deploy (Web) / 构建前端镜像并部署 (push) Failing after 10m23s
fix: npm 源改为 registry.npmmirror.com(taobao.org 域名已停止服务)
2026-08-31 16:19:29 +08:00

37 lines
1.2 KiB
Docker

# =============================================================
# freedom-web 前端镜像
# 构建阶段:node:16 构建 Vue 静态产物
# 运行阶段:nginx 托管静态文件 + 统一入口反代
#
# 注意:Vue 2.5 + vue-cli 3 为较老项目,固定使用 node:16 保证构建兼容
# =============================================================
FROM node:16-alpine AS builder
WORKDIR /build
# 复制依赖清单,利用 Docker 分层缓存(先安装依赖再复制源码)
COPY package.json .
RUN npm config set registry https://registry.npmmirror.com/ && \
npm install --no-audit --no-fund || npm install --no-audit --no-fund --legacy-peer-deps
# 复制源码
COPY . .
# 构建生产产物(产物输出到 dist/)
RUN npm run build
# ---------- 运行阶段 ----------
FROM nginx:1.24-alpine
WORKDIR /usr/share/nginx/html
# 清理默认站点,复制构建产物
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /build/dist/ /usr/share/nginx/html/
# 统一入口 Nginx 配置(/api 反代到后端 + SPA 路由 + Excel 静态模板)
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 对外暴露端口
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]