feat(deploy): 重构部署方案并添加 nginx 代理

- 新增 nginx 服务作为前端和后端的代理
- 重新配置前端和后端服务,不再直接暴露端口
- 更新前端 Dockerfile,简化为静态文件服务器- 在 MarkdownViewer 组件中添加 ExternalLink 图标
This commit is contained in:
黄建武
2025-05-06 13:56:43 +08:00
parent bab61d8462
commit be4c3313d4
6 changed files with 58 additions and 25 deletions

View File

@@ -1,4 +1,3 @@
version: "3.9"
services:
backend:
@@ -13,11 +12,8 @@ services:
- BACKEND_HOST=${BACKEND_HOST}
volumes:
- ./backend:/app
ports:
- "${BACKEND_PORT}:${BACKEND_PORT}"
depends_on:
- frontend
expose:
- "${BACKEND_PORT}" # 不再对外暴露,用于 nginx 内部通信
frontend:
container_name: bilinote-frontend
@@ -26,7 +22,16 @@ services:
dockerfile: BillNote_frontend/Dockerfile
env_file:
- .env
expose:
- "80" # 不暴露给宿主机,只供 nginx 访问
nginx:
container_name: bilinote-nginx
image: nginx:1.25-alpine
ports:
- "${FRONTEND_PORT}:80"
- "80:80"
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- backend
- frontend