feat: 添加Docker和部署配置

- 添加Dockerfile用于容器化部署
- 添加docker-compose.yml用于本地开发环境
- 添加build.sh构建脚本
- 添加README.md项目文档
- 添加API文档
This commit is contained in:
徐在坤
2026-01-18 15:58:05 +08:00
parent 8582e88ec2
commit ebfd705b93
7 changed files with 1533 additions and 0 deletions

38
api/docker-compose.yml Normal file
View File

@@ -0,0 +1,38 @@
version: '3.8'
services:
api:
build:
context: .
dockerfile: Dockerfile
image: life-echo-api:latest
container_name: life-echo-api-prod
ports:
- "8000:8000"
env_file:
- .env.prod
volumes:
# 持久化数据库
- ./data:/app/data
restart: always
healthcheck:
test: ["CMD", "python", "-c", "import requests; requests.get('http://localhost:8000/health')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
networks:
- life-echo-network
# 资源限制
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '1'
memory: 1G
networks:
life-echo-network:
driver: bridge