chore: 完善 Docker 部署配置并修复测试超时

- 新增 Dockerfile: 多阶段构建,优化镜像大小
- 新增 .dockerignore: 加速构建,排除不必要文件
- 更新 docker-compose.yml: 使用 SQLite 简化部署
- 修复 vitest.config.js: testTimeout 改为 60000ms 修复慢测试超时
This commit is contained in:
2026-04-08 22:13:46 +08:00
parent a85d822419
commit 1b96715b55
4 changed files with 130 additions and 12 deletions

View File

@@ -1,26 +1,48 @@
version: '3.8'
# 用户管理系统 - Docker 部署配置
# 使用 SQLite 数据库,无需额外数据库服务
#
# 使用方法:
# docker compose up -d # 启动服务
# docker compose logs -f # 查看日志
# docker compose down # 停止服务
#
# 访问: http://localhost:8080
services:
# 用户管理服务
user-management:
build: .
container_name: user-ms-app
app:
build:
context: .
dockerfile: Dockerfile
container_name: user-management-app
restart: unless-stopped
ports:
- "8080:8080"
volumes:
# 持久化 SQLite 数据库
- app-data:/app/data
# 持久化日志
- app-logs:/app/logs
environment:
- DB_HOST=postgres
- DB_PORT=5432
- DB_USER=user_ms
- DB_PASSWORD=user_ms_pass
- DB_NAME=user_ms
depends_on:
- postgres
- TZ=Asia/Shanghai
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/api/v1/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
networks:
- user-ms-network
volumes:
postgres-data:
app-data:
driver: local
app-logs:
driver: local
networks:
user-ms-network:
driver: bridge