Files
ChatRoom/docker-compose.yml

68 lines
1.6 KiB
YAML
Raw Normal View History

2026-02-04 00:11:24 +08:00
version: '3.8'
2026-02-03 23:45:27 +08:00
services:
app:
2026-02-04 13:06:11 +08:00
build: . # 强制使用当前代码构建镜像
image: zhengdushi/chatroom:latest
2026-02-03 23:45:27 +08:00
container_name: chatroom-app
ports:
- "2779:2779"
environment:
- PORT=2779
2026-02-04 00:11:24 +08:00
- RABBITMQ_HOST=rabbitmq
- RABBITMQ_USER=admin
2026-02-04 13:06:11 +08:00
- RABBITMQ_PASS=1218Zhengyaqi
2026-02-04 00:11:24 +08:00
- RABBITMQ_URL=amqp://admin:1218Zhengyaqi@rabbitmq:5672/
2026-02-04 13:06:11 +08:00
- REDIS_ADDR=redis:6379 # 确保环境变量正确传递
2026-02-03 23:45:27 +08:00
depends_on:
2026-02-04 13:06:11 +08:00
rabbitmq:
condition: service_healthy # 等待 RabbitMQ 健康
redis:
condition: service_healthy # 等待 Redis 健康
2026-02-04 00:11:24 +08:00
restart: unless-stopped
networks:
- chatroom-net
2026-02-03 23:45:27 +08:00
rabbitmq:
2026-02-04 00:11:24 +08:00
image: rabbitmq:3-management-alpine
2026-02-03 23:45:27 +08:00
container_name: chatroom-rabbitmq
ports:
- "5672:5672"
- "15672:15672"
2026-02-04 00:11:24 +08:00
environment:
RABBITMQ_DEFAULT_USER: admin
RABBITMQ_DEFAULT_PASS: 1218Zhengyaqi # ← 必须和上面一致!
2026-02-04 13:06:11 +08:00
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "-q", "check_running"]
interval: 10s
timeout: 5s
retries: 5
2026-02-04 00:11:24 +08:00
volumes:
- rabbitmq_data:/var/lib/rabbitmq
restart: unless-stopped
networks:
- chatroom-net
2026-02-04 13:06:11 +08:00
redis:
image: redis:alpine
container_name: chatroom-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
restart: unless-stopped
networks:
- chatroom-net
2026-02-04 00:11:24 +08:00
networks:
chatroom-net:
driver: bridge
volumes:
2026-02-04 13:06:11 +08:00
rabbitmq_data:
redis_data: