添加Redis缓存支持和Docker部署配置

- 新增Redis缓存功能,用于优化仪表板统计数据查询性能
- 添加Redis连接池管理和自动降级机制,无连接时自动跳过缓存
- 配置Dockerfile支持前后端容器化部署
- 添加docker-compose编排文件实现一键部署
- 更新README文档包含新的部署方式和架构说明
- 在入库出库操作后清除相关缓存以保证数据一致性
This commit is contained in:
2026-07-07 10:08:33 +08:00
parent 48007f536d
commit b764f6fa59
12 changed files with 245 additions and 6 deletions

4
frontend/.dockerignore Normal file
View File

@@ -0,0 +1,4 @@
node_modules/
dist/
.env
.env.local

20
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,20 @@
# ============================================================
# 药品管理系统 — 前端 Dockerfile多阶段构建
# ============================================================
# ---- 构建阶段 ----
FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
# ---- 运行阶段 ----
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

19
frontend/nginx.conf Normal file
View File

@@ -0,0 +1,19 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# API 代理到后端
location /api/ {
proxy_pass http://backend:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Vue SPA 路由
location / {
try_files $uri $uri/ /index.html;
}
}