Files
new-api/docker-compose-custom.yml
huangzhenpc 04c59d1136 修复docker-compose-custom.yml构建配置
- 添加build配置段,指定Dockerfile构建镜像
- 修复镜像构建问题,现在可以正确编译最新代码
- 保持所有环境变量和网络配置不变

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 15:17:45 +08:00

37 lines
1.2 KiB
YAML

version: '3.4'
services:
new-api-custom:
build:
context: .
dockerfile: Dockerfile
image: new-api-custom:latest
container_name: new-api-custom
restart: always
command: --log-dir /app/logs
ports:
- "3099:3000" # 使用3099端口
volumes:
- ./data:/data # 共享相同数据目录
- ./logs-custom:/app/logs # 使用独立日志目录
environment:
- SQL_DSN=root:123456@tcp(mysql:3306)/new-api # 连接现有的mysql容器
- REDIS_CONN_STRING=redis://redis # 连接现有的redis容器
- TZ=Asia/Shanghai
- ERROR_LOG_ENABLED=true
# - STREAMING_TIMEOUT=120
# - SESSION_SECRET=random_string # 如果需要多机部署
healthcheck:
test: ["CMD-SHELL", "wget -q -O - http://localhost:3000/api/status | grep -o '\"success\":\\s*true' | awk -F: '{print $$2}'"]
interval: 30s
timeout: 10s
retries: 3
networks:
- new-api_default # 连接到现有的网络,复用现有的 redis 和 mysql
# 不定义 redis 和 mysql 服务,直接使用现有运行的容器
# 只需要连接到相同的网络即可访问
networks:
new-api_default:
external: true # 使用现有的网络