topfans/docker/docker-compose.local.yml
2026-04-24 18:04:55 +08:00

311 lines
8.1 KiB
YAML

# ===================================================================
# 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
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
# ==================== 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
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
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