topfans/docker/docker-compose.local.yml

410 lines
12 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.

# ===================================================================
# TopFans Docker Compose - Local Development (8G+ RAM)
# ===================================================================
# Usage:
# docker-compose -f docker-compose.local.yml --profile local up -d
# ===================================================================
x-common-env: &common-env
GIN_MODE: debug
ENV: development
LOG_LEVEL: info
DB_HOST: host.docker.internal
DB_PORT: 15432
DB_USER: postgres
DB_PASSWORD: ${DB_PASSWORD:-123456}
DB_NAME: ${DB_NAME:-top-fans}
DB_SSLMODE: disable
x-healthcheck: &healthcheck
test: ["CMD-SHELL", "nc -z localhost 20000 || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
services:
# ==================== Dubbo Services ====================
# Start with UserService (root service - all others depend on it)
userservice:
image: topfans/userservice:latest
build:
context: ..
dockerfile: docker/Dockerfile.services
target: userservice
container_name: topfans-userservice
restart: unless-stopped
environment:
<<: *common-env
PORT: 20000
REDIS_HOST: host.docker.internal
REDIS_PORT: 6379
REDIS_DB: 0
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- topfans-net
expose:
- "20000"
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 20000 || exit 1"]
<<: *healthcheck
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
# Dubbo services (can start in parallel after UserService is ready)
assetservice:
image: topfans/assetservice:latest
build:
context: ..
dockerfile: docker/Dockerfile.services
target: assetservice
container_name: topfans-assetservice
restart: unless-stopped
environment:
<<: *common-env
PORT: 20003
DUBBO_USER_SERVICE_URL: tri://userservice:20000
OSS_REGION: ${OSS_REGION:-cn-shanghai}
OSS_BUCKET_NAME: ${OSS_BUCKET_NAME:-top-fans-test}
OSS_STS_ROLE_ARN: ${OSS_STS_ROLE_ARN:-acs:ram::1387642798143585:role/top-fans-oss-user}
OSS_ACCESS_KEY_ID: ${OSS_ACCESS_KEY_ID:-}
OSS_ACCESS_KEY_SECRET: ${OSS_ACCESS_KEY_SECRET:-}
OSS_AVATAR_DIR: ${OSS_AVATAR_DIR:-avatar/}
OSS_ASSET_DIR: ${OSS_ASSET_DIR:-asset/}
OSS_TOKEN_EXPIRE_TIME: ${OSS_TOKEN_EXPIRE_TIME:-3600}
depends_on:
userservice:
condition: service_healthy
networks:
- topfans-net
extra_hosts:
- "host.docker.internal:host-gateway"
expose:
- "20003"
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 20003 || exit 1"]
<<: *healthcheck
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
socialservice:
image: topfans/socialservice:latest
build:
context: ..
dockerfile: docker/Dockerfile.services
target: socialservice
container_name: topfans-socialservice
restart: unless-stopped
environment:
<<: *common-env
PORT: 20002
DUBBO_USER_SERVICE_URL: tri://userservice:20000
DUBBO_ASSET_SERVICE_URL: tri://assetservice:20003
depends_on:
userservice:
condition: service_healthy
assetservice:
condition: service_healthy
networks:
- topfans-net
extra_hosts:
- "host.docker.internal:host-gateway"
expose:
- "20002"
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 20002 || exit 1"]
<<: *healthcheck
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
galleryservice:
image: topfans/galleryservice:latest
build:
context: ..
dockerfile: docker/Dockerfile.services
target: galleryservice
container_name: topfans-galleryservice
restart: unless-stopped
environment:
<<: *common-env
PORT: 20004
DUBBO_USER_SERVICE_URL: tri://userservice:20000
DUBBO_ASSET_SERVICE_URL: tri://assetservice:20003
depends_on:
userservice:
condition: service_healthy
assetservice:
condition: service_healthy
networks:
- topfans-net
extra_hosts:
- "host.docker.internal:host-gateway"
expose:
- "20004"
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 20004 || exit 1"]
<<: *healthcheck
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
activityservice:
image: topfans/activityservice:latest
build:
context: ..
dockerfile: docker/Dockerfile.services
target: activityservice
container_name: topfans-activityservice
restart: unless-stopped
environment:
<<: *common-env
PORT: 20005
DUBBO_USER_SERVICE_URL: tri://userservice:20000
depends_on:
userservice:
condition: service_healthy
networks:
- topfans-net
extra_hosts:
- "host.docker.internal:host-gateway"
expose:
- "20005"
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 20005 || exit 1"]
<<: *healthcheck
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
taskservice:
image: topfans/taskservice:latest
build:
context: ..
dockerfile: docker/Dockerfile.services
target: taskservice
container_name: topfans-taskservice
restart: unless-stopped
environment:
<<: *common-env
PORT: 20006
USER_SERVICE_URL: tri://userservice:20000
depends_on:
userservice:
condition: service_healthy
networks:
- topfans-net
extra_hosts:
- "host.docker.internal:host-gateway"
expose:
- "20006"
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 20006 || exit 1"]
<<: *healthcheck
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
starbookservice:
image: topfans/starbookservice:latest
build:
context: ..
dockerfile: docker/Dockerfile.services
target: starbookservice
container_name: topfans-starbookservice
restart: unless-stopped
environment:
<<: *common-env
PORT: 20007
ASSET_SERVICE_URL: tri://assetservice:20003
depends_on:
userservice:
condition: service_healthy
assetservice:
condition: service_healthy
networks:
- topfans-net
extra_hosts:
- "host.docker.internal:host-gateway"
expose:
- "20007"
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 20007 || exit 1"]
<<: *healthcheck
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
# ==================== AI Chat Service ====================
aichatservice:
image: topfans/aichatservice:latest
build:
context: ..
dockerfile: docker/Dockerfile.services
target: aichatservice
container_name: topfans-aichatservice
restart: unless-stopped
environment:
<<: *common-env
PORT: 20008
DB_HOST: host.docker.internal
DB_PORT: 15432
REDIS_HOST: host.docker.internal
REDIS_PORT: 6379
REDIS_DB: 0
MINIMAX_API_KEY: ${MINIMAX_API_KEY:-}
MINIMAX_API_URL: ${MINIMAX_API_URL:-https://api.minimaxi.com/v1}
MINIMAX_MODEL: ${MINIMAX_MODEL:-M2-her}
QWEN_API_KEY: ${QWEN_API_KEY:-}
QWEN_API_URL: ${QWEN_API_URL:-https://dashscope.aliyuncs.com/compatible-mode/v1}
QWEN_MODEL: ${QWEN_MODEL:-qwen-plus}
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- topfans-net
expose:
- "20008"
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 20008 || exit 1"]
<<: *healthcheck
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
# ==================== Laser Compositor Service (镭射卡 6 层合成) ====================
lasercompositor:
image: topfans/lasercompositor:latest
build:
context: ..
dockerfile: docker/Dockerfile.services
target: lasercompositor
# 跳过 pull(本地无 push 到 registry),直接走 build
pull_policy: never
container_name: topfans-lasercompositor
restart: unless-stopped
environment:
<<: *common-env
COMPOSITOR_PORT: 7002
OSS_REGION: ${OSS_REGION:-cn-shanghai}
OSS_BUCKET_NAME: ${OSS_BUCKET_NAME:-top-fans-test}
OSS_ACCESS_KEY_ID: ${OSS_ACCESS_KEY_ID:-}
OSS_ACCESS_KEY_SECRET: ${OSS_ACCESS_KEY_SECRET:-}
OSS_ASSET_DIR: ${OSS_ASSET_DIR:-asset/}
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- topfans-net
expose:
- "7002"
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 7002 || exit 1"]
<<: *healthcheck
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
# ==================== API Gateway ====================
gateway:
image: topfans/gateway:latest
build:
context: ..
dockerfile: docker/Dockerfile.services
target: gateway
container_name: topfans-gateway
restart: unless-stopped
environment:
<<: *common-env
SERVER_PORT: 8080
JWT_SECRET: ${JWT_SECRET:-topfans-secret-key-please-change-in-production}
DUBBO_USER_SERVICE_URL: tri://userservice:20000
DUBBO_SOCIAL_SERVICE_URL: tri://socialservice:20002
DUBBO_ASSET_SERVICE_URL: tri://assetservice:20003
DUBBO_GALLERY_SERVICE_URL: tri://galleryservice:20004
DUBBO_ACTIVITY_SERVICE_URL: tri://activityservice:20005
DUBBO_TASK_SERVICE_URL: tri://taskservice:20006
DUBBO_STARBOOK_SERVICE_URL: tri://starbookservice:20007
DIFY_API_BASE: ${DIFY_API_BASE:-http://host.docker.internal:8081/v1}
DIFY_API_KEY: ${DIFY_API_KEY:-}
DUBBO_AI_CHAT_SERVICE_URL: tri://aichatservice:20008
# 镭射卡 AI 生成MiniMax 文生图)
MINIMAX_API_KEY: ${MINIMAX_API_KEY:-}
MINIMAX_API_URL: ${MINIMAX_API_URL:-https://api.minimaxi.com/v1/image_generation}
# 镭射卡 6 层合成微服务(容器内通过 service name 访问)
LASER_COMPOSITOR_URL: http://lasercompositor:7002
# 抠图(人像扣底)
SEGMENT_PROVIDER: ${SEGMENT_PROVIDER:-imageseg}
# OSS 配置gateway 用于签名 + 抠图上传)
OSS_REGION: ${OSS_REGION:-cn-shanghai}
OSS_BUCKET_NAME: ${OSS_BUCKET_NAME:-top-fans-test}
OSS_STS_ROLE_ARN: ${OSS_STS_ROLE_ARN:-}
OSS_ACCESS_KEY_ID: ${OSS_ACCESS_KEY_ID:-}
OSS_ACCESS_KEY_SECRET: ${OSS_ACCESS_KEY_SECRET:-}
OSS_AVATAR_DIR: ${OSS_AVATAR_DIR:-avatar/}
OSS_ASSET_DIR: ${OSS_ASSET_DIR:-asset/}
OSS_TOKEN_EXPIRE_TIME: ${OSS_TOKEN_EXPIRE_TIME:-3600}
depends_on:
userservice:
condition: service_healthy
assetservice:
condition: service_healthy
socialservice:
condition: service_healthy
galleryservice:
condition: service_healthy
activityservice:
condition: service_healthy
taskservice:
condition: service_healthy
starbookservice:
condition: service_healthy
aichatservice:
condition: service_healthy
lasercompositor:
condition: service_healthy
networks:
- topfans-net
ports:
- "8080:8080"
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 8080 || exit 1"]
<<: *healthcheck
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
networks:
topfans-net:
driver: bridge