Files
full-stack-doc/backend/docker-compose.yml
2025-10-14 20:05:29 +08:00

64 lines
1.5 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

version: '3.8'
services:
cloud-drive-backend:
build: .
container_name: cloud-drive-backend
ports:
- "8002:8002"
environment:
- ENVIRONMENT=production
- DATABASE_URL=mysql://username:password@mysql-host:3306/mytest_db
- REDIS_URL=redis://redis-host:6379/0
- SECRET_KEY=your-production-secret-key
- CORS_ORIGINS=http://localhost:3003,https://yourdomain.com
volumes:
- ./uploads:/app/uploads
- ./logs:/app/logs
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8002/api/v1/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- cloud-drive-network
# 可选MySQL数据库服务
mysql:
image: mysql:8.0
container_name: cloud-drive-mysql
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
- MYSQL_DATABASE=mytest_db
- MYSQL_USER=username
- MYSQL_PASSWORD=password
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
restart: unless-stopped
networks:
- cloud-drive-network
# 可选Redis服务
redis:
image: redis:7-alpine
container_name: cloud-drive-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
restart: unless-stopped
networks:
- cloud-drive-network
volumes:
mysql_data:
redis_data:
networks:
cloud-drive-network:
driver: bridge