mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-05-06 20:42:52 +08:00
feat(deploy): 重构部署方案并添加 nginx 代理
- 新增 nginx 服务作为前端和后端的代理 - 重新配置前端和后端服务,不再直接暴露端口 - 更新前端 Dockerfile,简化为静态文件服务器- 在 MarkdownViewer 组件中添加 ExternalLink 图标
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# === 前端构建阶段 ===
|
||||
FROM node:18-alpine AS build
|
||||
FROM node:18-alpine AS builder
|
||||
|
||||
# 安装 pnpm
|
||||
RUN npm install -g pnpm
|
||||
@@ -13,20 +13,13 @@ COPY ./BillNote_frontend /app
|
||||
# 安装依赖并构建
|
||||
RUN pnpm install && pnpm run build
|
||||
|
||||
# === nginx 运行阶段 ===
|
||||
FROM nginx:alpine
|
||||
# --- 阶段2:使用 nginx 作为静态服务器 ---
|
||||
FROM nginx:1.25-alpine
|
||||
|
||||
# 删除默认配置(可选)
|
||||
RUN rm -rf /etc/nginx/conf.d/default.conf
|
||||
COPY ./BillNote_frontend/deploy/default.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 拷贝模板配置
|
||||
COPY ./BillNote_frontend/deploy/default.conf.template /etc/nginx/templates/default.conf.template
|
||||
|
||||
# 拷贝构建产物
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
# 拷贝启动脚本
|
||||
COPY ./BillNote_frontend/deploy/start.sh /start.sh
|
||||
RUN chmod +x /start.sh
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# 使用启动脚本启动容器
|
||||
CMD ["/start.sh"]
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
Reference in New Issue
Block a user