feat: 添加 Docker 部署支持
- Dockerfile (多阶段构建,生产优化) - 基于 node:18-alpine - 非 root 用户运行(安全) - 健康检查配置 - docker-compose.yml - 一键部署配置 - 网络隔离 - 自动重启策略 - .dockerignore - 排除不必要文件 - 优化镜像大小 - .env.example - 环境变量模板 - 更新 README.md - Docker 部署文档 - 常用命令示例 - 生产环境配置
This commit is contained in:
29
docker-compose.yml
Normal file
29
docker-compose.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
ip-service:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: ip-service
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=3000
|
||||
volumes:
|
||||
# 可选:挂载日志目录
|
||||
- ./logs:/app/logs
|
||||
networks:
|
||||
- ip-network
|
||||
healthcheck:
|
||||
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
|
||||
interval: 30s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
networks:
|
||||
ip-network:
|
||||
driver: bridge
|
||||
Reference in New Issue
Block a user