chore: Docker 部署——多阶段 Dockerfile + compose + 数据卷持久化
- 前端 node:22-alpine 构建阶段(npm ci + vite build) - 运行时 python:3.14-slim + uv --frozen 冻结安装(依赖层独立缓存) - entrypoint: 数据卷为空时自动建库并导入 254 套样板 - SQLite 落数据卷 /app/db(HMC_DATABASE_URL 可切 MySQL); healthcheck /api/health - .dockerignore 排除构建无关资产; .gitattributes 强制 sh LF
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
image: menchuang:latest
|
||||
container_name: menchuang
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8000:8000"
|
||||
environment:
|
||||
# SQLite 落在数据卷; 如需 MySQL: mysql+aiomysql://user:pwd@host:3306/hmc
|
||||
HMC_DATABASE_URL: sqlite+aiosqlite:////app/db/huamenchuang.db
|
||||
# 生产务必换成随机长密钥(登录态签名)
|
||||
HMC_JWT_SECRET: ${HMC_JWT_SECRET:-change-me-in-production-please-set-a-long-random-secret-key}
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- db_data:/app/db
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request;urllib.request.urlopen('http://127.0.0.1:8000/api/health',timeout=4)"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
Reference in New Issue
Block a user