fileshare/docker-compose.yml
2025-08-10 12:57:17 +08:00

88 lines
2.5 KiB
YAML
Raw 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:
fileshare:
build:
context: .
dockerfile: Dockerfile # 或使用 Dockerfile.multi 获得更小镜像
container_name: fileshare-service
restart: unless-stopped
ports:
- "${PORT:-8000}:8000"
environment:
- HOST=0.0.0.0
- PORT=8000
- MAX_FILE_SIZE=${MAX_FILE_SIZE:-104857600} # 100MB
- EXPIRE_MINUTES=${EXPIRE_MINUTES:-15}
volumes:
# 持久化上传目录(可选,重启后文件会保留)
- ./data/uploads:/app/uploads
# 日志目录(可选)
- ./data/logs:/app/logs
networks:
- fileshare-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
labels:
- "traefik.enable=true"
- "traefik.http.routers.fileshare.rule=Host(`fileshare.localhost`)"
- "traefik.http.services.fileshare.loadbalancer.server.port=8000"
# 可选使用Traefik作为反向代理生产环境推荐
traefik:
image: traefik:v3.0
container_name: fileshare-traefik
restart: unless-stopped
profiles:
- traefik # 使用profile控制是否启动
command:
- "--api.dashboard=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
- "--certificatesresolvers.letsencrypt.acme.email=${ACME_EMAIL:-admin@localhost}"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
- "8080:8080" # Traefik dashboard
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data/letsencrypt:/letsencrypt
networks:
- fileshare-network
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`traefik.localhost`)"
- "traefik.http.routers.dashboard.service=api@internal"
# 可选Redis缓存用于集群部署时共享会话
redis:
image: redis:7-alpine
container_name: fileshare-redis
restart: unless-stopped
profiles:
- redis # 使用profile控制是否启动
ports:
- "6379:6379"
volumes:
- ./data/redis:/data
networks:
- fileshare-network
command: redis-server --appendonly yes
networks:
fileshare-network:
driver: bridge
volumes:
uploads:
driver: local
logs:
driver: local